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 "aft-test $*"
53 if [ ! -f index.html ] ; then
54 wget -q $BASEURL -O index.html
56 echo "ERROR: Cannot wget $BASEURL"
61 WGTNAME="$(grep -o '[a-z-]*.wgt' index.html | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-coverage$,,' | sed 's,-test$,,' | uniq)"
63 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
66 # remove extension and the debug state
67 #export WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,' | sed 's,-debug$,,' | sed 's,-coverage$,,' | sed 's,-test$,,')
68 echo "DEBUG: fetch $wgtfile"
70 if [ ! -f $wgtfile ] ; then
71 wget -q $BASEURL/$wgtfile
73 echo "ERROR: wget from $BASEURL/$wgtfile"
89 echo "DEBUG: analyse wgt file"
90 unzip $CURDIR/$wgtfile
92 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
93 echo "ERROR: cannot unzip $wgtfile"
95 if [ -f config.xml ];then
96 grep hidden config.xml
98 echo "DEBUG: hidden package"
100 echo "DEBUG: not hidden package"
102 # a service sets urn:AGL:widget:provided-api
103 grep "urn:AGL:widget:provided-api" config.xml
104 if [ $? -eq 0 ] ; then
105 # we are a service, now determine the scope ...
106 grep "urn:AGL:permission::partner:scope-platform" config.xml
108 export SERVICE_PLATFORM=1
110 export SERVICE_USER=1
113 # we are an application
114 export APPLICATION_USER=1
115 # no other type known (yet)
118 echo "DEBUG: fail to unzip"
127 # a) (release).wgt -> lifecycle
128 # b) -test.wgt -> run afm-test $wgt
129 # later: c) -coverage wgt -> install coverage AND run afm-test $wgt
130 for RUNIT in runrelease runtest ; do
136 if [ x"runrelease" = x"$RUNIT" ] ; then
137 eval wgtfile="${WGTNAME}.wgt"
140 echo "DEBUG: list current pkgs"
143 afm-util list --all > $LIST
145 echo "ERROR: afm-util list exit with error"
148 if [ ! -s "$LIST" ];then
149 echo "ERROR: afm-util list is empty"
153 echo "DEBUG: check presence of $WGTNAME"
154 NAMEID=$(grep id\\\":\\\"${WGTNAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
155 if [ ! -z "$NAMEID" ];then
156 echo "DEBUG: $WGTNAME already installed as $NAMEID"
157 # need to kill then deinstall
158 do_afm_util ps --all | grep -q $WGTNAME
160 echo "DEBUG: kill $WGTNAME"
161 do_afm_util kill $WGTNAME
163 echo "ERROR: afm-util kill"
164 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
167 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
170 echo "DEBUG: no need to kill $WGTNAME"
173 echo "DEBUG: deinstall $WGTNAME"
174 afm-util remove $NAMEID
176 echo "ERROR: afm-util remove"
177 #lava-test-case afm-util-remove-$WGTNAME --result fail
178 journalctl -b | tail -40
181 lava-test-case afm-util-remove-$WGTNAME --result pass
184 echo "DEBUG: $WGTNAME not installed"
188 echo "DEBUG: install $wgtfile"
190 afm-util install $wgtfile > $OUT
192 echo "ERROR: afm-util install"
193 lava-test-case afm-util-install-$WGTNAME --result fail
196 lava-test-case afm-util-install-$WGTNAME --result pass
198 # message is like \"added\":\"mediaplayer@0.1\"
199 NAMEID=$(grep d\\\":\\\"${WGTNAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
200 if [ -z "$NAMEID" ];then
201 echo "ERROR: Cannot get nameid"
202 echo "DEBUG: ========== DUMPING output =========="
204 echo "DEBUG: ========== END DUMP =========="
207 echo "DEBUG: $WGTNAME is installed as $NAMEID"
209 afm-util list --all > $LIST
211 echo "ERROR: afm-util list exit with error"
214 if [ ! -s "$LIST" ];then
215 echo "ERROR: afm-util list is empty"
218 echo "DEBUG: Verify that $WGTNAME is installed"
219 grep -q $NAMEID $LIST
221 echo "ERROR: $WGTNAME is not installed"
222 # for debugging, give full output
223 echo "DEBUG: start of list"
225 echo "DEBUG: end of list"
228 do_afm_util info $NAMEID
230 echo "ERROR: afm-util info"
231 lava-test-case afm-util-info-$WGTNAME --result fail
233 lava-test-case afm-util-info-$WGTNAME --result pass
236 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
237 systemctl list-units --full | grep "afm.*$WGTNAME--"
238 echo "DEBUG: check if we see the package with systemctl -a (before start)"
239 systemctl -a |grep "afm.*$WGTNAME--"
241 echo "DEBUG: start $NAMEID"
242 do_afm_util start $NAMEID > "rid"
244 echo "ERROR: afm-util start"
245 lava-test-case afm-util-start-$WGTNAME --result fail
249 lava-test-case afm-util-start-$WGTNAME --result pass
252 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
253 systemctl list-units --full | grep "afm.*$WGTNAME--"
254 echo "DEBUG: check if we see the package with systemctl -a (after start)"
255 systemctl -a |grep "afm.*$WGTNAME--"
257 echo "DEBUG: Get RID for $NAMEID"
259 afm-util ps --all > $PSLIST
261 echo "ERROR: afm-util ps"
262 lava-test-case afm-util-ps-$WGTNAME --result fail
266 lava-test-case afm-util-ps-$WGTNAME --result pass
268 # TODO, compare RID with the list in $PSLIST"
270 if [ "$RID" == 'null' ];then
272 echo "DEBUG: retry start $NAMEID"
273 do_afm_util start $NAMEID > "rid"
275 echo "ERROR: afm-util start"
276 lava-test-case afm-util-start-$WGTNAME --result fail
282 if [ "$RID" == 'null' ];then
283 echo "ERROR: RID is null, service fail to start"
284 lava-test-case afm-util-status-$WGTNAME --result fail
288 echo "DEBUG: status $NAMEID ($RID)"
289 do_afm_util status $RID
291 echo "ERROR: afm-util status"
292 lava-test-case afm-util-status-$WGTNAME --result fail
295 lava-test-case afm-util-status-$WGTNAME --result pass
298 echo "DEBUG: kill $NAMEID ($RID)"
299 do_afm_util kill $NAMEID
301 echo "ERROR: afm-util kill"
302 lava-test-case afm-util-kill-$WGTNAME --result fail
305 lava-test-case afm-util-kill-$WGTNAME --result pass
308 echo "DEBUG: start2 $NAMEID"
309 do_afm_util start $NAMEID > rid
311 echo "ERROR: afm-util start2"
312 lava-test-case afm-util-start2-$WGTNAME --result fail
316 lava-test-case afm-util-start2-$WGTNAME --result pass
319 if [ "$RID" == 'null' ];then
320 echo "ERROR: RID is null"
324 echo "DEBUG: status2 $NAMEID ($RID)"
325 do_afm_util status $RID
327 echo "ERROR: afm-util status2"
328 lava-test-case afm-util-status2-$WGTNAME --result fail
331 lava-test-case afm-util-status2-$WGTNAME --result pass
334 if [ x"runtest" = x"$RUNIT" ] ; then
335 eval wgtfile="${WGTNAME}-test.wgt"
338 journalctl -b | grep ${WGTNAME}-test
339 ( journalctl -b | grep ${WGTNAME}-test | grep ERROR ) || true