1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.ia-c-error
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
# license: GNU General Public License, version 3
# description: test using run normally but disable it for some functions
# see also: example.ia-c-error
# The following tests are included:
# (1) Run script with -c in sub
# (2) check logfile
# (3) Run script with -c in sub and main
# (5) check logfile
# (6) Run script with -c in main
# (7) check logfile
# (8) Run script with -c and ia_ignore in sub and main
# (9) Run script with -c and ia_stdout in sub and main
. ./tstlib
shell=""
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" ] && set -- "$@" -s "$shell"
[ "$shell" = "posh" ] && set -- "$@" -u "$(bug913718_unify)"
cmd=$(dirname $0)/example.ia-c-error
bug913718_cmd
ia_logfile="$(mktemp)"
export ia_logfile
rm -f $ia_logfile
check "(1) Run script with -c in sub" -i "echo \"i
\"" "$@" "$cmd -a" "--- output with ERROR from <example.ia-c-error/sub> running <echo \"error\"> ---
e:error
--- (q)uit (r)edo (i)gnore (s)witch interactive ---
? "
check "(2) check logfile" "$@" "cat $ia_logfile" "|example.ia-c-error
||example.ia-c-error/sub
||--- output with ERROR from <example.ia-c-error/sub> running <echo \"error\"> ---
||e:error
||--- (q)uit (r)edo (i)gnore (s)witch interactive ---
||? i<RETURN>"
cmd=$(dirname $0)/example.ia-c-error.tmp.main_sub
cat $(dirname $0)/example.ia-c-error | sed -e "s/\<ia .* # sub ia$/ia -c/" -e "s/\<ia .* # main ia$/ia -c/" > $cmd
chmod 755 $cmd
bug913718_cmd
rm -f $ia_logfile
check "(3) Run script with -c in sub and main" -i "echo \"i
\"" "$@" "$cmd -a" "--- output with ERROR from <example.ia-c-error.tmp.main_sub/sub> running <echo \"error\"> ---
e:error
--- (q)uit (r)edo (i)gnore (s)witch interactive ---
? "
check "(4) check logfile" \
"$@" "cat $ia_logfile" "|example.ia-c-error.tmp.main_sub
||example.ia-c-error.tmp.main_sub/sub
||--- output with ERROR from <example.ia-c-error.tmp.main_sub/sub> running <echo \"error\"> ---
||e:error
||--- (q)uit (r)edo (i)gnore (s)witch interactive ---
||? i<RETURN>"
cmd=$(dirname $0)/example.ia-c-error.tmp.main
cat $(dirname $0)/example.ia-c-error | sed -e "s/\<ia .* # sub ia$/ia/" -e "s/\<ia .* # main ia$/ia -c/" > $cmd
chmod 755 $cmd
bug913718_cmd
rm -f $ia_logfile
check "(5) Run script with -c in main" -i "echo \"i
\"" "$@" "$cmd -a" "--- output with ERROR from <example.ia-c-error.tmp.main> running <sub > ---
e:error
--- (q)uit (r)edo (i)gnore (s)witch interactive ---
? "
check "(6) check logfile" \
"$@" "cat $ia_logfile" "|example.ia-c-error.tmp.main
||example.ia-c-error.tmp.main/sub
|--- output with ERROR from <example.ia-c-error.tmp.main> running <sub > ---
|e:error
|--- (q)uit (r)edo (i)gnore (s)witch interactive ---
|? i<RETURN>"
cmd=$(dirname $0)/example.ia-c-ignore.tmp.main_sub
cat $(dirname $0)/example.ia-c-error | sed -e "s/\<ia .* # sub ia$/ia -c/" -e "s/\<ia .* # main ia$/ia -c/" \
-e "/ia_add/i ia_ignore \"error\"" > $cmd
chmod 755 $cmd
bug913718_cmd
rm -f $ia_logfile
check "(8) Run script with -c and ia_ignore in sub and main" "$@" "$cmd" ""
cmd=$(dirname $0)/example.ia-c-stdout.tmp.main_sub
cat $(dirname $0)/example.ia-c-error | sed -e "s/\<ia .* # sub ia$/ia -c/" -e "s/\<ia .* # main ia$/ia -c/" \
-e "/ia_add/i ia_stdout \"error\"" > $cmd
chmod 755 $cmd
bug913718_cmd
rm -f $ia_logfile
check "(9) Run script with -c and ia_stdout in sub and main" "$@" "$cmd" "error"
rm -f $ia_logfile
|