tst-bz28707.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2021-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include <errno.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <support/check.h>
  18. #include <time.h>
  19. /* Test that we can use a truncated timezone-file, where the time-type
  20. at index 0 is not indexed by the transition-types array (and the
  21. transition-types array does not contain at least both one DST and one
  22. normal time members). */
  23. static int
  24. do_test (void)
  25. {
  26. if (setenv ("TZ", "XT5", 1) != 0)
  27. FAIL_EXIT1 ("setenv: %m");
  28. errno = 0;
  29. tzset ();
  30. if (errno != 0)
  31. /* This is not a test failure because checking errno this way is
  32. not a documented way for determining tzset success. We do this
  33. only to gather additional diagnostics. */
  34. printf ("warning: tzset set errno to %d (%m)", errno);
  35. /* Sanity-check that we got the right abbreviation for DST. For
  36. normal time, we're likely to get "-00" (the "unspecified" marker),
  37. even though the POSIX timezone string says "-04". Let's not test
  38. that. */
  39. TEST_COMPARE_STRING (tzname[1], "-03");
  40. return 0;
  41. }
  42. #include <support/test-driver.c>