10 # for pyagl - unless redefined in a test
11 AGL_AVAILABLE_INTERFACES="ethernet"
22 echo "Unknown argument $1"
28 if [ -z "$BASEURL" ]; then
29 echo "$0: missing BASEURL"
30 echo "Usage: $0 -b BASEURL"
37 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
38 su - $AGLDRIVER -c "afm-util $*"
48 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
49 su - $AGLDRIVER -c "afm-test -l $*"
56 # work in tmp folder to allow different users to access files (smack)
60 if [ ! -f index.html ] ; then
61 wget -q $BASEURL -O index.html
63 echo "ERROR: Cannot wget $BASEURL"
68 # first download all files
69 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
72 # remove extension and the debug state
73 echo "DEBUG: fetch $wgtfile"
75 if [ ! -f $wgtfile ] ; then
76 wget -q $BASEURL/$wgtfile
78 echo "ERROR: wget from $BASEURL/$wgtfile"
83 chmod -R a+rwx ${TOPDIR}
84 chsmack -a "*" ${TOPDIR}/*
91 export SERVICE_PLATFORM=0
93 export APPLICATION_USER=0
99 echo "DEBUG: analyse wgt file"
100 unzip $CURDIR/$wgtfile
102 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
103 echo "ERROR: cannot unzip $wgtfile"
105 if [ -f config.xml ];then
106 grep hidden config.xml
108 echo "DEBUG: hidden package"
110 echo "DEBUG: not hidden package"
112 # a service sets urn:AGL:widget:provided-api
113 grep "urn:AGL:widget:provided-api" config.xml
114 if [ $? -eq 0 ] ; then
115 # we are a service, now determine the scope ...
116 grep "urn:AGL:permission::partner:scope-platform" config.xml
118 export SERVICE_PLATFORM=1
120 export SERVICE_USER=1
123 # we are an application
124 export APPLICATION_USER=1
125 # no other type known (yet)
127 # the file naming convention is servicename.wgt
128 # but some didnt respect it
129 export WGTSERVICENAME=$(grep 'id=.*' config.xml | sed 's,^.*id=,id=,' | cut -d= -f2 | cut -d'"' -f2)
130 if [ -z "$WGTSERVICENAME" ];then
131 echo "WARN: failed to find name in config.xml, fallback to filename"
132 export WGTSERVICENAME="$WGTNAME"
134 echo "DEBUG: detected service name as $WGTSERVICENAME"
137 echo "DEBUG: fail to unzip"
144 # check if WGTNAME is running
145 check_service_running() {
149 echo "DEBUG: check_service_running with systemctl list-units -full"
150 systemctl list-units --full | grep "afm.*$WGTNAME--"
154 echo "DEBUG: check_service_running with systemctl -a"
155 systemctl -a |grep "afm.*$WGTNAME--"
157 if [ $RUNNING -eq 0 ];then
158 echo "ERROR: inconsistent results"
168 # we need the full name (with -test, -debug etc..) for LAVA test case
169 WGTNAMEF=$(echo $2 | sed 's,.wgt,,')
171 echo "INFO: do_release_test $WGTNAME $wgtfile"
173 echo "DEBUG: list current pkgs"
176 afm-util list --all > $LIST
178 echo "ERROR: afm-util list exit with error"
181 if [ ! -s "$LIST" ];then
182 echo "ERROR: afm-util list is empty"
186 echo "DEBUG: check presence of $WGTNAME"
187 NAMEID=$(grep id\\\":\\\"${WGTSERVICENAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
188 if [ ! -z "$NAMEID" ];then
189 echo "DEBUG: $WGTNAME already installed as $NAMEID"
190 # need to kill then deinstall
191 do_afm_util ps --all | grep -q $WGTNAME
193 echo "DEBUG: kill $WGTNAME"
194 do_afm_util kill $WGTNAME
196 echo "ERROR: afm-util kill"
197 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
200 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
203 echo "DEBUG: no need to kill $WGTNAME"
206 echo "DEBUG: deinstall $WGTNAME"
207 afm-util remove $NAMEID
209 echo "ERROR: afm-util remove"
210 #lava-test-case afm-util-remove-$WGTNAMEF --result fail
211 journalctl -b | tail -40
214 lava-test-case afm-util-remove-$WGTNAMEF --result pass
217 echo "DEBUG: $WGTNAME not installed"
221 echo "DEBUG: install $wgtfile"
223 afm-util install $wgtfile > $OUT
225 echo "ERROR: afm-util install"
226 lava-test-case afm-util-install-$WGTNAMEF --result fail
229 lava-test-case afm-util-install-$WGTNAMEF --result pass
231 # message is like \"added\":\"mediaplayer@0.1\"
232 NAMEID=$(grep d\\\":\\\"${WGTSERVICENAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
233 if [ -z "$NAMEID" ];then
234 echo "ERROR: Cannot get nameid"
235 echo "DEBUG: ========== DUMPING output =========="
237 echo "DEBUG: ========== END DUMP =========="
240 echo "DEBUG: $WGTNAME is installed as $NAMEID"
242 afm-util list --all > $LIST
244 echo "ERROR: afm-util list exit with error"
247 if [ ! -s "$LIST" ];then
248 echo "ERROR: afm-util list is empty"
251 echo "DEBUG: Verify that $WGTNAME is installed"
252 grep -q $NAMEID $LIST
254 echo "ERROR: $WGTNAME is not installed"
255 # for debugging, give full output
256 echo "DEBUG: start of list"
258 echo "DEBUG: end of list"
261 do_afm_util info $NAMEID
263 echo "ERROR: afm-util info"
264 lava-test-case afm-util-info-$WGTNAMEF --result fail
266 lava-test-case afm-util-info-$WGTNAMEF --result pass
269 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
270 systemctl list-units --full | grep "afm.*$WGTNAME--"
271 echo "DEBUG: check if we see the package with systemctl -a (before start)"
272 systemctl -a |grep "afm.*$WGTNAME--"
274 echo "DEBUG: start $NAMEID"
275 do_afm_util start $NAMEID > "rid"
277 echo "ERROR: afm-util start"
278 lava-test-case afm-util-start-$WGTNAMEF --result fail
282 lava-test-case afm-util-start-$WGTNAMEF --result pass
285 check_service_running $WGTNAME
287 echo "DEBUG: Get RID for $NAMEID"
289 afm-util ps --all > $PSLIST
291 echo "ERROR: afm-util ps"
292 lava-test-case afm-util-ps-$WGTNAMEF --result fail
296 lava-test-case afm-util-ps-$WGTNAMEF --result pass
298 # TODO, compare RID with the list in $PSLIST"
300 if [ "$RID" == 'null' ];then
302 echo "DEBUG: retry start $NAMEID"
303 do_afm_util start $NAMEID > "rid"
305 echo "ERROR: afm-util start"
306 lava-test-case afm-util-start-$WGTNAMEF --result fail
312 if [ "$RID" == 'null' ];then
313 echo "ERROR: RID is null, service fail to start"
314 lava-test-case afm-util-status-$WGTNAMEF --result fail
318 echo "DEBUG: status $NAMEID ($RID)"
319 do_afm_util status $RID
321 echo "ERROR: afm-util status"
322 lava-test-case afm-util-status-$WGTNAMEF --result fail
325 lava-test-case afm-util-status-$WGTNAMEF --result pass
328 echo "DEBUG: kill $NAMEID ($RID)"
329 do_afm_util kill $NAMEID
331 echo "ERROR: afm-util kill"
332 lava-test-case afm-util-kill-$WGTNAMEF --result fail
335 lava-test-case afm-util-kill-$WGTNAMEF --result pass
338 echo "DEBUG: start2 $NAMEID"
339 do_afm_util start $NAMEID > rid
341 echo "ERROR: afm-util start2"
342 lava-test-case afm-util-start2-$WGTNAMEF --result fail
346 lava-test-case afm-util-start2-$WGTNAMEF --result pass
349 if [ "$RID" == 'null' ];then
350 echo "ERROR: RID is null"
354 echo "DEBUG: status2 $NAMEID ($RID)"
355 do_afm_util status $RID
357 echo "ERROR: afm-util status2"
358 lava-test-case afm-util-status2-$WGTNAMEF --result fail
361 lava-test-case afm-util-status2-$WGTNAMEF --result pass
365 WGTNAMES=$(grep -o '[a-z-]*.wgt' index.html | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-test$,,' | sed 's,-coverage$,,' | sort | uniq)
366 for WGTNAME in $WGTNAMES
368 if [ -e $WGTNAME.wgt ];then
369 inspect_wgt $WGTNAME.wgt $WGTNAME
370 do_release_test $WGTNAME $WGTNAME.wgt
372 echo "WARN: cannot find $WGTNAME.wgt"
374 if [ -e $WGTNAME-test.wgt ];then
375 # wgt-test do not have the same permissions in the config.xml as the parent wgt
376 # so keep the value from last run
377 #inspect_wgt $WGTNAME-test.wgt
378 check_service_running $WGTNAME
380 do_afm_test $TOPDIR/$WGTNAME-test.wgt
382 lava-test-case run-test-$WGTNAME --result pass
384 lava-test-case run-test-$WGTNAME --result fail
387 echo "DEBUG: $WGTNAME is not running, skipping test"
388 lava-test-case run-test-$WGTNAME --result skip
391 echo "WARN: cannot find $WGTNAME.wgt"
393 if [ -e $WGTNAME-debug.wgt ];then
394 inspect_wgt $WGTNAME-debug.wgt $WGTNAME
395 do_release_test $WGTNAME $WGTNAME-debug.wgt
397 if [ -e $WGTNAME-coverage.wgt ];then
398 inspect_wgt $WGTNAME-coverage.wgt $WGTNAME
399 do_release_test $WGTNAME $WGTNAME-coverage.wgt
400 check_service_running $WGTNAME
402 afm-util install $TOPDIR/$WGTNAME-test.wgt
403 do_afm_test $TOPDIR/$WGTNAME-test.wgt
405 lava-test-case run-test-$WGTNAME --result pass
407 lava-test-case run-test-$WGTNAME --result fail
410 echo "DEBUG: $WGTNAME is not running, skipping test"
411 lava-test-case run-test-$WGTNAME --result skip