]> granicus.if.org Git - strace/commitdiff
tests/gen_tests.sh: enable passing arguments to sourced tests
authorEugene Syromyatnikov <evgsyr@gmail.com>
Thu, 25 Jan 2018 09:33:55 +0000 (10:33 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 25 Jan 2018 07:18:38 +0000 (07:18 +0000)
* tests/gen_tests.sh: Read first argument separately, put it in $arg0,
and the rest of the arguments in $args.
(case "$arg0" in) <+*)>: Set command line to $args and source $arg0.

tests/gen_tests.sh

index b06243658c2950ab963dcb12a14f70f52ce1ffd6..fd497edb742c640707951aba196ab4b24b6ba8d4 100755 (executable)
@@ -54,7 +54,7 @@ fi
 
 names=
 
-while read -r name args; do {
+while read -r name arg0 args; do {
        [ -n "${name###*}" ] || continue
        if [ -z "$match" ]; then
                names="$names $name"
@@ -65,13 +65,14 @@ while read -r name args; do {
 
        hdr="\
 #!/bin/sh -efu
-# Generated by $0 from $input ($name $args); do not edit."
+# Generated by $0 from $input ($name $arg0 $args); do not edit."
 
-       case "$args" in
+       case "$arg0" in
                +*)
                cat <<-EOF
                $hdr
-               . "\${srcdir=.}/${args#+}"
+               set -- $args
+               . "\${srcdir=.}/${arg0#+}"
                EOF
                ;;
 
@@ -79,7 +80,7 @@ while read -r name args; do {
                cat <<-EOF
                $hdr
                . "\${srcdir=.}/init.sh"
-               run_strace_match_diff $args
+               run_strace_match_diff $arg0 $args
                EOF
                ;;
 
@@ -87,7 +88,7 @@ while read -r name args; do {
                cat <<-EOF
                $hdr
                . "\${srcdir=.}/init.sh"
-               $args
+               $arg0 $args
                EOF
                ;;
        esac > "$output"