7dfb3695942522958cbc7bfbcb2781fd7c3b34c2
[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 echo '
59 ##########################################################
60 # test to check options
61 ##########################################################
62 '
63 mk $R/bin/afb-daemon-cov --help
64
65 mk $R/bin/afb-daemon-cov --version
66
67 mk $R/bin/afb-daemon-cov --no-httpd --fake-option
68
69 mk $R/bin/afb-daemon-cov --daemon --session-max
70
71 mk $R/bin/afb-daemon-cov --ws-client fake --session-max toto
72
73 mk $R/bin/afb-daemon-cov --foreground --port -55
74
75 mk $R/bin/afb-daemon-cov --foreground --port 9999999
76
77 mk $R/bin/afb-daemon-cov --no-ldpath --traceapi fake
78
79 mk $R/bin/afb-daemon-cov --traceditf all --tracesvc all --log error,alarm
80
81 mk $R/bin/afb-daemon-cov --call noapi/noverb:false
82
83 mk $R/bin/afb-daemon-cov --call not-a-call
84
85 LISTEN_FDNAMES=toto,demat LISTEN_FDS=5
86 typeset -x LISTEN_FDNAMES LISTEN_FDS
87 mk $R/bin/afb-daemon-cov --no-ldpath --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"
88 typeset +x LISTEN_FDNAMES LISTEN_FDS
89
90 mk $R/bin/afb-daemon-cov --weak-ldpaths $R/ldpath/weak --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"
91
92 AFB_DEBUG_BREAK=zero,one,two,main-start  AFB_DEBUG_WAIT="here I am,main-args"
93 typeset -x AFB_DEBUG_BREAK AFB_DEBUG_WAIT
94 mkdbgwait $R/bin/afb-daemon-cov --rootdir $R/i-will-never-exist
95 typeset +x AFB_DEBUG_BREAK AFB_DEBUG_WAIT
96
97 mk $R/bin/afb-daemon-cov --workdir=/etc/you/should/not/be/able/to/create/me
98
99 mk $R/bin/afb-daemon-cov --exec $R/it-doesn-t-exist
100
101 echo '
102 ##########################################################
103 # test of the bench
104 ##########################################################
105 '
106 mk $R/bin/test-apiset
107
108 mk $R/bin/test-session
109
110 mk $R/bin/test-wrap-json
111
112 echo '
113 ##########################################################
114 # true life test: run parts as direct client
115 ##########################################################
116 '
117 mk \
118 vg \
119         --log-file=$R/valgrind.out \
120         --trace-children=no \
121         --track-fds=yes \
122         --leak-check=full \
123         --show-leak-kinds=all \
124         --num-callers=50 \
125 $R/bin/afb-daemon-cov \
126         --verbose \
127         --verbose \
128         --verbose \
129         --verbose \
130         --quiet \
131         --quiet \
132         --quiet \
133         --quiet \
134         --quiet \
135         --quiet \
136         --log error,warning,notice,info,debug,critical,alert-error,warning,notice,info,debug,critical,alert+error,warning,notice,info,debug,critical,alert \
137         --foreground \
138         --name binder-cov \
139         --port 8888 \
140         --roothttp $R/www \
141         --rootbase /opa \
142         --rootapi /api \
143         --alias /icons:$R/www \
144         --apitimeout 90 \
145         --cntxtimeout 3600 \
146         --cache-eol 200 \
147         --workdir . \
148         --uploaddir . \
149         --rootdir . \
150         --ldpaths $R/ldpath/strong \
151         --binding $R/bin/demat.so \
152         --auto-api $R/apis/auto \
153         --token HELLO \
154         --random-token \
155         --session-max 1000 \
156         --tracereq all \
157         --traceapi all \
158         --traceses all \
159         --traceevt all \
160         --traceglob none \
161         --monitoring \
162         --set hello/key:a-kind-of-text \
163         --call demat/ping:true \
164         --call hello/ping:false \
165         --ws-server unix:$R/apis/ws/hello \
166         --ws-server unix:$R/apis/ws/salut \
167         --exec $R/scripts/run-parts.sh @p @t
168
169 echo '
170 ##########################################################
171 # true life test: run parts as in-direct server
172 ##########################################################
173 '
174 mk \
175 vg \
176         --log-file=$R/valgrind.out \
177         --trace-children=no \
178         --track-fds=yes \
179         --leak-check=full \
180         --show-leak-kinds=all \
181         --num-callers=50 \
182 $R/bin/afb-daemon-cov \
183         --foreground \
184         --verbose \
185         --verbose \
186         --roothttp $R/www \
187         --alias /icons:$R/www \
188         --workdir . \
189         --uploaddir . \
190         --rootdir . \
191         --port 8888 \
192         --ldpaths $R/ldpath/strong \
193         --binding $R/bin/demat.so \
194         --auto-api $R/apis/auto \
195         --random-token \
196         --ws-server unix:$R/apis/ws/hello \
197         --ws-server unix:$R/apis/ws/salut \
198         --ws-server localhost:9595/salut \
199         --exec \
200             $R/bin/afb-daemon-nocov \
201                 --quiet \
202                 --quiet \
203                 --port 9999 \
204                 --auto-api $R/apis/auto \
205                 --auto-api $R/apis/ws \
206                 --ws-client localhost:9595/salut2 \
207                 --exec $R/scripts/run-parts.sh @@p @@t
208
209 echo '
210 ##########################################################
211 # true life test: run parts as in-direct client
212 ##########################################################
213 '
214 mk \
215 vg \
216         --log-file=$R/valgrind.out \
217         --trace-children=no \
218         --track-fds=yes \
219         --leak-check=full \
220         --show-leak-kinds=all \
221         --num-callers=50 \
222 $R/bin/afb-daemon-nocov \
223         --quiet \
224         --quiet \
225         --foreground \
226         --roothttp $R/www \
227         --alias /icons:$R/www \
228         --workdir . \
229         --uploaddir . \
230         --rootdir . \
231         --port 8888 \
232         --ldpaths $R/ldpath/strong \
233         --binding $R/bin/demat.so \
234         --auto-api $R/apis/auto \
235         --random-token \
236         --ws-server unix:$R/apis/ws/hello \
237         --ws-server unix:$R/apis/ws/salut \
238         --ws-server localhost:9595/salut \
239         --exec \
240             $R/bin/afb-daemon-cov \
241                 --port 9999 \
242                 --verbose \
243                 --verbose \
244                 --auto-api $R/apis/auto \
245                 --auto-api $R/apis/ws \
246                 --ws-client localhost:9595/salut2 \
247                 --exec $R/scripts/run-parts.sh @@p @@t
248
249 exit 0
250
251