From d5345f9f10897d4191deb4444cce6335da60761c Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Thu, 16 Jul 2020 12:12:02 +0200 Subject: afm-test: fix kill issues + install from wgt id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Change-Id: Ia2fb78b25b70c760f05753d669d7bd98fcd8dad7 --- afm-test.target.sh | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'afm-test.target.sh') 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" -- cgit 1.2.3-korg