elf: Add comments on how LD_AUDIT and LD_PRELOAD handle __libc_enable_secure
[glibc.git] / timezone / tst-bz29951.c
blobabd334683bc7218097a6b3fba73c98e67439ca7f
1 /* Check that daylight is set if the last DST transition did not change offset.
2 Copyright (C) 2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <stdlib.h>
21 #include <support/check.h>
22 #include <time.h>
24 /* Set the specified time zone with error checking. */
25 static void
26 set_timezone (const char *name)
28 TEST_VERIFY (setenv ("TZ", name, 1) == 0);
29 errno = 0;
30 tzset ();
31 TEST_COMPARE (errno, 0);
34 static int
35 do_test (void)
37 /* Test zone based on tz-2022g version of Africa/Tripoli. The last
38 DST transition coincided with a change in the standard time
39 offset, effectively making it a no-op.
41 Africa/Tripoli Thu Oct 24 23:59:59 2013 UT
42 = Fri Oct 25 01:59:59 2013 CEST isdst=1 gmtoff=7200
43 Africa/Tripoli Fri Oct 25 00:00:00 2013 UT
44 = Fri Oct 25 02:00:00 2013 EET isdst=0 gmtoff=7200
46 set_timezone ("XT6");
47 TEST_VERIFY (daylight != 0);
48 TEST_COMPARE (timezone, -7200);
50 /* Check that localtime re-initializes the two variables. */
51 daylight = timezone = 17;
52 time_t t = 844034401;
53 struct tm *tm = localtime (&t);
54 TEST_VERIFY (daylight != 0);
55 TEST_COMPARE (timezone, -7200);
56 TEST_COMPARE (tm->tm_year, 96);
57 TEST_COMPARE (tm->tm_mon, 8);
58 TEST_COMPARE (tm->tm_mday, 29);
59 TEST_COMPARE (tm->tm_hour, 23);
60 TEST_COMPARE (tm->tm_min, 0);
61 TEST_COMPARE (tm->tm_sec, 1);
62 TEST_COMPARE (tm->tm_gmtoff, 3600);
63 TEST_COMPARE (tm->tm_isdst, 0);
65 return 0;
68 #include <support/test-driver.c>