summaryrefslogtreecommitdiffstats
path: root/afm-test.target.sh
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2020-07-16 12:12:02 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2020-07-21 13:33:59 +0000
commitd5345f9f10897d4191deb4444cce6335da60761c (patch)
tree929217c2984fdecb76182b949a2d40dff42416f2 /afm-test.target.sh
parent40eb2753e4fbe2d5a25c0f1c85b8bd5d29e3ea88 (diff)
afm-test: fix kill issues + install from wgt id
- fix kill issues: when a binding finished too quickly, the return of afm-util start can be empty, so it is necessary to test this case - pass argument wgt id: add the way to pass the wgt id instead of the path to the test wgt Bug-AGL: SPEC-3466, SPEC-3457 Signed-off-by: Clément Bénier <clement.benier@iot.bzh> Change-Id: Ia2fb78b25b70c760f05753d669d7bd98fcd8dad7
Diffstat (limited to 'afm-test.target.sh')
-rwxr-xr-xafm-test.target.sh49
1 files changed, 27 insertions, 22 deletions
diff --git a/afm-test.target.sh b/afm-test.target.sh
index 7aa6b2e..1d400c0 100755
--- a/afm-test.target.sh
+++ b/afm-test.target.sh
@@ -22,7 +22,7 @@ trap cleanup SIGTERM SIGINT SIGABRT SIGHUP
function cleanup() {
afm-util kill $pid >&2
- afm-util remove $APP >&2
+ [[ "$WGT" ]] && afm-util remove $APP >&2
rm ${AFM_PLATFORM_RUNDIR}/${APP}.env 2> /dev/null
exit 1
}
@@ -67,16 +67,25 @@ esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
-# check application name passed as first arg
-WGT=$1
-[[ -z "$WGT" ]] && { usage; exit 0;}
-[[ ! -f "$WGT" ]] && { usage; exit 0;}
+function wgt_install {
+ # check application name passed as first arg
+ WGT=$1
+ [[ -z "$WGT" ]] && { usage; exit 0;}
+ [[ ! -f "$WGT" ]] && { usage; exit 0;}
+
+ INSTALL=$(afm-util install $WGT)
+ APP=$(echo $INSTALL | jq -r .added)
+}
+
+if afm-util info $1 &> /dev/null; then
+ APP=$1
+else
+ wgt_install $1
+fi
-INSTALL=$(afm-util install $WGT)
-APP=$(echo $INSTALL | jq -r .added)
AFM_PLATFORM_RUNDIR=/run/platform/debug/
[[ "$APP" == "null" ]] && error "Widget contains error. Abort"
-APP_HOME=${HOME}/app-data/$(echo ${APP} |cut -d'@' -f1)
+APP_HOME=/home/$(id -u)/app-data/$(echo ${APP} |cut -d'@' -f1)
# Clean the old test results
find "${APP_HOME}" -name '*tap' -exec rm -f {} \;
@@ -90,20 +99,16 @@ EOF
# ask appfw to start application
pid=$(afm-util start $APP)
-[[ -z "$pid" || ! -e "/proc/$pid" ]] && error "Failed to start application $APP"
-info "$APP started with pid=$pid"
+[[ -z "$pid" || ! -e "/proc/$pid" ]] || info "$APP started with pid=$pid"
-kill -0 $pid
-RUNNING=$?
-while [[ $RUNNING -eq 0 ]]
-do
- kill -0 $pid 2> /dev/null
- RUNNING=$?
- sleep 0.2
-done
+if [[ "$pid" ]]; then
+ while kill -0 $pid &> /dev/null; do
+ sleep 0.2
+ done
+fi
-# Terminate the App
-afm-util kill $pid > /dev/null
+# Terminate the App if not already dead
+[[ "$pid" && -d /proc/$pid ]] && afm-util kill $pid > /dev/null
find "${APP_HOME}" -name '*tap' -exec \
sed -r -e '/^# (S| +)/d' \
@@ -111,7 +116,7 @@ sed -r -e '/^# (S| +)/d' \
--e 's:^ok +([0-9]+)\t+(.*):PASS\: \1 \2:' \
--e 's:^not ok +([0-9]+)\t+(.*):FAIL\: \1 \2:' {} \;
-afm-util remove $APP > /dev/null
+[[ "$WGT" ]] && afm-util remove $APP > /dev/null
rm ${AFM_PLATFORM_RUNDIR}/${APP}.env 2> /dev/null
-info "$APP killed and removed"
+[[ "$WGT" ]] && info "$APP killed and removed" || info "$APP killed"