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 114 115 116 117 118 119 120 121
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.hello_world_debug
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
# license: GNU General Public License, version 3
# description: test simple script like "hello world" but with debug
# see also: hello_world_debug
# The following tests are included:
# (1) Run without options
# (2) Run interactive
. ./tstlib
shell=""
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
/bin/echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" ] && set -- "$@" -s "$shell"
cat $(dirname $0)/hello_world_debug | sed -e "s/\(dbg \)[^\\\"]*/\1/" >$(dirname $0)/hello_world_debug.tmp.simple
cat $(dirname $0)/hello_world_debug | sed -e "s/\(dbg [0-9] \)[^\\\"]*/\1/" >$(dirname $0)/hello_world_debug.tmp.only_level
chmod 755 $(dirname $0)/hello_world_debug.tmp.simple $(dirname $0)/hello_world_debug.tmp.only_level
i=0; for cmd in hello_world_debug.tmp.simple hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(1.$i) Run hello_world_debug.tmp.simple without options" "$@" "$cmd" \
"hello world"
done
i=0; for cmd in hello_world_debug.tmp.simple hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(2.$i) Run hello_world_debug.tmp.simple with -d" "$@" "$cmd -d 99" \
"DEBUG main program
DEBUG say_hello function start
hello world
DEBUG say_hello function end"
done
i=0; for cmd in hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(3.$i) Run hello_world_debug with -d 1" "$@" "$cmd -d 1" \
"DEBUG main program
hello world"
done
i=0; for cmd in hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(4.$i) Run hello_world_debug with -d 2" "$@" "$cmd -d 2" \
"DEBUG main program
hello world"
done
i=0; for cmd in hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(5.$i) Run hello_world_debug with -d 3" "$@" "$cmd -d 3" \
"DEBUG main program
DEBUG say_hello function start
hello world
DEBUG say_hello function end"
done
i=0; for cmd in hello_world_debug.tmp.only_level hello_world_debug; do i=$((i+1))
cmd=$(dirname $0)/$cmd
use_locallib
check "(6.$i) Run hello_world_debug with -d 99" "$@" "$cmd -d 99" \
"DEBUG main program
DEBUG say_hello function start
hello world
DEBUG say_hello function end"
done
cmd="$(dirname $0)/hello_world_debug"
use_locallib
check "(7) Run hello_world_debug with -d" "$@" "$cmd -d \"3 start\"" \
"DEBUG say_hello function start
hello world"
check "(8) Run hello_world_debug with -d" "$@" "$cmd -d \"3 start end\"" \
"DEBUG say_hello function start
hello world
DEBUG say_hello function end"
check "(9) Run hello_world_debug with -d" "$@" "$cmd -d \"3 start none\"" \
"DEBUG main program
DEBUG say_hello function start
hello world"
check "(10) Run with -a -i -d \"3 none\", add \"end\" and continue" -i "echo \"d end
c
\"" "$@" "$cmd -a -i -d \"3 none\"" \
"=== hello_world_debug.tmp.locallib ===
1 dbg \"main program\"
2 say_hello_world
d ... change dbg: 3 none
c continue without questions
q quit
? [1]
=== hello_world_debug.tmp.locallib ===
1 dbg \"main program\"
2 say_hello_world
d ... change dbg: 3 end none
c continue without questions
q quit
? [1]
DEBUG main program
hello world
DEBUG say_hello function end"
|