summaryrefslogtreecommitdiff
path: root/tests/port
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-02-28 11:46:52 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-02-28 11:46:52 +0100
commitb4cf78d1eaed900aa6acbcab01bc8693c88b0275 (patch)
treea4682a8004ee45b46f4f6d4c5e5b980ec1692ea1 /tests/port
parent2e27ca524f38f537e6bf706c7aa7dce79a745e17 (diff)
downloadwolfbones-b4cf78d1eaed900aa6acbcab01bc8693c88b0275.tar.gz
wolfbones-b4cf78d1eaed900aa6acbcab01bc8693c88b0275.tar.bz2
added localtime_r and a stub (which needs mutexes, which we still have to port!)
Diffstat (limited to 'tests/port')
-rw-r--r--tests/port/GNUmakefile6
-rw-r--r--tests/port/Makefile.W327
-rw-r--r--tests/port/test_localtime_r.c23
3 files changed, 32 insertions, 4 deletions
diff --git a/tests/port/GNUmakefile b/tests/port/GNUmakefile
index 0410187..dd28702 100644
--- a/tests/port/GNUmakefile
+++ b/tests/port/GNUmakefile
@@ -10,7 +10,8 @@ TEST_BINS = \
test_strdup$(EXE) \
test_strerror_r$(EXE) \
test_strcasecmp$(EXE) \
- test_strncasecmp$(EXE)
+ test_strncasecmp$(EXE) \
+ test_localtime_r$(EXE)
-include $(TOPDIR)/makefiles/gmake/sub.mk
@@ -29,4 +30,5 @@ local_test:
@./test_strcasecmp >/dev/null
@echo "Testing strncasecmp.."
@./test_strncasecmp >/dev/null
-
+ @echo "Testing localtime_r.."
+ @./test_localtime_r >/dev/null
diff --git a/tests/port/Makefile.W32 b/tests/port/Makefile.W32
index 291dfcb..18eb2d7 100644
--- a/tests/port/Makefile.W32
+++ b/tests/port/Makefile.W32
@@ -10,7 +10,8 @@ TEST_BINS = \
test_strdup.exe \
test_strerror_r.exe \
test_strcasecmp.exe \
- test_strncasecmp.exe
+ test_strncasecmp.exe \
+ test_localtime_r.exe
!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk
@@ -19,6 +20,7 @@ test_strdup.exe: test_strdup.obj
test_strerror_r.exe: test_strerror_r.obj
test_strcasecmp.exe: test_strcasecmp.obj
test_strncasecmp.exe: test_strncasecmp.obj
+test_localtime_r.exe: test_localtime_r.obj
local_all:
@@ -35,4 +37,5 @@ local_test:
@test_strcasecmp >NUL 2>NUL
@echo Testing strncasecmp..
@test_strncasecmp >NUL 2>NUL
-
+ @echo Testing localtime_r..
+ @test_localtime_r >NUL 2>NUL
diff --git a/tests/port/test_localtime_r.c b/tests/port/test_localtime_r.c
new file mode 100644
index 0000000..9c9ba3e
--- /dev/null
+++ b/tests/port/test_localtime_r.c
@@ -0,0 +1,23 @@
+#include "port/sys.h"
+
+#define TEST_LOCALTIME_R
+#include "port/time.h" /* for localtime_r */
+
+#include "port/string.h" /* for memcmp */
+
+#include <stdlib.h> /* for exit, EXIT_SUCCESS, free */
+
+int main( void ) {
+ time_t cur_time;
+ struct tm local_time;
+ struct tm local_time2;
+
+ time( &cur_time );
+ if( cur_time < 0 ) return EXIT_FAILURE;
+
+ if( localtime_r( &cur_time, &local_time ) == NULL ) return EXIT_FAILURE;
+ if( wolf_port_localtime_r( &cur_time, &local_time2 ) == NULL ) return EXIT_FAILURE;
+ if( memcmp( &local_time, &local_time2, sizeof( struct tm ) ) != 0 ) return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}