8 export AGLDRIVER=agl-driver
10 # for pyagl - unless redefined in a test
11 export AGL_AVAILABLE_INTERFACES="ethernet"
12 export AGL_CAN_INTERFACE="vcan0"
23 echo "Unknown argument $1"
29 if [ -z "$BASEURL" ]; then
30 echo "$0: missing BASEURL"
31 echo "Usage: $0 -b BASEURL"
38 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
39 su - $AGLDRIVER -c "afm-util $*"
49 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
50 su - $AGLDRIVER -c "afm-test -l $*"
57 # work in tmp folder to allow different users to access files (smack)
61 if [ ! -f index.html ] ; then
62 wget -q $BASEURL -O index.html
64 echo "ERROR: Cannot wget $BASEURL"
69 # first download all files
70 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
73 # remove extension and the debug state
74 echo "DEBUG: fetch $wgtfile"
76 if [ ! -f $wgtfile ] ; then
77 wget -q $BASEURL/$wgtfile
79 echo "ERROR: wget from $BASEURL/$wgtfile"
84 chmod -R a+rwx ${TOPDIR}
85 chsmack -a "*" ${TOPDIR}/*
92 export SERVICE_PLATFORM=0
94 export APPLICATION_USER=0
100 echo "DEBUG: analyse wgt file"
101 unzip $CURDIR/$wgtfile
103 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
104 echo "ERROR: cannot unzip $wgtfile"
106 if [ -f config.xml ];then
107 grep hidden config.xml
109 echo "DEBUG: hidden package"
111 echo "DEBUG: not hidden package"
113 # a service sets urn:AGL:widget:provided-api
114 grep "urn:AGL:widget:provided-api" config.xml
115 if [ $? -eq 0 ] ; then
116 # we are a service, now determine the scope ...
117 grep "urn:AGL:permission::partner:scope-platform" config.xml
119 export SERVICE_PLATFORM=1
121 export SERVICE_USER=1
124 # we are an application
125 export APPLICATION_USER=1
126 # no other type known (yet)
128 # the file naming convention is servicename.wgt
129 # but some didnt respect it
130 export WGTSERVICENAME=$(grep 'id=.*' config.xml | sed 's,^.*id=,id=,' | cut -d= -f2 | cut -d'"' -f2)
131 if [ -z "$WGTSERVICENAME" ];then
132 echo "WARN: failed to find name in config.xml, fallback to filename"
133 export WGTSERVICENAME="$WGTNAME"
135 echo "DEBUG: detected service name as $WGTSERVICENAME"
138 echo "DEBUG: fail to unzip"
145 # check if WGTNAME is running
146 check_service_running() {
150 echo "DEBUG: check_service_running with systemctl list-units -full"
151 systemctl list-units --full | grep "afm.*$WGTNAME--"
155 echo "DEBUG: check_service_running with systemctl -a"
156 systemctl -a |grep "afm.*$WGTNAME--"
158 if [ $RUNNING -eq 0 ];then
159 echo "ERROR: inconsistent results"
169 # we need the full name (with -test, -debug etc..) for LAVA test case
170 WGTNAMEF=$(echo $2 | sed 's,.wgt,,')
172 echo "INFO: do_release_test $WGTNAME $wgtfile"
174 echo "DEBUG: list current pkgs"
177 afm-util list --all > $LIST
179 echo "ERROR: afm-util list exit with error"
182 if [ ! -s "$LIST" ];then
183 echo "ERROR: afm-util list is empty"
187 echo "DEBUG: check presence of $WGTNAME"
188 NAMEID=$(grep id\\\":\\\"${WGTSERVICENAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
189 if [ ! -z "$NAMEID" ];then
190 echo "DEBUG: $WGTNAME already installed as $NAMEID"
191 # need to kill then deinstall
192 do_afm_util ps --all | grep -q $WGTNAME
194 echo "DEBUG: kill $WGTNAME"
195 do_afm_util kill $WGTNAME
197 echo "ERROR: afm-util kill"
198 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
201 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
204 echo "DEBUG: no need to kill $WGTNAME"
207 echo "DEBUG: deinstall $WGTNAME"
208 afm-util remove $NAMEID
210 echo "ERROR: afm-util remove"
211 #lava-test-case afm-util-remove-$WGTNAMEF --result fail
212 journalctl -b | tail -40
215 lava-test-case afm-util-remove-$WGTNAMEF --result pass
218 echo "DEBUG: $WGTNAME not installed"
222 echo "DEBUG: install $wgtfile"
224 afm-util install $wgtfile > $OUT
226 echo "ERROR: afm-util install"
227 lava-test-case afm-util-install-$WGTNAMEF --result fail
230 lava-test-case afm-util-install-$WGTNAMEF --result pass
232 # message is like \"added\":\"mediaplayer@0.1\"
233 NAMEID=$(grep d\\\":\\\"${WGTSERVICENAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
234 if [ -z "$NAMEID" ];then
235 echo "ERROR: Cannot get nameid"
236 echo "DEBUG: ========== DUMPING output =========="
238 echo "DEBUG: ========== END DUMP =========="
241 echo "DEBUG: $WGTNAME is installed as $NAMEID"
243 afm-util list --all > $LIST
245 echo "ERROR: afm-util list exit with error"
248 if [ ! -s "$LIST" ];then
249 echo "ERROR: afm-util list is empty"
252 echo "DEBUG: Verify that $WGTNAME is installed"
253 grep -q $NAMEID $LIST
255 echo "ERROR: $WGTNAME is not installed"
256 # for debugging, give full output
257 echo "DEBUG: start of list"
259 echo "DEBUG: end of list"
262 do_afm_util info $NAMEID
264 echo "ERROR: afm-util info"
265 lava-test-case afm-util-info-$WGTNAMEF --result fail
267 lava-test-case afm-util-info-$WGTNAMEF --result pass
270 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
271 systemctl list-units --full | grep "afm.*$WGTNAME--"
272 echo "DEBUG: check if we see the package with systemctl -a (before start)"
273 systemctl -a |grep "afm.*$WGTNAME--"
275 echo "DEBUG: start $NAMEID"
276 do_afm_util start $NAMEID > "rid"
278 echo "ERROR: afm-util start"
279 lava-test-case afm-util-start-$WGTNAMEF --result fail
283 lava-test-case afm-util-start-$WGTNAMEF --result pass
286 check_service_running $WGTNAME
288 echo "DEBUG: Get RID for $NAMEID"
290 afm-util ps --all > $PSLIST
292 echo "ERROR: afm-util ps"
293 lava-test-case afm-util-ps-$WGTNAMEF --result fail
297 lava-test-case afm-util-ps-$WGTNAMEF --result pass
299 # TODO, compare RID with the list in $PSLIST"
301 if [ "$RID" == 'null' ];then
303 echo "DEBUG: retry start $NAMEID"
304 do_afm_util start $NAMEID > "rid"
306 echo "ERROR: afm-util start"
307 lava-test-case afm-util-start-$WGTNAMEF --result fail
313 if [ "$RID" == 'null' ];then
314 echo "ERROR: RID is null, service fail to start"
315 lava-test-case afm-util-status-$WGTNAMEF --result fail
319 echo "DEBUG: status $NAMEID ($RID)"
320 do_afm_util status $RID
322 echo "ERROR: afm-util status"
323 lava-test-case afm-util-status-$WGTNAMEF --result fail
326 lava-test-case afm-util-status-$WGTNAMEF --result pass
329 echo "DEBUG: kill $NAMEID ($RID)"
330 do_afm_util kill $NAMEID
332 echo "ERROR: afm-util kill"
333 lava-test-case afm-util-kill-$WGTNAMEF --result fail
336 lava-test-case afm-util-kill-$WGTNAMEF --result pass
339 echo "DEBUG: start2 $NAMEID"
340 do_afm_util start $NAMEID > rid
342 echo "ERROR: afm-util start2"
343 lava-test-case afm-util-start2-$WGTNAMEF --result fail
347 lava-test-case afm-util-start2-$WGTNAMEF --result pass
350 if [ "$RID" == 'null' ];then
351 echo "ERROR: RID is null"
355 echo "DEBUG: status2 $NAMEID ($RID)"
356 do_afm_util status $RID
358 echo "ERROR: afm-util status2"
359 lava-test-case afm-util-status2-$WGTNAMEF --result fail
362 lava-test-case afm-util-status2-$WGTNAMEF --result pass
366 WGTNAMES=$(grep -o '[a-z-]*.wgt' index.html | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-test$,,' | sed 's,-coverage$,,' | sort | uniq)
367 for WGTNAME in $WGTNAMES
369 if [ -e $WGTNAME.wgt ];then
370 inspect_wgt $WGTNAME.wgt $WGTNAME
371 do_release_test $WGTNAME $WGTNAME.wgt
372 pytest --show-capture=no --color=no -k "not hwrequired and not internet" /usr/lib/python?.?/site-packages/pyagl/tests/ -L
374 echo "WARN: cannot find $WGTNAME.wgt"
376 # disabled due to SPEC-3608
377 #if [ -e $WGTNAME-test.wgt ];then
378 # # wgt-test do not have the same permissions in the config.xml as the parent wgt
379 # # so keep the value from last run
380 # #inspect_wgt $WGTNAME-test.wgt
381 # check_service_running $WGTNAME
382 # if [ $? -eq 1 ];then
383 # do_afm_test $TOPDIR/$WGTNAME-test.wgt
384 # if [ $? -eq 0 ];then
385 # lava-test-case run-test-$WGTNAME --result pass
387 # lava-test-case run-test-$WGTNAME --result fail
390 # echo "DEBUG: $WGTNAME is not running, skipping test"
391 # lava-test-case run-test-$WGTNAME --result skip
394 # echo "WARN: cannot find $WGTNAME.wgt"
396 if [ -e $WGTNAME-debug.wgt ];then
397 inspect_wgt $WGTNAME-debug.wgt $WGTNAME
398 do_release_test $WGTNAME $WGTNAME-debug.wgt
399 pytest --color=no -k "not hwrequired" /usr/lib/python?.?/site-packages/pyagl/tests/
401 if [ -e "$WGTNAME-coverage.wgt" ];then
402 gcovr-wrapper "$WGTNAME-coverage.wgt" > coverage.result
405 if [ $RET -eq 0 ];then
406 lava-test-case "run-test-$WGTNAME-coverage" --result pass
407 LINES_PERCENT=$(grep -o '^lines.*%' coverage.result | cut -d ' ' -f2 | cut -d% -f1)
408 lava-test-case "run-test-$WGTNAME-coverage-percentage-lines" --result pass --measurement "$LINES_PERCENT"
409 BRANCHES_PERCENT=$(grep -o '^branches.*%' coverage.result | cut -d ' ' -f2 | cut -d% -f1)
410 lava-test-case "run-test-$WGTNAME-coverage-percentage-branches" --result pass --measurement "$BRANCHES_PERCENT"
412 lava-test-case "run-test-$WGTNAME-coverage" --result fail