|
| 1 | +import subprocess |
| 2 | +import sys |
| 3 | +import os |
| 4 | +from pyexpect import expect |
| 5 | + |
| 6 | +wrapper = os.getenv("MESON_EXE_WRAPPER") |
| 7 | +wrapper = [x for x in (wrapper,) if x] |
| 8 | + |
| 9 | +def check_tz(tz, expected): |
| 10 | + output = subprocess.check_output( |
| 11 | + wrapper + [sys.argv[1]], |
| 12 | + stderr=subprocess.STDOUT, |
| 13 | + env={"TZ": tz}, |
| 14 | + ) |
| 15 | + |
| 16 | + expect(expected).to_equal(output) |
| 17 | + |
| 18 | +check_tz("UTC0", b"UTC UTC 0 0\n") |
| 19 | +check_tz("GMT0", b"GMT GMT 0 0\n") |
| 20 | +check_tz(":UTC0", b"UTC UTC 0 0\n") |
| 21 | +check_tz("EST+5", b"EST EST 18000 0\n") |
| 22 | +check_tz("EET-2", b"EET EET -7200 0\n") |
| 23 | +check_tz("<+03>-03", b"+03 +03 -10800 0\n") |
| 24 | +check_tz("NPT-05:45", b"NPT NPT -20700 0\n") |
| 25 | +check_tz("NST+03:30NDT", b"NST NDT 12600 1\n") |
| 26 | +check_tz("NZST-12NZDT-13", b"NZST NZDT -43200 1\n") |
| 27 | +check_tz("<PST-8>+8<PDT-7>+7,M3.2.0,M11.1.0", b"PST-8 PDT-7 28800 1\n") |
| 28 | + |
| 29 | +# These depend on tzdata, which may or may not exist. |
| 30 | +# Useful to check every now and then, but these also present subtle differences |
| 31 | +# between the host libc and mlibc, so we can't expect these to always hold up. |
| 32 | +# E.g. glibc will set `tzname` from the TZ environment variable even if it |
| 33 | +# cannot find the tzinfo file, however mlibc will use the name of the timezone |
| 34 | +# as read from the tzinfo file or the timezone that it defaults to (UTC). |
| 35 | + |
| 36 | +# Would be b"Universal 0 0\n" on glibc. |
| 37 | +# check_tz("", b"UTC UTC 0 0\n") |
| 38 | + |
| 39 | +# Would be b"UTC 0 0\n" on glibc. |
| 40 | +# check_tz("UTC", b"UTC UTC 0 0\n") |
| 41 | +# check_tz(":UTC", b"UTC UTC 0 0\n") |
| 42 | + |
| 43 | +# Would be b"Universal 0 0\n" on glibc. |
| 44 | +# check_tz("Universal", b"UTC UTC 0 0\n") |
| 45 | +# check_tz(":Universal", b"UTC UTC 0 0\n") |
| 46 | + |
| 47 | +# Would be b"ATimeZoneThatShouldHopefullyNeverBeInTzdata 0 0\n" on glibc. |
| 48 | +# check_tz("ATimeZoneThatShouldHopefullyNeverBeInTzdata", b"UTC UTC 0 0\n") |
| 49 | +# check_tz(":ATimeZoneThatShouldHopefullyNeverBeInTzdata", b"UTC UTC 0 0\n") |
0 commit comments