19 echo "Unknown argument $1"
25 if [ -z "$BASEURL" ]; then
26 echo "$0: missing BASEURL"
27 echo "Usage: $0 -b BASEURL"
34 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
35 su - $AGLDRIVER -c "afm-util $*"
45 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
46 su - $AGLDRIVER -c "afm-test -l $*"
53 # work in tmp folder to allow different users to access files (smack)
57 if [ ! -f index.html ] ; then
58 wget -q $BASEURL -O index.html
60 echo "ERROR: Cannot wget $BASEURL"
65 # first download all files
66 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
69 # remove extension and the debug state
70 echo "DEBUG: fetch $wgtfile"
72 if [ ! -f $wgtfile ] ; then
73 wget -q $BASEURL/$wgtfile
75 echo "ERROR: wget from $BASEURL/$wgtfile"
80 chmod -R a+rwx ${TOPDIR}
81 chsmack -a "*" ${TOPDIR}/*
87 export SERVICE_PLATFORM=0
89 export APPLICATION_USER=0
95 echo "DEBUG: analyse wgt file"
96 unzip $CURDIR/$wgtfile
98 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
99 echo "ERROR: cannot unzip $wgtfile"
101 if [ -f config.xml ];then
102 grep hidden config.xml
104 echo "DEBUG: hidden package"
106 echo "DEBUG: not hidden package"
108 # a service sets urn:AGL:widget:provided-api
109 grep "urn:AGL:widget:provided-api" config.xml
110 if [ $? -eq 0 ] ; then
111 # we are a service, now determine the scope ...
112 grep "urn:AGL:permission::partner:scope-platform" config.xml
114 export SERVICE_PLATFORM=1
116 export SERVICE_USER=1
119 # we are an application
120 export APPLICATION_USER=1
121 # no other type known (yet)
124 echo "DEBUG: fail to unzip"
131 # check if WGTNAME is running
132 check_service_running() {
136 echo "DEBUG: check_service_running with systemctl list-units -full"
137 systemctl list-units --full | grep "afm.*$WGTNAME--"
141 echo "DEBUG: check_service_running with systemctl -a"
142 systemctl -a |grep "afm.*$WGTNAME--"
144 if [ $RUNNING -eq 0 ];then
145 echo "ERROR: inconsistent results"
155 # we need the full name (with -test, -debug etc..) for LAVA test case
156 WGTNAMEF=$(echo $2 | sed 's,.wgt,,')
158 echo "INFO: do_release_test $WGTNAME $wgtfile"
160 echo "DEBUG: list current pkgs"
163 afm-util list --all > $LIST
165 echo "ERROR: afm-util list exit with error"
168 if [ ! -s "$LIST" ];then
169 echo "ERROR: afm-util list is empty"
173 echo "DEBUG: check presence of $WGTNAME"
174 NAMEID=$(grep id\\\":\\\"${WGTNAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
175 if [ ! -z "$NAMEID" ];then
176 echo "DEBUG: $WGTNAME already installed as $NAMEID"
177 # need to kill then deinstall
178 do_afm_util ps --all | grep -q $WGTNAME
180 echo "DEBUG: kill $WGTNAME"
181 do_afm_util kill $WGTNAME
183 echo "ERROR: afm-util kill"
184 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
187 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
190 echo "DEBUG: no need to kill $WGTNAME"
193 echo "DEBUG: deinstall $WGTNAME"
194 afm-util remove $NAMEID
196 echo "ERROR: afm-util remove"
197 #lava-test-case afm-util-remove-$WGTNAMEF --result fail
198 journalctl -b | tail -40
201 lava-test-case afm-util-remove-$WGTNAMEF --result pass
204 echo "DEBUG: $WGTNAME not installed"
208 echo "DEBUG: install $wgtfile"
210 afm-util install $wgtfile > $OUT
212 echo "ERROR: afm-util install"
213 lava-test-case afm-util-install-$WGTNAMEF --result fail
216 lava-test-case afm-util-install-$WGTNAMEF --result pass
218 # message is like \"added\":\"mediaplayer@0.1\"
219 NAMEID=$(grep d\\\":\\\"${WGTNAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
220 if [ -z "$NAMEID" ];then
221 echo "ERROR: Cannot get nameid"
222 echo "DEBUG: ========== DUMPING output =========="
224 echo "DEBUG: ========== END DUMP =========="
227 echo "DEBUG: $WGTNAME is installed as $NAMEID"
229 afm-util list --all > $LIST
231 echo "ERROR: afm-util list exit with error"
234 if [ ! -s "$LIST" ];then
235 echo "ERROR: afm-util list is empty"
238 echo "DEBUG: Verify that $WGTNAME is installed"
239 grep -q $NAMEID $LIST
241 echo "ERROR: $WGTNAME is not installed"
242 # for debugging, give full output
243 echo "DEBUG: start of list"
245 echo "DEBUG: end of list"
248 do_afm_util info $NAMEID
250 echo "ERROR: afm-util info"
251 lava-test-case afm-util-info-$WGTNAMEF --result fail
253 lava-test-case afm-util-info-$WGTNAMEF --result pass
256 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
257 systemctl list-units --full | grep "afm.*$WGTNAME--"
258 echo "DEBUG: check if we see the package with systemctl -a (before start)"
259 systemctl -a |grep "afm.*$WGTNAME--"
261 echo "DEBUG: start $NAMEID"
262 do_afm_util start $NAMEID > "rid"
264 echo "ERROR: afm-util start"
265 lava-test-case afm-util-start-$WGTNAMEF --result fail
269 lava-test-case afm-util-start-$WGTNAMEF --result pass
272 check_service_running $WGTNAME
274 echo "DEBUG: Get RID for $NAMEID"
276 afm-util ps --all > $PSLIST
278 echo "ERROR: afm-util ps"
279 lava-test-case afm-util-ps-$WGTNAMEF --result fail
283 lava-test-case afm-util-ps-$WGTNAMEF --result pass
285 # TODO, compare RID with the list in $PSLIST"
287 if [ "$RID" == 'null' ];then
289 echo "DEBUG: retry start $NAMEID"
290 do_afm_util start $NAMEID > "rid"
292 echo "ERROR: afm-util start"
293 lava-test-case afm-util-start-$WGTNAMEF --result fail
299 if [ "$RID" == 'null' ];then
300 echo "ERROR: RID is null, service fail to start"
301 lava-test-case afm-util-status-$WGTNAMEF --result fail
305 echo "DEBUG: status $NAMEID ($RID)"
306 do_afm_util status $RID
308 echo "ERROR: afm-util status"
309 lava-test-case afm-util-status-$WGTNAMEF --result fail
312 lava-test-case afm-util-status-$WGTNAMEF --result pass
315 echo "DEBUG: kill $NAMEID ($RID)"
316 do_afm_util kill $NAMEID
318 echo "ERROR: afm-util kill"
319 lava-test-case afm-util-kill-$WGTNAMEF --result fail
322 lava-test-case afm-util-kill-$WGTNAMEF --result pass
325 echo "DEBUG: start2 $NAMEID"
326 do_afm_util start $NAMEID > rid
328 echo "ERROR: afm-util start2"
329 lava-test-case afm-util-start2-$WGTNAMEF --result fail
333 lava-test-case afm-util-start2-$WGTNAMEF --result pass
336 if [ "$RID" == 'null' ];then
337 echo "ERROR: RID is null"
341 echo "DEBUG: status2 $NAMEID ($RID)"
342 do_afm_util status $RID
344 echo "ERROR: afm-util status2"
345 lava-test-case afm-util-status2-$WGTNAMEF --result fail
348 lava-test-case afm-util-status2-$WGTNAMEF --result pass
352 WGTNAMES=$(grep -o '[a-z-]*.wgt' index.html | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-test$,,' | sed 's,-coverage$,,' | sort | uniq)
353 for WGTNAME in $WGTNAMES
355 if [ -e $WGTNAME.wgt ];then
356 inspect_wgt $WGTNAME.wgt
357 do_release_test $WGTNAME $WGTNAME.wgt
359 echo "WARN: cannot find $WGTNAME.wgt"
361 if [ -e $WGTNAME-test.wgt ];then
362 # wgt-test do not have the same permissions in the config.xml as the parent wgt
363 # so keep the value from last run
364 #inspect_wgt $WGTNAME-test.wgt
365 check_service_running $WGTNAME
367 do_afm_test $TOPDIR/$WGTNAME-test.wgt
369 lava-test-case run-test-$WGTNAME --result pass
371 lava-test-case run-test-$WGTNAME --result fail
374 echo "DEBUG: $WGTNAME is not running, skipping test"
375 lava-test-case run-test-$WGTNAME --result skip
378 echo "WARN: cannot find $WGTNAME.wgt"
380 if [ -e $WGTNAME-debug.wgt ];then
381 inspect_wgt $WGTNAME-debug.wgt
382 do_release_test $WGTNAME $WGTNAME-debug.wgt
384 if [ -e $WGTNAME-coverage.wgt ];then
385 inspect_wgt $WGTNAME-coverage.wgt
386 echo "DEBUG: coverage not handled yet"