From f0453faf366b802bf3e3575050b10b469b9dcea6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 26 Apr 2016 09:28:09 -0400 Subject: [PATCH 1/7] libCom/test: add test for HST time zone Test US/Hawaii zone which does not observe daylight saving time. --- src/libCom/test/epicsTimeZoneTest.c | 56 ++++++++++++++++++----------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/libCom/test/epicsTimeZoneTest.c b/src/libCom/test/epicsTimeZoneTest.c index dd12b1acf..685295fc4 100644 --- a/src/libCom/test/epicsTimeZoneTest.c +++ b/src/libCom/test/epicsTimeZoneTest.c @@ -17,15 +17,9 @@ #endif static -void setTZ(const char *base, const char *dst, int offset) +void setTZ(const char *tz) { - char tz[20]; - if(offset!=0 || dst) - sprintf(tz, "%s%d%s", base, offset/3600, dst); - else - sprintf(tz, "%s", base); - testDiag("TZ=\"%s\"", tz); - + testDiag("TZ = \"%s\"", tz); epicsEnvSet("TZ", tz); tzset(); } @@ -86,32 +80,52 @@ void test_gmtime(time_t T, int sec, int min, int hour, MAIN(epicsTimeZoneTest) { - testPlan(80); + testPlan(160); /* 1445259616 * Mon Oct 19 09:00:16 2015 EDT * Mon Oct 19 08:00:16 2015 CDT + * Mon Oct 19 03:00:16 2015 HST (no dst) * Mon Oct 19 13:00:16 2015 UTC */ testDiag("POSIX 1445259616"); - setTZ("EST", "EDT", 5*3600); - test_localtime(1445259616ul, 16, 0, 9, 19, 9, 2015, 1, 291, 1); - setTZ("CST", "CDT", 6*3600); - test_localtime(1445259616ul, 16, 0, 8, 19, 9, 2015, 1, 291, 1); - setTZ("UTC", NULL, 0); + setTZ("EST5EDT"); + test_localtime(1445259616ul, 16, 0, 9, 19, 9, 2015, 1, 291, 1); + test_gmtime (1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); + setTZ("CST6CDT"); + test_localtime(1445259616ul, 16, 0, 8, 19, 9, 2015, 1, 291, 1); + test_gmtime (1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); +#if defined(__rtems__) + setTZ("HST10HST10"); +#else + setTZ("HST10"); +#endif + test_localtime(1445259616ul, 16, 0, 3, 19, 9, 2015, 1, 291, 0); + test_gmtime (1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); + setTZ("UTC0"); test_localtime(1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); - test_gmtime(1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); + test_gmtime (1445259616ul, 16, 0, 13, 19, 9, 2015, 1, 291, 0); /* 1421244931 * Wed Jan 14 09:15:31 2015 EST * Wed Jan 14 08:15:31 2015 CST + * Wed Jan 14 04:15:31 2015 HST * Wed Jan 14 14:15:31 2015 UTC */ testDiag("POSIX 1421244931"); - setTZ("EST", "EDT", 5*3600); - test_localtime(1421244931ul, 31, 15, 9, 14, 0, 2015, 3, 13, 0); - setTZ("CST", "CDT", 6*3600); - test_localtime(1421244931ul, 31, 15, 8, 14, 0, 2015, 3, 13, 0); - setTZ("UTC", NULL, 0); + setTZ("EST5EDT"); + test_localtime(1421244931ul, 31, 15, 9, 14, 0, 2015, 3, 13, 0); + test_gmtime (1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); + setTZ("CST6CDT"); + test_localtime(1421244931ul, 31, 15, 8, 14, 0, 2015, 3, 13, 0); + test_gmtime (1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); +#if defined(__rtems__) + setTZ("HST10HST10"); +#else + setTZ("HST10"); +#endif + test_localtime(1421244931ul, 31, 15, 4, 14, 0, 2015, 3, 13, 0); + test_gmtime (1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); + setTZ("UTC0"); test_localtime(1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); - test_gmtime(1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); + test_gmtime (1421244931ul, 31, 15, 14, 14, 0, 2015, 3, 13, 0); return testDone(); } From 93597e20d53a3c523071eb8e5f7c339f3a7511cd Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 26 Apr 2016 09:59:22 -0400 Subject: [PATCH 2/7] add epicsTimeZoneTest to libCom test harness --- src/libCom/test/Makefile | 1 + src/libCom/test/epicsRunLibComTests.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 7e1b5a020..fadf89066 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -70,6 +70,7 @@ TESTS += epicsTimeTest TESTPROD_HOST += epicsTimeZoneTest epicsTimeZoneTest_SRCS += epicsTimeZoneTest.c +testHarness_SRCS += epicsTimeZoneTest.cpp TESTS += epicsTimeZoneTest TESTPROD_HOST += epicsThreadTest diff --git a/src/libCom/test/epicsRunLibComTests.c b/src/libCom/test/epicsRunLibComTests.c index aa62465ff..73a491ae6 100644 --- a/src/libCom/test/epicsRunLibComTests.c +++ b/src/libCom/test/epicsRunLibComTests.c @@ -34,6 +34,7 @@ int epicsThreadOnceTest(void); int epicsThreadPriorityTest(void); int epicsThreadPrivateTest(void); int epicsTimeTest(void); +int epicsTimeZoneTest(void); int macLibTest(void); int macEnvExpandTest(void); int ringPointerTest(void); @@ -89,6 +90,8 @@ void epicsRunLibComTests(void) runTest(epicsTimeTest); + runTest(epicsTimeZoneTest); + runTest(macLibTest); runTest(macEnvExpandTest); From fdda079b8f256de59e6478791e72dd61e1d68aab Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 27 Apr 2016 10:28:01 -0500 Subject: [PATCH 3/7] BSD's finite expects a double; make glibc 2.23 happy --- src/libCom/osi/os/posix/epicsMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libCom/osi/os/posix/epicsMath.h b/src/libCom/osi/os/posix/epicsMath.h index 4ed0fdc51..7cd0bb409 100644 --- a/src/libCom/osi/os/posix/epicsMath.h +++ b/src/libCom/osi/os/posix/epicsMath.h @@ -19,7 +19,7 @@ extern "C" { #ifdef isfinite # undef finite -# define finite(x) isfinite(x) +# define finite(x) isfinite((double)x) #endif epicsShareExtern float epicsNAN; From f0f89b4b1c8331988c86660952188250147d0383 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 27 Apr 2016 10:28:57 -0500 Subject: [PATCH 4/7] Fix file paths in comments --- src/libCom/osi/os/Darwin/osdFindSymbol.c | 2 +- src/libCom/osi/os/Linux/osdFindSymbol.c | 2 +- src/libCom/osi/os/solaris/osdFindSymbol.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libCom/osi/os/Darwin/osdFindSymbol.c b/src/libCom/osi/os/Darwin/osdFindSymbol.c index 967c220cd..224c76279 100644 --- a/src/libCom/osi/os/Darwin/osdFindSymbol.c +++ b/src/libCom/osi/os/Darwin/osdFindSymbol.c @@ -4,7 +4,7 @@ * EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ -/* osi/os/default/epicsFindSymbol.c */ +/* osi/os/Darwin/epicsFindSymbol.c */ #include diff --git a/src/libCom/osi/os/Linux/osdFindSymbol.c b/src/libCom/osi/os/Linux/osdFindSymbol.c index 967c220cd..443379dff 100644 --- a/src/libCom/osi/os/Linux/osdFindSymbol.c +++ b/src/libCom/osi/os/Linux/osdFindSymbol.c @@ -4,7 +4,7 @@ * EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ -/* osi/os/default/epicsFindSymbol.c */ +/* osi/os/Linux/epicsFindSymbol.c */ #include diff --git a/src/libCom/osi/os/solaris/osdFindSymbol.c b/src/libCom/osi/os/solaris/osdFindSymbol.c index 967c220cd..0fad63a42 100644 --- a/src/libCom/osi/os/solaris/osdFindSymbol.c +++ b/src/libCom/osi/os/solaris/osdFindSymbol.c @@ -4,7 +4,7 @@ * EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ -/* osi/os/default/epicsFindSymbol.c */ +/* osi/os/solaris/epicsFindSymbol.c */ #include From 2226f3acb9f4e6b153677956008932bda31b0b53 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 27 Apr 2016 12:45:18 -0400 Subject: [PATCH 5/7] libCom/test: don't include epicsTimeZoneTest for vxWorks --- src/libCom/test/Makefile | 2 ++ src/libCom/test/epicsRunLibComTests.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index fadf89066..a0d47270b 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -70,7 +70,9 @@ TESTS += epicsTimeTest TESTPROD_HOST += epicsTimeZoneTest epicsTimeZoneTest_SRCS += epicsTimeZoneTest.c +ifeq ($(OS_CLASS),RTEMS) testHarness_SRCS += epicsTimeZoneTest.cpp +endif TESTS += epicsTimeZoneTest TESTPROD_HOST += epicsThreadTest diff --git a/src/libCom/test/epicsRunLibComTests.c b/src/libCom/test/epicsRunLibComTests.c index 73a491ae6..3b81b15cf 100644 --- a/src/libCom/test/epicsRunLibComTests.c +++ b/src/libCom/test/epicsRunLibComTests.c @@ -34,7 +34,9 @@ int epicsThreadOnceTest(void); int epicsThreadPriorityTest(void); int epicsThreadPrivateTest(void); int epicsTimeTest(void); +#ifdef __rtems__ int epicsTimeZoneTest(void); +#endif int macLibTest(void); int macEnvExpandTest(void); int ringPointerTest(void); @@ -90,7 +92,9 @@ void epicsRunLibComTests(void) runTest(epicsTimeTest); +#ifdef __rtems__ runTest(epicsTimeZoneTest); +#endif runTest(macLibTest); From 24ddcd2524ec19c5e1f50c6a9e04c9b5c1ba74ac Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 27 Apr 2016 12:09:10 -0500 Subject: [PATCH 6/7] Fix epicsTimeZoneTest.cpp => .c and remove conditional --- src/libCom/test/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index a0d47270b..7f5994c0d 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -70,9 +70,7 @@ TESTS += epicsTimeTest TESTPROD_HOST += epicsTimeZoneTest epicsTimeZoneTest_SRCS += epicsTimeZoneTest.c -ifeq ($(OS_CLASS),RTEMS) -testHarness_SRCS += epicsTimeZoneTest.cpp -endif +rtemsTestHarness_SRCS += epicsTimeZoneTest.c TESTS += epicsTimeZoneTest TESTPROD_HOST += epicsThreadTest From 054a234c70d34c4d384af5704d481e2fe36c1ff2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 28 Apr 2016 13:27:47 -0500 Subject: [PATCH 7/7] Parentheses in macro --- src/libCom/osi/os/posix/epicsMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libCom/osi/os/posix/epicsMath.h b/src/libCom/osi/os/posix/epicsMath.h index 7cd0bb409..4e558676c 100644 --- a/src/libCom/osi/os/posix/epicsMath.h +++ b/src/libCom/osi/os/posix/epicsMath.h @@ -19,7 +19,7 @@ extern "C" { #ifdef isfinite # undef finite -# define finite(x) isfinite((double)x) +# define finite(x) isfinite((double)(x)) #endif epicsShareExtern float epicsNAN;