From da19aac034a396f6c6acbf84532fabc995190586 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 26 Apr 2019 10:44:02 +0200 Subject: [PATCH] add precautions for old glibc The glibc 2.17 currently being used on the Intranator lacks two commits from 2015 which implement correct handling of ISO8601 timezone specifications. This causes timestamp parsing to fail where the `Z' suffix is used to indicate UTC, so comment out the respective tests. --- test/test_timefunc.cpp | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/test/test_timefunc.cpp b/test/test_timefunc.cpp index 5fc58e5..6192b78 100644 --- a/test/test_timefunc.cpp +++ b/test/test_timefunc.cpp @@ -23,6 +23,16 @@ on this file might be covered by the GNU General Public License. * @copyright Copyright © 2001-2008 by Intra2net AG * */ +#include +#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 23) +/* + * Ancient glibc (pre 2015) has a defective implementation of strptime(3) + * that doesn’t handle the ‘Z’ modifier of ISO8601 to indicate UTC. It also + * parses fractional timezones only partially so e. g. “+11:11” is treated + * as “+1100”. + */ +# define GLIBC_STRPTIME_LACKS_Z +#endif #define BOOST_TEST_DYN_LINK #include @@ -1189,6 +1199,7 @@ BOOST_AUTO_TEST_SUITE(Clock) # endif } +# ifndef GLIBC_STRPTIME_LACKS_Z BOOST_AUTO_TEST_CASE(FromString_iso8601_Z) { const std::string in1 ("2019-04-25T13:41:47+0000"); @@ -1205,6 +1216,7 @@ BOOST_AUTO_TEST_SUITE(Clock) BOOST_CHECK_EQUAL(*t1->format_iso8601 (), *t2->format_iso8601 ()); BOOST_CHECK_EQUAL(*t2->format_iso8601 (), in1); } +# endif BOOST_AUTO_TEST_CASE(FromString_iso8601_partial) { @@ -1240,14 +1252,22 @@ BOOST_AUTO_TEST_SUITE(Clock) boost::optional t2 = I2n::clock::time_of_iso8601 (in2, true, true, true); boost::optional t3 = I2n::clock::time_of_iso8601 (in3, true, true, true); +# ifdef GLIBC_STRPTIME_LACKS_Z + BOOST_CHECK(!t1); +# else BOOST_CHECK(t1); +# endif BOOST_CHECK(t2); BOOST_CHECK(t3); +# ifndef GLIBC_STRPTIME_LACKS_Z BOOST_CHECK_EQUAL(*t1->format_iso8601 (), "2019-04-25T13:41:47+0000"); BOOST_CHECK_EQUAL(t1->get_sec (), 1556199707); +# endif BOOST_CHECK_EQUAL(*t2->format_iso8601 (), "2019-04-25T15:41:47+0000"); +# ifndef GLIBC_STRPTIME_LACKS_Z BOOST_CHECK_EQUAL(t2->get_sec (), t1->get_sec () + 2 * 60 * 60); +# endif BOOST_CHECK_EQUAL(*t2, *t3); BOOST_CHECK_EQUAL(*t3->format_iso8601 (), "2019-04-25T15:41:47+0000"); } -- 1.7.1