From e18a6a28db78a45773c17f0828d95452abfc8c0f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 17 Jul 2020 15:01:17 +0100 Subject: [PATCH 1/2] tests: Incorporate bug base into g_test_bug() calls in gdatetime tests This will allow the following commit to refer to GitLab in its `g_test_bug()` call. Signed-off-by: Philip Withnall --- glib/tests/gdatetime.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c index c88b411ff..5d453cef7 100644 --- a/glib/tests/gdatetime.c +++ b/glib/tests/gdatetime.c @@ -160,7 +160,7 @@ test_GDateTime_new_from_unix_overflow (void) { GDateTime *dt; - g_test_bug ("782089"); + g_test_bug ("http://bugzilla.gnome.org/782089"); dt = g_date_time_new_from_unix_utc (G_MAXINT64); g_assert_null (dt); @@ -174,7 +174,7 @@ test_GDateTime_invalid (void) { GDateTime *dt; - g_test_bug ("702674"); + g_test_bug ("http://bugzilla.gnome.org/702674"); dt = g_date_time_new_utc (2013, -2147483647, 31, 17, 15, 48); g_assert (dt == NULL); @@ -435,7 +435,7 @@ test_GDateTime_new_from_timeval_overflow (void) GDateTime *dt; GTimeVal tv; - g_test_bug ("782089"); + g_test_bug ("http://bugzilla.gnome.org/782089"); tv.tv_sec = find_maximum_supported_tv_sec (); tv.tv_usec = G_USEC_PER_SEC - 1; @@ -1772,7 +1772,7 @@ test_month_names (void) { gchar *oldlocale; - g_test_bug ("749206"); + g_test_bug ("http://bugzilla.gnome.org/749206"); /* If running uninstalled (G_TEST_BUILDDIR is set), skip this test, since we * need the translations to be installed. We can’t mess around with @@ -2114,7 +2114,7 @@ test_z (void) GDateTime *dt; gchar *p; - g_test_bug ("642935"); + g_test_bug ("http://bugzilla.gnome.org/642935"); tz = g_time_zone_new ("-08:00"); dt = g_date_time_new (tz, 1, 1, 1, 0, 0, 0); @@ -2583,7 +2583,7 @@ test_GDateTime_floating_point (void) GDateTime *dt; GTimeZone *tz; - g_test_bug ("697715"); + g_test_bug ("http://bugzilla.gnome.org/697715"); tz = g_time_zone_new ("-03:00"); g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "-03:00"); @@ -2701,7 +2701,6 @@ main (gint argc, g_unsetenv ("LANGUAGE"); g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/"); /* GDateTime Tests */ bind_textdomain_codeset ("glib20", "UTF-8"); From 98a7d6e389e66befeb9408b7b2b9e39c01e0d320 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 17 Jul 2020 15:02:01 +0100 Subject: [PATCH 2/2] tests: Add tests for RFC 8536 v3 parsing of time zones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds really basic validation that `GTimeZone` can successfully parse a ‘slim’ format timezone file. Signed-off-by: Philip Withnall Helps: #2129 --- glib/tests/gdatetime.c | 33 +++++++++++++++++++++++++++ glib/tests/meson.build | 1 + glib/tests/time-zones/Amsterdam-fat | Bin 0 -> 2910 bytes glib/tests/time-zones/Amsterdam-slim | Bin 0 -> 1071 bytes 4 files changed, 34 insertions(+) create mode 100644 glib/tests/time-zones/Amsterdam-fat create mode 100644 glib/tests/time-zones/Amsterdam-slim diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c index 5d453cef7..fb207be70 100644 --- a/glib/tests/gdatetime.c +++ b/glib/tests/gdatetime.c @@ -2692,6 +2692,38 @@ test_new_offset (void) } } +static void +test_time_zone_parse_rfc8536 (void) +{ + const gchar *test_files[] = + { + /* Generated with `zic -b slim`; see + * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1533#note_842235 */ + "Amsterdam-slim", + /* Generated with `zic -b fat` */ + "Amsterdam-fat", + }; + gsize i; + + g_test_summary ("Test parsing time zone files in RFC 8536 version 3 format"); + g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2129"); + + for (i = 0; i < G_N_ELEMENTS (test_files); i++) + { + gchar *path = NULL; + GTimeZone *tz = NULL; + + path = g_test_build_filename (G_TEST_DIST, "time-zones", test_files[i], NULL); + g_assert_true (g_path_is_absolute (path)); + tz = g_time_zone_new (path); + g_assert_nonnull (tz); + /* UTC will be loaded as a fallback if parsing fails */ + g_assert_cmpstr (g_time_zone_get_identifier (tz), !=, "UTC"); + g_time_zone_unref (tz); + g_free (path); + } +} + gint main (gint argc, gchar *argv[]) @@ -2761,6 +2793,7 @@ main (gint argc, g_test_add_func ("/GTimeZone/floating-point", test_GDateTime_floating_point); g_test_add_func ("/GTimeZone/identifier", test_identifier); g_test_add_func ("/GTimeZone/new-offset", test_new_offset); + g_test_add_func ("/GTimeZone/parse-rfc8536", test_time_zone_parse_rfc8536); return g_test_run (); } diff --git a/glib/tests/meson.build b/glib/tests/meson.build index 8da477d19..6eb23e8a7 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -189,6 +189,7 @@ if installed_tests_enabled ) install_subdir('bookmarks', install_dir : installed_tests_execdir) install_subdir('markups', install_dir : installed_tests_execdir) + install_subdir('time-zones', install_dir : installed_tests_execdir) endif # Not entirely random of course, but at least it changes over time diff --git a/glib/tests/time-zones/Amsterdam-fat b/glib/tests/time-zones/Amsterdam-fat new file mode 100644 index 0000000000000000000000000000000000000000..c3ff07b436aedf662eae60f50668f5abcdb172b6 GIT binary patch literal 2910 zcmeIzdrVe!9LMqJQAndBe#Hb*yhVf;#0OAPlavt61VVixQt*<9T4adCur#`;wffC{ zb1ZXe-VoFwqTy|T_ghoRYLuF;O;>g?axai>Yt8jftv~vwb2z`(+2LP!fBX|> z<;Q#ea<#Kxc)059!+XzH?Xkj%y|SYD^PH7ucRQ;p_BkI^MLDaNg*t0A*{m(O>8vY^ zH0!g@ITe|KW!8z)^do7${5n_4C~n=dai)zKH7>SHs^mLKz-nyS%e zYtwR5`(|IWZCf|9z3?&T!=>Y#y39V#j=77>PM_oK^6znWw{LOw3@chtDzf zXRerrTN|9l-A!iixie~P_cL0N@Ir`))D ztY^{H<0H0bp1eFpPHhU)rgbUu@zMcu`t>OJq$pHA%^0rjDyC`hJDsKd!c>*wMD36l zts(w!?U+77?oIebJ4ODWp&id_SnE?7c5SbQU)rkoeYQqBA9`22G&D*?b&Yggxmvmz zmG1LjlO6>{(lck8+@I!`$f2q7Kun@UMMTSkPPjw|rfBr_0ov>9DDB-Gs(p^M(Y|#z zHKyV_?N@$IV;7##{>2UI%iE%Hxo0K5s7?}+>Se&V_hew#RgxHADv7ttWKfrK9du!; z4F0u5hcu?h!(V3W(8|f0R6j%?S)8oHRz&FV{76k+I9MJX8K^0FU1UVmWlc@FEh7Uz z(ovCL$*7iZWOVBTGP>!wJbr1tjH%fyX(#t-`Vu1<)ob;M*|R0nyrE;CdRxa8OxN)b z6{tULls*}jp;@Py}>Fd2@!p@&{Vsnt>tmz=Rbys9k*)^G5-Xv2d zH_Oxo-|I8OcFDBdlbY9kxlB*0(fqbMbVgUz8Q(6`nYW8{*714z>;=C*w{fBt9GxT2 zzm=r3E62+VGrMcy;(;<}>`*Dn50klZ-K046mb}=(BPIPiY01@#QW|_iOHUt`c`ax4 zrP@k)xv5^~FF&XYYF6nh^D4A#Ntw3twrU;lH}5uqciB6r?cMHukMm#M9#25I{WtW4 zRCoj2_qKPw2h@5T`(?j3-GPGaQtSkRv}{xkbt<_h#(DfIN5YT99~l5-1dt&>#sC=vWE7BLaJA!r41}v431ldcu|Ng`84YAOknunU z1Q`)zNRTl>1_c=vWLRA7xF7@LYDWec8f0vc!9hj`86ISOkO4wQ2pJ+|jF3S>MhO`v zWSo$Ja7j~$Y3F(g$x%mUdVtUBZdqaGG@r2A)|&28!~Rlz`5FyLx#@PjvX?1 t$mk)%hm0RGfXE2q|3eu3?}jkQj%B|%)-onNA$DM_FD5ZkT3uM literal 0 HcmV?d00001 diff --git a/glib/tests/time-zones/Amsterdam-slim b/glib/tests/time-zones/Amsterdam-slim new file mode 100644 index 0000000000000000000000000000000000000000..4a6fa1d4945d6646652e2972ee8b632ca64c00cc GIT binary patch literal 1071 zcmb8s?MqWp90%|_-CD>^Z?opIWv;buxjFBgjb8LZnS&xHt1c4eqEL*$7i*31MG%G2 zi}qp-p(0Du*)pcihib#khtv$rWrd-`S4l`@7DQydsdK*j1FUm6=X1X2ocrT)uULJq zzL;6JNyrU4XcO0eR{_FC2aGR zdFlCsi)+a3E-i9LRT4SikRf+kV#p75Cy|5v7<_bU33kalQm$6BwBF<8Ysew~19E8U zEOPgkdgPwqVdUP#9T>i@hkbo{u-|ovrF91U$Kar&06w{ps{2%6k)MfC7|B|N(b7gQ zeJ=WS7I{c@9(ibf1;&1LVm}^9AP*QE2d(b5X@ygs<|(iNEB;D(x-TDYr1gxZ5PxZ7ZXIyDdXuqw#QtUg+w z|4{<>e$>Hzb4pk+DTn&OHE0NYf`!dVXl$B>MV=TG>bjxHxxl4K{=G}nY2P6Gug);i zX8Q7qfJBP*Mly#Pmh6m56bzHeF)H%u@+ImDyU0`?7nw4mUJ!}}GMmV3wTWbqgAB4N VG|{EOZZ_^W3I@ALpca`k{sL)%tV93+ literal 0 HcmV?d00001