File: test.hello_world_log

package info (click to toggle)
shellia 5.10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 792 kB
  • sloc: sh: 7,840; makefile: 34
file content (103 lines) | stat: -rwxr-xr-x 2,714 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# vim: set filetype=sh :
#        file: test.hello_world_log
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
#     license: GNU General Public License, version 3
# description: test "hello world" script with logging
#    see also: hello_world_log

# The following tests are included:
# (1) Run with options -a -d 99 -- "shellia user"
# (2) Run with options -a -i "shellia user" and enter 2, c and q

. ./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"

cmd="$(dirname $0)/hello_world_log"
use_locallib

check "(1) Run with options -d 99 -- \"shellia user\"" "$@" "$cmd -a -d 99 -- \"shellia user\"" \
"DEBUG main program begin
DEBUG function say_hello called with 1 arguments
hello shellia user
DEBUG function say_hello end
DEBUG main program end
--- LOGFILE ---
|hello_world_log.tmp.locallib
|DEBUG main program begin
||hello_world_log.tmp.locallib/say_hello
||DEBUG function say_hello called with 1 arguments
||s:hello shellia user
||DEBUG function say_hello end
|DEBUG main program end
---------------"

check "(2) Run hello_world interactive" -i "/bin/echo -e \"2\nc\nq\n\"" "$@" "$cmd -a -i \"shellia user\"" \
"=== hello_world_log.tmp.locallib ===
1 dbg \"main program begin\"
2 say_hello -i -- \"shellia user\"
3 dbg \"main program end\"
d ... change dbg: 0
i toggle -i flag
c continue without questions
q quit
? [1] 
=== hello_world_log.tmp.locallib/say_hello ===
1 dbg \"function say_hello called with 1 arguments\"
2 name=\"shellia user\"
3 echo \"hello \$name\"
4 dbg \"function say_hello end\"
d ... change dbg: 0
c continue without questions
q quit
? [1] 
hello shellia user
=== hello_world_log.tmp.locallib ===
1 dbg \"main program begin\"
2 say_hello -i -- \"shellia user\"
3 dbg \"main program end\"
d ... change dbg: 0
i toggle -i flag
q quit
? [3] 
--- LOGFILE ---
|=== hello_world_log.tmp.locallib ===
|1 dbg \"main program begin\"
|2 say_hello -i -- \"shellia user\"
|3 dbg \"main program end\"
|d ... change dbg: 0
|i toggle -i flag
|c continue without questions
|q quit
|? [1] 2<RETURN>
||=== hello_world_log.tmp.locallib/say_hello ===
||1 dbg \"function say_hello called with 1 arguments\"
||2 name=\"shellia user\"
||3 echo \"hello \$name\"
||4 dbg \"function say_hello end\"
||d ... change dbg: 0
||c continue without questions
||q quit
||? [1] c<RETURN>
||s:hello shellia user
|=== hello_world_log.tmp.locallib ===
|1 dbg \"main program begin\"
|2 say_hello -i -- \"shellia user\"
|3 dbg \"main program end\"
|d ... change dbg: 0
|i toggle -i flag
|q quit
|? [3] q<RETURN>
---------------"