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
|
#!/bin/sh
# vim: set filetype=sh :
# file: test.only_debug
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
# license: GNU General Public License, version 3
# description: test debug features provided by shellia
# see also: example.only_debug
# The following tests are included:
# (1) Run script without options
# (2) check the logfile
. ./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" = "posh" ] && set -- "$@" -u "$(bug913718_unify)"
cmd=$(dirname $0)/example.only_debug
bug913718_cmd
ia_logfile="$(mktemp)"
export ia_logfile
rm -f $ia_logfile
check "(1) Run script without options" "$@" "$cmd" "testing: without dbgon or dbgoff
testing: dbgon <1>
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 04:dbg_<1>_<car>
DEBUG 05:dbg_<1>_<cat>
testing: dbgon
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 03:dbg_<3>_<>
DEBUG 04:dbg_<1>_<car>
DEBUG 05:dbg_<1>_<cat>
DEBUG 06:dbg_<2>_<car>
DEBUG 07:dbg_<2>_<bike>
DEBUG 08:dbg_<3>_<dog>
DEBUG 09:dbg_<3>_<cat>
testing: dbgon <2>
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 04:dbg_<1>_<car>
DEBUG 05:dbg_<1>_<cat>
DEBUG 06:dbg_<2>_<car>
DEBUG 07:dbg_<2>_<bike>
testing: dbgon <3>
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 03:dbg_<3>_<>
DEBUG 04:dbg_<1>_<car>
DEBUG 05:dbg_<1>_<cat>
DEBUG 06:dbg_<2>_<car>
DEBUG 07:dbg_<2>_<bike>
DEBUG 08:dbg_<3>_<dog>
DEBUG 09:dbg_<3>_<cat>
testing: dbgoff
testing: dbgon <1> <car bike>
DEBUG 04:dbg_<1>_<car>
testing: dbgon <1> <car - bike>
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 04:dbg_<1>_<car>
testing: dbgon <2> <car bike>
DEBUG 04:dbg_<1>_<car>
DEBUG 06:dbg_<2>_<car>
DEBUG 07:dbg_<2>_<bike>
testing: dbgon <3> <car bike>
DEBUG 04:dbg_<1>_<car>
DEBUG 06:dbg_<2>_<car>
DEBUG 07:dbg_<2>_<bike>
testing: dbgon <3> <dog cat>
DEBUG 05:dbg_<1>_<cat>
DEBUG 08:dbg_<3>_<dog>
DEBUG 09:dbg_<3>_<cat>
testing: dbgon <3> <dog cat ->
DEBUG 01:dbg_<>_<>
DEBUG 02:dbg_<1>_<>
DEBUG 03:dbg_<3>_<>
DEBUG 05:dbg_<1>_<cat>
DEBUG 08:dbg_<3>_<dog>
DEBUG 09:dbg_<3>_<cat>"
# (2) check the logfile
[ -f $ia_logfile ] && echo "ERROR $ia_logfile exists" || echo "OK $ia_logfile does not exist"
rm -f $ia_logfile
|