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}/*
88 export SERVICE_PLATFORM=0
90 export APPLICATION_USER=0
96 echo "DEBUG: analyse wgt file"
97 unzip $CURDIR/$wgtfile
99 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
100 echo "ERROR: cannot unzip $wgtfile"
102 if [ -f config.xml ];then
103 grep hidden config.xml
105 echo "DEBUG: hidden package"
107 echo "DEBUG: not hidden package"
109 # a service sets urn:AGL:widget:provided-api
110 grep "urn:AGL:widget:provided-api" config.xml
111 if [ $? -eq 0 ] ; then
112 # we are a service, now determine the scope ...
113 grep "urn:AGL:permission::partner:scope-platform" config.xml
115 export SERVICE_PLATFORM=1
117 export SERVICE_USER=1
120 # we are an application
121 export APPLICATION_USER=1
122 # no other type known (yet)
124 # the file naming convention is servicename.wgt
125 # but some didnt respect it
126 export WGTSERVICENAME=$(grep '<name>' config.xml | cut -d'>' -f2 | cut -d'<' -f1)
127 if [ -z "$WGTSERVICENAME" ];then
128 echo "WARN: failed to find name in config.xml, fallback to filename"
129 export WGTSERVICENAME="$WGTNAME"
131 echo "DEBUG: detected service name as $WGTSERVICENAME"
134 echo "DEBUG: fail to unzip"
141 # check if WGTNAME is running
142 check_service_running() {
146 echo "DEBUG: check_service_running with systemctl list-units -full"
147 systemctl list-units --full | grep "afm.*$WGTNAME--"
151 echo "DEBUG: check_service_running with systemctl -a"
152 systemctl -a |grep "afm.*$WGTNAME--"
154 if [ $RUNNING -eq 0 ];then
155 echo "ERROR: inconsistent results"
165 # we need the full name (with -test, -debug etc..) for LAVA test case
166 WGTNAMEF=$(echo $2 | sed 's,.wgt,,')
168 echo "INFO: do_release_test $WGTNAME $wgtfile"
170 echo "DEBUG: list current pkgs"
173 afm-util list --all > $LIST
175 echo "ERROR: afm-util list exit with error"
178 if [ ! -s "$LIST" ];then
179 echo "ERROR: afm-util list is empty"
183 echo "DEBUG: check presence of $WGTNAME"
184 NAMEID=$(grep id\\\":\\\"${WGTSERVICENAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
185 if [ ! -z "$NAMEID" ];then
186 echo "DEBUG: $WGTNAME already installed as $NAMEID"
187 # need to kill then deinstall
188 do_afm_util ps --all | grep -q $WGTNAME
190 echo "DEBUG: kill $WGTNAME"
191 do_afm_util kill $WGTNAME
193 echo "ERROR: afm-util kill"
194 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
197 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
200 echo "DEBUG: no need to kill $WGTNAME"
203 echo "DEBUG: deinstall $WGTNAME"
204 afm-util remove $NAMEID
206 echo "ERROR: afm-util remove"
207 #lava-test-case afm-util-remove-$WGTNAMEF --result fail
208 journalctl -b | tail -40
211 lava-test-case afm-util-remove-$WGTNAMEF --result pass
214 echo "DEBUG: $WGTNAME not installed"
218 echo "DEBUG: install $wgtfile"
220 afm-util install $wgtfile > $OUT
222 echo "ERROR: afm-util install"
223 lava-test-case afm-util-install-$WGTNAMEF --result fail
226 lava-test-case afm-util-install-$WGTNAMEF --result pass
228 # message is like \"added\":\"mediaplayer@0.1\"
229 NAMEID=$(grep d\\\":\\\"${WGTSERVICENAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
230 if [ -z "$NAMEID" ];then
231 echo "ERROR: Cannot get nameid"
232 echo "DEBUG: ========== DUMPING output =========="
234 echo "DEBUG: ========== END DUMP =========="
237 echo "DEBUG: $WGTNAME is installed as $NAMEID"
239 afm-util list --all > $LIST
241 echo "ERROR: afm-util list exit with error"
244 if [ ! -s "$LIST" ];then
245 echo "ERROR: afm-util list is empty"
248 echo "DEBUG: Verify that $WGTNAME is installed"
249 grep -q $NAMEID $LIST
251 echo "ERROR: $WGTNAME is not installed"
252 # for debugging, give full output
253 echo "DEBUG: start of list"
255 echo "DEBUG: end of list"
258 do_afm_util info $NAMEID
260 echo "ERROR: afm-util info"
261 lava-test-case afm-util-info-$WGTNAMEF --result fail
263 lava-test-case afm-util-info-$WGTNAMEF --result pass
266 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
267 systemctl list-units --full | grep "afm.*$WGTNAME--"
268 echo "DEBUG: check if we see the package with systemctl -a (before start)"
269 systemctl -a |grep "afm.*$WGTNAME--"
271 echo "DEBUG: start $NAMEID"
272 do_afm_util start $NAMEID > "rid"
274 echo "ERROR: afm-util start"
275 lava-test-case afm-util-start-$WGTNAMEF --result fail
279 lava-test-case afm-util-start-$WGTNAMEF --result pass
282 check_service_running $WGTNAME
284 echo "DEBUG: Get RID for $NAMEID"
286 afm-util ps --all > $PSLIST
288 echo "ERROR: afm-util ps"
289 lava-test-case afm-util-ps-$WGTNAMEF --result fail
293 lava-test-case afm-util-ps-$WGTNAMEF --result pass
295 # TODO, compare RID with the list in $PSLIST"
297 if [ "$RID" == 'null' ];then
299 echo "DEBUG: retry start $NAMEID"
300 do_afm_util start $NAMEID > "rid"
302 echo "ERROR: afm-util start"
303 lava-test-case afm-util-start-$WGTNAMEF --result fail
309 if [ "$RID" == 'null' ];then
310 echo "ERROR: RID is null, service fail to start"
311 lava-test-case afm-util-status-$WGTNAMEF --result fail
315 echo "DEBUG: status $NAMEID ($RID)"
316 do_afm_util status $RID
318 echo "ERROR: afm-util status"
319 lava-test-case afm-util-status-$WGTNAMEF --result fail
322 lava-test-case afm-util-status-$WGTNAMEF --result pass
325 echo "DEBUG: kill $NAMEID ($RID)"
326 do_afm_util kill $NAMEID
328 echo "ERROR: afm-util kill"
329 lava-test-case afm-util-kill-$WGTNAMEF --result fail
332 lava-test-case afm-util-kill-$WGTNAMEF --result pass
335 echo "DEBUG: start2 $NAMEID"
336 do_afm_util start $NAMEID > rid
338 echo "ERROR: afm-util start2"
339 lava-test-case afm-util-start2-$WGTNAMEF --result fail
343 lava-test-case afm-util-start2-$WGTNAMEF --result pass
346 if [ "$RID" == 'null' ];then
347 echo "ERROR: RID is null"
351 echo "DEBUG: status2 $NAMEID ($RID)"
352 do_afm_util status $RID
354 echo "ERROR: afm-util status2"
355 lava-test-case afm-util-status2-$WGTNAMEF --result fail
358 lava-test-case afm-util-status2-$WGTNAMEF --result pass
362 WGTNAMES=$(grep -o '[a-z-]*.wgt' index.html | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-test$,,' | sed 's,-coverage$,,' | sort | uniq)
363 for WGTNAME in $WGTNAMES
365 if [ -e $WGTNAME.wgt ];then
366 inspect_wgt $WGTNAME.wgt $WGTNAME
367 do_release_test $WGTNAME $WGTNAME.wgt
369 echo "WARN: cannot find $WGTNAME.wgt"
371 if [ -e $WGTNAME-test.wgt ];then
372 # wgt-test do not have the same permissions in the config.xml as the parent wgt
373 # so keep the value from last run
374 #inspect_wgt $WGTNAME-test.wgt
375 check_service_running $WGTNAME
377 do_afm_test $TOPDIR/$WGTNAME-test.wgt
379 lava-test-case run-test-$WGTNAME --result pass
381 lava-test-case run-test-$WGTNAME --result fail
384 echo "DEBUG: $WGTNAME is not running, skipping test"
385 lava-test-case run-test-$WGTNAME --result skip
388 echo "WARN: cannot find $WGTNAME.wgt"
390 if [ -e $WGTNAME-debug.wgt ];then
391 inspect_wgt $WGTNAME-debug.wgt $WGTNAME
392 do_release_test $WGTNAME $WGTNAME-debug.wgt
394 if [ -e $WGTNAME-coverage.wgt ];then
395 inspect_wgt $WGTNAME-coverage.wgt $WGTNAME
396 echo "DEBUG: coverage not handled yet"