diff options
Diffstat (limited to 'bench/compat.sh')
| -rwxr-xr-x | bench/compat.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/bench/compat.sh b/bench/compat.sh new file mode 100755 index 0000000..7575fd1 --- /dev/null +++ b/bench/compat.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# How far is zash from the shell this host calls sh? +# +# sh bench/compat.sh ./zash [/bin/sh] +# +# Every tests/posix script is run under both shells, each in its own empty +# directory, and the scripts whose output or status differ are listed with +# the first difference. +# +# This is not a pass/fail test. The suite's .exp files come from a +# reference shell (tests/regen.sh), and on z/OS /bin/sh is IBM's ksh lineage +# shell with behaviour of its own. What the count says is how close a +# script that names #!/bin/sh gets to its meaning here, which is the +# compatibility zash aims for; a script that zash runs and the host's sh +# does not is either a zash extension or a zash bug, and the diff says +# which one to look at. +# +# The scripts need the same PATH the suite does on z/OS (build/zos-tools +# for sleep); see tests/run.sh. +here=$(cd "$(dirname "$0")" && pwd) +tests=$here/../tests +zash=${1:?usage: compat.sh zash-shell [other-shell]} +other=${2:-/bin/sh} +case $zash in /*) ;; *) zash=$PWD/$zash ;; esac +# Some posix scripts start a shell of their own through $TSH; give them the +# one under test, as tests/run.sh does. +TSH=$zash +export TSH +work=${TMPDIR:-/tmp}/zash-compat.$$ +mkdir -p "$work" || exit 1 +trap 'rm -rf "$work"' EXIT + +run() { # shell script dir out + mkdir -p "$3" || exit 1 + ( cd "$3" && "$1" "$2" ) >"$work/$4" 2>&1 + echo "[status $?]" >>"$work/$4" +} + +same=0 +differ=0 +for t in "$tests"/posix/*.sh; do + name=$(basename "$t" .sh) + run "$zash" "$t" "$work/$name/zash" z.out + run "$other" "$t" "$work/$name/other" o.out + if cmp -s "$work/z.out" "$work/o.out"; then + same=$((same + 1)) + continue + fi + differ=$((differ + 1)) + echo "=== $name" + diff "$work/o.out" "$work/z.out" | sed -n '1,10p' +done + +echo "$same agree, $differ differ from $other" |
