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 $*"
42 if [ ! -f index.html ] ; then
43 wget -q $BASEURL -O index.html
45 echo "ERROR: Cannot wget $BASEURL"
50 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
53 # remove extension and the debug state
54 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-test$,,' | sed 's,-coverage$,,')
58 echo "DEBUG: fetch $wgtfile"
60 if [ ! -f $wgtfile ] ; then
61 wget -q $BASEURL/$wgtfile
63 echo "ERROR: wget from $BASEURL/$wgtfile"
71 echo "DEBUG: analyse wgt file"
72 unzip $CURDIR/$wgtfile
74 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
75 echo "ERROR: cannot unzip $wgtfile"
77 if [ -f config.xml ];then
78 grep hidden config.xml
80 echo "DEBUG: hidden package"
82 echo "DEBUG: not hidden package"
84 # a service sets urn:AGL:widget:provided-api
85 grep "urn:AGL:widget:provided-api" config.xml
86 if [ $? -eq 0 ] ; then
87 # we are a service, now determine the scope ...
88 grep "urn:AGL:permission::partner:scope-platform" config.xml
95 # we are an application
97 # no other type known (yet)
100 echo "DEBUG: fail to unzip"
106 echo "DEBUG: list current pkgs"
109 afm-util list --all > $LIST
111 echo "ERROR: afm-util list exit with error"
114 if [ ! -s "$LIST" ];then
115 echo "ERROR: afm-util list is empty"
119 echo "DEBUG: check presence of $WGTNAME"
120 NAMEID=$(grep id\\\":\\\"${WGTNAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
121 if [ ! -z "$NAMEID" ];then
122 echo "DEBUG: $WGTNAME already installed as $NAMEID"
123 # need to kill then deinstall
124 do_afm_util ps --all | grep -q $WGTNAME
126 echo "DEBUG: kill $WGTNAME"
127 do_afm_util kill $WGTNAME
129 echo "ERROR: afm-util kill"
130 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
133 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
136 echo "DEBUG: no need to kill $WGTNAME"
139 echo "DEBUG: deinstall $WGTNAME"
140 afm-util remove $NAMEID
142 echo "ERROR: afm-util remove"
143 #lava-test-case afm-util-remove-$WGTNAME --result fail
144 journalctl -b | tail -40
147 lava-test-case afm-util-remove-$WGTNAME --result pass
150 echo "DEBUG: $WGTNAME not installed"
154 echo "DEBUG: install $wgtfile"
156 afm-util install $wgtfile > $OUT
158 echo "ERROR: afm-util install"
159 lava-test-case afm-util-install-$WGTNAME --result fail
162 lava-test-case afm-util-install-$WGTNAME --result pass
164 # message is like \"added\":\"mediaplayer@0.1\"
165 NAMEID=$(grep d\\\":\\\"${WGTNAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
166 if [ -z "$NAMEID" ];then
167 echo "ERROR: Cannot get nameid"
168 echo "DEBUG: ========== DUMPING output =========="
170 echo "DEBUG: ========== END DUMP =========="
173 echo "DEBUG: $WGTNAME is installed as $NAMEID"
175 afm-util list --all > $LIST
177 echo "ERROR: afm-util list exit with error"
180 if [ ! -s "$LIST" ];then
181 echo "ERROR: afm-util list is empty"
184 echo "DEBUG: Verify that $WGTNAME is installed"
185 grep -q $NAMEID $LIST
187 echo "ERROR: $WGTNAME is not installed"
188 # for debugging, give full output
189 echo "DEBUG: start of list"
191 echo "DEBUG: end of list"
194 do_afm_util info $NAMEID
196 echo "ERROR: afm-util info"
197 lava-test-case afm-util-info-$WGTNAME --result fail
199 lava-test-case afm-util-info-$WGTNAME --result pass
202 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
203 systemctl list-units --full | grep "afm.*$WGTNAME--"
204 echo "DEBUG: check if we see the package with systemctl -a (before start)"
205 systemctl -a |grep "afm.*$WGTNAME--"
207 echo "DEBUG: start $NAMEID"
208 do_afm_util start $NAMEID > "rid"
210 echo "ERROR: afm-util start"
211 lava-test-case afm-util-start-$WGTNAME --result fail
215 lava-test-case afm-util-start-$WGTNAME --result pass
218 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
219 systemctl list-units --full | grep "afm.*$WGTNAME--"
220 echo "DEBUG: check if we see the package with systemctl -a (after start)"
221 systemctl -a |grep "afm.*$WGTNAME--"
223 echo "DEBUG: Get RID for $NAMEID"
225 afm-util ps --all > $PSLIST
227 echo "ERROR: afm-util ps"
228 lava-test-case afm-util-ps-$WGTNAME --result fail
232 lava-test-case afm-util-ps-$WGTNAME --result pass
234 # TODO, compare RID with the list in $PSLIST"
236 if [ "$RID" == 'null' ];then
238 echo "DEBUG: retry start $NAMEID"
239 do_afm_util start $NAMEID > "rid"
241 echo "ERROR: afm-util start"
242 lava-test-case afm-util-start-$WGTNAME --result fail
248 if [ "$RID" == 'null' ];then
249 echo "ERROR: RID is null, service fail to start"
250 lava-test-case afm-util-status-$WGTNAME --result fail
254 echo "DEBUG: status $NAMEID ($RID)"
255 do_afm_util status $RID
257 echo "ERROR: afm-util status"
258 lava-test-case afm-util-status-$WGTNAME --result fail
261 lava-test-case afm-util-status-$WGTNAME --result pass
264 echo "DEBUG: kill $NAMEID ($RID)"
265 do_afm_util kill $NAMEID
267 echo "ERROR: afm-util kill"
268 lava-test-case afm-util-kill-$WGTNAME --result fail
271 lava-test-case afm-util-kill-$WGTNAME --result pass
274 echo "DEBUG: start2 $NAMEID"
275 do_afm_util start $NAMEID > rid
277 echo "ERROR: afm-util start2"
278 lava-test-case afm-util-start2-$WGTNAME --result fail
282 lava-test-case afm-util-start2-$WGTNAME --result pass
285 if [ "$RID" == 'null' ];then
286 echo "ERROR: RID is null"
290 echo "DEBUG: status2 $NAMEID ($RID)"
291 do_afm_util status $RID
293 echo "ERROR: afm-util status2"
294 lava-test-case afm-util-status2-$WGTNAME --result fail
297 lava-test-case afm-util-status2-$WGTNAME --result pass