summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <[email protected]>2023-03-20 20:17:34 +0100
committerEdward Welbourne <[email protected]>2023-04-14 15:22:27 +0200
commit462d3547f76ea21cd437a23b76991d4d1accfa50 (patch)
tree4dcad2c4e618dcc2ac40a5636236d5baf759d413
parent9f11574a7d2f8a259ea4b61f5dd83366532e5bad (diff)
Add a manual test helper script, foreachzone
This makes it possible, on a system with /usr/{lib,share}/zoneinfo/, to systematically run a command with TZ set to each system-supported zone. For example, it can be used to verify that a corelib/time/ test passes regardless of the valid setting of TZ. Change-Id: I6ea9a64d8bcb745aea80ab9ae431602d3e3265a1 Reviewed-by: Thiago Macieira <[email protected]>
-rwxr-xr-xtests/manual/corelib/time/foreachzone30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/manual/corelib/time/foreachzone b/tests/manual/corelib/time/foreachzone
new file mode 100755
index 00000000000..480679885a9
--- /dev/null
+++ b/tests/manual/corelib/time/foreachzone
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Usage: foreachzone command [args...]
+#
+# The command is run with eval, so can include embedded shell
+# metacharacters such as | and ||. It is run in a sub-shell, so can
+# change environment or cd to a different directory without
+# complicating later runs of the same command.
+#
+# It is run repeatedly, with the TZ environment variable set to each
+# timezone name in turn, excluding the copies of zoneinfo/ under its
+# posix/ and right/ sub-dirs. Symbolic links are included (as long as
+# they point to valid zone data).
+#
+# For example, in the top level of a build tree,
+# foreachzone ninja tst_qdate_check
+# will run all the QDate tests in every time zone (this may take some
+# time).
+
+DIR=/usr/share/zoneinfo
+[ -d "$DIR" ] || DIR=/usr/lib/zoneinfo
+
+find $DIR -type d \( -name posix -o -name right \) -prune -o \( -type f -o -type l \) -print \
+ | while read f
+do
+ # To filter out symlinks in zoneinfo/ itself, uncomment this line:
+ # echo "$f" | grep -wq 'zoneinfo/.*/' || [ ! -h "$f" ] || continue
+ # To skip all symlinks, omit the -L here:
+ file -L "$f" | grep -wq 'timezone data .*, version' || continue
+ ( export TZ=${f#*/zoneinfo/}; eval "$@" )
+done