]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-time-util.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / test / test-time-util.c
index e639ded48cab20a05a5d33c4ad61742b4bd964cf..5393deff702f56c691cf0405283c5c4dc3d97765 100644 (file)
@@ -3,19 +3,6 @@
   This file is part of systemd.
 
   Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include "random-util.h"
@@ -383,6 +370,22 @@ static void test_usec_shift_clock(void) {
         }
 }
 
+static void test_in_utc_timezone(void) {
+        assert_se(setenv("TZ", ":UTC", 1) >= 0);
+        assert_se(in_utc_timezone());
+        assert_se(streq(tzname[0], "UTC"));
+        assert_se(streq(tzname[1], "UTC"));
+        assert_se(timezone == 0);
+        assert_se(daylight == 0);
+
+        assert_se(setenv("TZ", "Europe/Berlin", 1) >= 0);
+        assert_se(!in_utc_timezone());
+        assert_se(streq(tzname[0], "CET"));
+        assert_se(streq(tzname[1], "CEST"));
+
+        assert_se(unsetenv("TZ") >= 0);
+}
+
 int main(int argc, char *argv[]) {
         uintmax_t x;
 
@@ -409,6 +412,7 @@ int main(int argc, char *argv[]) {
         test_format_timestamp_utc();
         test_dual_timestamp_deserialize();
         test_usec_shift_clock();
+        test_in_utc_timezone();
 
         /* Ensure time_t is signed */
         assert_cc((time_t) -1 < (time_t) 1);