summaryrefslogtreecommitdiff
path: root/regress/bin/ksh/th
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2022-10-16 08:49:04 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2022-10-16 08:49:04 +0000
commit25d437c54184a2569af6ad592656227ff507a943 (patch)
tree7b9e8cb3dd4df56d01de202f3d29ea2832900e76 /regress/bin/ksh/th
parent20fff826c8f56146ea25ff5278b6b16b140d0503 (diff)
Always pass the test program as PROG env var, fix synopsis
The ./th perl script always runs -p prog (KSH in Makefile) as the shell, but cannot signal it other than the optional SIGKILL after `time-limit'. Implementing time-related signal handling in ./th seems overkill, so always pass the program as PROG in the environment so it can wrap itself, e.g. description: simluate interrupting a script stdin: timeout --signal SIGINT --preserve-status -- 1s $PROG -c ' actual test script getting ^C after one second... ' Avoiding hard-coded programs in tests with PROG allows testing different shells through `make KSH=/path/to/sh' without changing or adding shell specific tests. While here, make -p and -s as mandatory in usage as ./th `die's if they're not passed (allowing to always just pass -p's argument as PROG).
Diffstat (limited to 'regress/bin/ksh/th')
-rw-r--r--regress/bin/ksh/th11
1 files changed, 7 insertions, 4 deletions
diff --git a/regress/bin/ksh/th b/regress/bin/ksh/th
index 682503d5345..2185007cc0d 100644
--- a/regress/bin/ksh/th
+++ b/regress/bin/ksh/th
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $OpenBSD: th,v 1.3 2021/09/02 07:14:15 jasper Exp $
+# $OpenBSD: th,v 1.4 2022/10/16 08:49:03 kn Exp $
#
@@ -56,9 +56,11 @@
# missing, NAME is removed from the
# environment. Programs are run with
# the following minimal environment:
-# USER, LOGNAME, HOME, PATH, SHELL
+# USER, LOGNAME, HOME, PATH, SHELL,
+# PROG
# (values from the current environment
# takes higher precedence).
+# PROG always contains the -p argument.
# file-setup mps Used to create files, directories
# and symlinks. First word is either
# file, dir or symlink; second word is
@@ -139,7 +141,7 @@ $os = defined $^O ? $^O : 'unknown';
($prog = $0) =~ s#.*/##;
$Usage = <<EOF ;
-Usage: $prog [-s test-set] [-C category] [-p prog] [-v] [-e e=v] test-name ...
+Usage: $prog -p prog -s test-set [-v] [-C category] [-e e=v] test-name ...
-p p Use p as the program to test
-C c Specify the comma separated list of categories the program
belongs to (see category field).
@@ -233,7 +235,7 @@ $all_tests = @ARGV == 0;
# Set up a very minimal environment
%new_env = ();
-foreach $env (('USER', 'LOGNAME', 'HOME', 'PATH', 'SHELL')) {
+foreach $env (('USER', 'LOGNAME', 'HOME', 'PATH', 'SHELL', 'PROG')) {
$new_env{$env} = $ENV{$env} if defined $ENV{$env};
}
if (defined $opt_e) {
@@ -470,6 +472,7 @@ run_test
if (!$pid) {
@SIG{@trap_sigs} = ('DEFAULT') x @trap_sigs;
$SIG{'ALRM'} = 'DEFAULT';
+ $ENV{'PROG'} = $test_prog;
if (defined $test{'env-setup'}) {
local($var, $val, $i);