|
| 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 0 0\n") |
| 19 | +check_tz("GMT0", b"GMT 0 0\n") |
| 20 | +check_tz(":UTC0", b"UTC 0 0\n") |
| 21 | +check_tz("EST+5", b"EST 18000 0\n") |
| 22 | +check_tz("EET-2", b"EET -7200 0\n") |
| 23 | +check_tz("<+03>-03", b"+03 -10800 0\n") |
| 24 | +check_tz("NZST-12", b"NZST -43200 0\n") |
| 25 | +check_tz("NST+03:40", b"NST 13200 0\n") |
| 26 | +check_tz("NPT-05:45", b"NPT -20700 0\n") |
| 27 | + |
| 28 | +# These depend on tzdata, which may or may not exist. |
| 29 | +# Useful to check every now and then, but these also present subtle differences |
| 30 | +# between the host libc and mlibc, so we can't expect these to always hold up. |
| 31 | +# E.g. glibc will set `tzname` from the TZ environment variable even if it |
| 32 | +# cannot find the tzinfo file, however mlibc will use the name of the timezone |
| 33 | +# as read from the tzinfo file or the timezone that it defaults to (UTC). |
| 34 | + |
| 35 | +# Would be b"Universal 0 0\n" on glibc. |
| 36 | +# check_tz("", b"UTC 0 0\n") |
| 37 | + |
| 38 | +# check_tz("UTC", b"UTC 0 0\n") |
| 39 | +# check_tz(":UTC", b"UTC 0 0\n") |
| 40 | + |
| 41 | +# Would be b"Universal 0 0\n" on glibc. |
| 42 | +# check_tz("Universal", b"UTC 0 0\n") |
| 43 | +# check_tz(":Universal", b"UTC 0 0\n") |
| 44 | + |
| 45 | +# Would be b"ATimeZoneThatShouldHopefullyNeverBeInTzdata 0 0\n" on glibc. |
| 46 | +# check_tz("ATimeZoneThatShouldHopefullyNeverBeInTzdata", b"UTC 0 0\n") |
| 47 | +# check_tz(":ATimeZoneThatShouldHopefullyNeverBeInTzdata", b"UTC 0 0\n") |
0 commit comments