coverage: Add test of AFB_DEBUG_WAIT
[src/app-framework-binder.git] / coverage / scripts / run-test.sh
1 #!/bin/bash
2
3 export R=$(realpath $(dirname $0)/..)
4 export PATH="$R/bin:$R/scripts:$PATH"
5
6 cd $R/bin
7
8 lcov -c -i -d $R/bin -o $R/lcov-out.info
9
10 vg() {
11         if [[ -z "$NOVALGRIND" ]]; then
12                 valgrind "$@"
13         else
14                 while :; do
15                         case "$1" in
16                         --*) shift;;
17                         *) break;;
18                         esac
19                 done
20                 "$@"
21         fi
22 }
23
24 mkbefore() {
25         echo
26         echo "*******************************************************************"
27         echo "** $*"
28         echo "*******************************************************************"
29         lcov -c -i -d $R/bin -o $R/fake.info
30 }
31
32 mkafter() {
33         lcov -c -d $R/bin -o $R/tmp.info
34         mv $R/lcov-out.info $R/previous.info
35         lcov -a $R/tmp.info -a $R/previous.info -o $R/lcov-out.info
36         rm $R/previous.info $R/fake.info  $R/tmp.info
37 }
38
39 mk() {
40         mkbefore "$@"
41         "$@"
42         mkafter "$@"
43 }
44
45 mkdbgwait() {
46         mkbefore "$@"
47         "$@" &
48         sleep 1
49         kill -INT %%
50         sleep 1
51         mkafter "$@"
52 }
53
54 mkdir /tmp/ldpaths
55 export AFB_LDPATHS=/tmp/ldpaths
56 export AFB_TRACEAPI=no
57
58 ##########################################################
59 # test to check options
60 ##########################################################
61 mk $R/bin/afb-daemon-cov --help
62
63 mk $R/bin/afb-daemon-cov --version
64
65 mk $R/bin/afb-daemon-cov --no-httpd --fake-option
66
67 mk $R/bin/afb-daemon-cov --daemon --session-max
68
69 mk $R/bin/afb-daemon-cov --ws-client fake --session-max toto
70
71 mk $R/bin/afb-daemon-cov --foreground --port -55
72
73 mk $R/bin/afb-daemon-cov --foreground --port 9999999
74
75 mk $R/bin/afb-daemon-cov --no-ldpath --traceapi fake
76
77 mk $R/bin/afb-daemon-cov --traceditf all --tracesvc all --log error,alarm
78
79 mk $R/bin/afb-daemon-cov --call noapi/noverb:false
80
81 mk $R/bin/afb-daemon-cov --call not-a-call
82
83 LISTEN_FDNAMES=toto,demat LISTEN_FDS=5
84 typeset -x LISTEN_FDNAMES LISTEN_FDS
85 mk $R/bin/afb-daemon-cov --no-ldpath --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"
86 typeset +x LISTEN_FDNAMES LISTEN_FDS
87
88 mk $R/bin/afb-daemon-cov --weak-ldpaths $R/ldpath/weak --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"
89
90 AFB_DEBUG_BREAK=zero,one,two,main-start  AFB_DEBUG_WAIT="here I am,main-args"
91 typeset -x AFB_DEBUG_BREAK AFB_DEBUG_WAIT
92 mkdbgwait $R/bin/afb-daemon-cov --rootdir $R/i-will-never-exist
93 typeset +x AFB_DEBUG_BREAK AFB_DEBUG_WAIT
94
95 mk $R/bin/afb-daemon-cov --workdir=/etc/you/should/not/be/able/to/create/me
96
97 mk $R/bin/afb-daemon-cov --exec $R/it-doesn-t-exist
98
99 ##########################################################
100 # test of the bench
101 ##########################################################
102 mk $R/bin/test-apiset
103
104 mk $R/bin/test-session
105
106 mk $R/bin/test-wrap-json
107
108 ##########################################################
109 # true life test: run parts as direct client
110 ##########################################################
111 mk \
112 vg \
113         --log-file=$R/valgrind.out \
114         --trace-children=no \
115         --track-fds=yes \
116         --leak-check=full \
117         --show-leak-kinds=all \
118         --num-callers=50 \
119 $R/bin/afb-daemon-cov \
120         --verbose \
121         --verbose \
122         --verbose \
123         --verbose \
124         --quiet \
125         --quiet \
126         --quiet \
127         --quiet \
128         --quiet \
129         --quiet \
130         --log error,warning,notice,info,debug,critical,alert-error,warning,notice,info,debug,critical,alert+error,warning,notice,info,debug,critical,alert \
131         --foreground \
132         --name binder-cov \
133         --port 8888 \
134         --roothttp $R/www \
135         --rootbase /opa \
136         --rootapi /api \
137         --alias /icons:$R/www \
138         --apitimeout 90 \
139         --cntxtimeout 3600 \
140         --cache-eol 200 \
141         --workdir . \
142         --uploaddir . \
143         --rootdir . \
144         --ldpaths $R/ldpath/strong \
145         --binding $R/bin/demat.so \
146         --auto-api $R/apis/auto \
147         --token HELLO \
148         --random-token \
149         --session-max 1000 \
150         --tracereq all \
151         --traceapi all \
152         --traceses all \
153         --traceevt all \
154         --traceglob none \
155         --monitoring \
156         --set hello/key:a-kind-of-text \
157         --call demat/ping:true \
158         --call hello/ping:false \
159         --ws-server unix:$R/apis/ws/hello \
160         --ws-server unix:$R/apis/ws/salut \
161         --exec $R/scripts/run-parts.sh @p @t
162
163 ##########################################################
164 # true life test: run parts as in-direct client
165 ##########################################################
166 mk \
167 vg \
168         --log-file=$R/valgrind.out \
169         --trace-children=no \
170         --track-fds=yes \
171         --leak-check=full \
172         --show-leak-kinds=all \
173         --num-callers=50 \
174 $R/bin/afb-daemon-cov \
175         --quiet \
176         --quiet \
177         --foreground \
178         --roothttp $R/www \
179         --alias /icons:$R/www \
180         --workdir . \
181         --uploaddir . \
182         --rootdir . \
183         --ldpaths $R/ldpath/strong \
184         --binding $R/bin/demat.so \
185         --auto-api $R/apis/auto \
186         --random-token \
187         --ws-server unix:$R/apis/ws/hello \
188         --ws-server unix:$R/apis/ws/salut \
189         --ws-server localhost:9595/salut \
190         --exec \
191             $R/bin/afb-daemon-nocov \
192                 --auto-api $R/apis/auto \
193                 --auto-api $R/apis/ws \
194                 --ws-client localhost:@p/salut2 \
195                 $R/scripts/run-parts.sh @@p @@t
196
197 exit 0
198
199