aboutsummaryrefslogtreecommitdiffstats
path: root/coverage/scripts/run-test.sh
blob: 7dfb3695942522958cbc7bfbcb2781fd7c3b34c2 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/bash

export R=$(realpath $(dirname $0)/..)
export PATH="$R/bin:$R/scripts:$PATH"

cd $R/bin

lcov -c -i -d $R/bin -o $R/lcov-out.info

vg() {
	if [[ -z "$NOVALGRIND" ]]; then
		valgrind "$@"
	else
		while :; do
			case "$1" in
			--*) shift;;
			*) break;;
			esac
		done
		"$@"
	fi
}

mkbefore() {
	echo
	echo "*******************************************************************"
	echo "** $*"
	echo "*******************************************************************"
	lcov -c -i -d $R/bin -o $R/fake.info
}

mkafter() {
	lcov -c -d $R/bin -o $R/tmp.info
	mv $R/lcov-out.info $R/previous.info
	lcov -a $R/tmp.info -a $R/previous.info -o $R/lcov-out.info
	rm $R/previous.info $R/fake.info  $R/tmp.info
}

mk() {
	mkbefore "$@"
	"$@"
	mkafter "$@"
}

mkdbgwait() {
	mkbefore "$@"
	"$@" &
	sleep 1
	kill -INT %%
	sleep 1
	mkafter "$@"
}

mkdir /tmp/ldpaths
export AFB_LDPATHS=/tmp/ldpaths
export AFB_TRACEAPI=no

echo '
##########################################################
# test to check options
##########################################################
'
mk $R/bin/afb-daemon-cov --help

mk $R/bin/afb-daemon-cov --version

mk $R/bin/afb-daemon-cov --no-httpd --fake-option

mk $R/bin/afb-daemon-cov --daemon --session-max

mk $R/bin/afb-daemon-cov --ws-client fake --session-max toto

mk $R/bin/afb-daemon-cov --foreground --port -55

mk $R/bin/afb-daemon-cov --foreground --port 9999999

mk $R/bin/afb-daemon-cov --no-ldpath --traceapi fake

mk $R/bin/afb-daemon-cov --traceditf all --tracesvc all --log error,alarm

mk $R/bin/afb-daemon-cov --call noapi/noverb:false

mk $R/bin/afb-daemon-cov --call not-a-call

LISTEN_FDNAMES=toto,demat LISTEN_FDS=5
typeset -x LISTEN_FDNAMES LISTEN_FDS
mk $R/bin/afb-daemon-cov --no-ldpath --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"
typeset +x LISTEN_FDNAMES LISTEN_FDS

mk $R/bin/afb-daemon-cov --weak-ldpaths $R/ldpath/weak --binding $R/bin/demat.so --ws-server sd:demat --call "demat/exit:0"

AFB_DEBUG_BREAK=zero,one,two,main-start  AFB_DEBUG_WAIT="here I am,main-args"
typeset -x AFB_DEBUG_BREAK AFB_DEBUG_WAIT
mkdbgwait $R/bin/afb-daemon-cov --rootdir $R/i-will-never-exist
typeset +x AFB_DEBUG_BREAK AFB_DEBUG_WAIT

mk $R/bin/afb-daemon-cov --workdir=/etc/you/should/not/be/able/to/create/me

mk $R/bin/afb-daemon-cov --exec $R/it-doesn-t-exist

echo '
##########################################################
# test of the bench
##########################################################
'
mk $R/bin/test-apiset

mk $R/bin/test-session

mk $R/bin/test-wrap-json

echo '
##########################################################
# true life test: run parts as direct client
##########################################################
'
mk \
vg \
	--log-file=$R/valgrind.out \
	--trace-children=no \
	--track-fds=yes \
	--leak-check=full \
	--show-leak-kinds=all \
	--num-callers=50 \
$R/bin/afb-daemon-cov \
	--verbose \
	--verbose \
	--verbose \
	--verbose \
	--quiet \
	--quiet \
	--quiet \
	--quiet \
	--quiet \
	--quiet \
	--log error,warning,notice,info,debug,critical,alert-error,warning,notice,info,debug,critical,alert+error,warning,notice,info,debug,critical,alert \
	--foreground \
	--name binder-cov \
	--port 8888 \
	--roothttp $R/www \
	--rootbase /opa \
	--rootapi /api \
	--alias /icons:$R/www \
	--apitimeout 90 \
	--cntxtimeout 3600 \
	--cache-eol 200 \
	--workdir . \
	--uploaddir . \
	--rootdir . \
	--ldpaths $R/ldpath/strong \
	--binding $R/bin/demat.so \
	--auto-api $R/apis/auto \
	--token HELLO \
	--random-token \
	--session-max 1000 \
	--tracereq all \
	--traceapi all \
	--traceses all \
	--traceevt all \
	--traceglob none \
	--monitoring \
	--set hello/key:a-kind-of-text \
	--call demat/ping:true \
	--call hello/ping:false \
	--ws-server unix:$R/apis/ws/hello \
	--ws-server unix:$R/apis/ws/salut \
	--exec $R/scripts/run-parts.sh @p @t

echo '
##########################################################
# true life test: run parts as in-direct server
##########################################################
'
mk \
vg \
	--log-file=$R/valgrind.out \
	--trace-children=no \
	--track-fds=yes \
	--leak-check=full \
	--show-leak-kinds=all \
	--num-callers=50 \
$R/bin/afb-daemon-cov \
	--foreground \
	--verbose \
	--verbose \
	--roothttp $R/www \
	--alias /icons:$R/www \
	--workdir . \
	--uploaddir . \
	--rootdir . \
	--port 8888 \
	--ldpaths $R/ldpath/strong \
	--binding $R/bin/demat.so \
	--auto-api $R/apis/auto \
	--random-token \
	--ws-server unix:$R/apis/ws/hello \
	--ws-server unix:$R/apis/ws/salut \
	--ws-server localhost:9595/salut \
	--exec \
	    $R/bin/afb-daemon-nocov \
		--quiet \
		--quiet \
		--port 9999 \
		--auto-api $R/apis/auto \
		--auto-api $R/apis/ws \
		--ws-client localhost:9595/salut2 \
		--exec $R/scripts/run-parts.sh @@p @@t

echo '
##########################################################
# true life test: run parts as in-direct client
##########################################################
'
mk \
vg \
	--log-file=$R/valgrind.out \
	--trace-children=no \
	--track-fds=yes \
	--leak-check=full \
	--show-leak-kinds=all \
	--num-callers=50 \
$R/bin/afb-daemon-nocov \
	--quiet \
	--quiet \
	--foreground \
	--roothttp $R/www \
	--alias /icons:$R/www \
	--workdir . \
	--uploaddir . \
	--rootdir . \
	--port 8888 \
	--ldpaths $R/ldpath/strong \
	--binding $R/bin/demat.so \
	--auto-api $R/apis/auto \
	--random-token \
	--ws-server unix:$R/apis/ws/hello \
	--ws-server unix:$R/apis/ws/salut \
	--ws-server localhost:9595/salut \
	--exec \
	    $R/bin/afb-daemon-cov \
		--port 9999 \
		--verbose \
		--verbose \
		--auto-api $R/apis/auto \
		--auto-api $R/apis/ws \
		--ws-client localhost:9595/salut2 \
		--exec $R/scripts/run-parts.sh @@p @@t

exit 0