From b4cf78d1eaed900aa6acbcab01bc8693c88b0275 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 28 Feb 2009 11:46:52 +0100 Subject: added localtime_r and a stub (which needs mutexes, which we still have to port!) --- tests/port/GNUmakefile | 6 ++++-- tests/port/Makefile.W32 | 7 +++++-- tests/port/test_localtime_r.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 tests/port/test_localtime_r.c (limited to 'tests/port') 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 /* 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; +} -- cgit v1.2.3-54-g00ecf