diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-22 17:17:35 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-23 09:48:49 +0200 |
commit | 3be1daaa166fd04bf7870040ca77da3ae1ea02b8 (patch) | |
tree | c8d231af48e9ac4aef032954d854fcff32e22ddd /afm-test.target.sh | |
parent | ee70785b9911e3dad626286277e7c6cdbdc94b79 (diff) |
Add Lava markers on output and select test set
The launch scripts now allow you to select a verb from the test api
to only launch that verb instead of all.
Also using the verb's argument {'lavaOutput':true}, the test framework
adds specific Lava markers.
Reformat the script to accept options instead of only positionnal arguments
Change-Id: I181407ebb192eb67e06d2ed95ee239d6f1a523f3
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'afm-test.target.sh')
-rwxr-xr-x | afm-test.target.sh | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/afm-test.target.sh b/afm-test.target.sh index 5038e74..c6739ae 100755 --- a/afm-test.target.sh +++ b/afm-test.target.sh @@ -23,12 +23,15 @@ trap cleanup SIGTERM SIGINT SIGABRT SIGHUP function cleanup() { afm-util kill $pid >&2 afm-util remove $APP >&2 + rm ${AFM_PLATFORM_RUNDIR}/${APP}.env 2> /dev/null exit 1 } function usage() { cat >&2 << EOF -Usage: $0 <path> +Usage: $0 [-l|--lava] [-v|--verb <verb>] <path> +-l|--lavaoutput: flag that enable Lava test marker to the output. (Default: disabled) +-v|--verb: select a specific verb to launch from the test API. (Default: all) path: path to the test wgt file EOF } @@ -41,6 +44,29 @@ function info() { echo "PASS: $*" >&2 } +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -l|--lavaoutput) + VERBARGS="{'lavaOutput':true}" + shift # past argument + ;; + -v|--verb) + VERBSELECTED="$2" + shift # past argument + shift # past value + ;; + *) + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + # check application name passed as first arg WGT=$1 [[ -z "$WGT" ]] && { usage; exit 0;} @@ -48,9 +74,20 @@ WGT=$1 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) +# Clean the old test results +find "${APP_HOME}" -name '*tap' -exec rm -f {} \; + +# Configure the test launch for a specific verb and args +mkdir -p ${AFM_PLATFORM_RUNDIR} +cat > ${AFM_PLATFORM_RUNDIR}/${APP}.env << EOF +VERBSELECTED="${VERBSELECTED}" +VERBARGS="${VERBARGS}" +EOF + # ask appfw to start application pid=$(afm-util start $APP) [[ -z "$pid" || ! -e "/proc/$pid" ]] && error "Failed to start application $APP" @@ -68,12 +105,12 @@ done # Terminate the App afm-util kill $pid > /dev/null afm-util remove $APP > /dev/null +rm ${AFM_PLATFORM_RUNDIR}/${APP}.env 2> /dev/null -# Little sed script making compliant the output of test results for ptest. find "${APP_HOME}" -name '*tap' -exec \ sed -r -e '/^# (S| +)/d' \ --e '1d' \ --e 's:^ok +([0-9]+)\t+(.*):PASS\: \1 \2:' \ --e 's:^not ok +([0-9]+)\t+(.*):FAIL\: \1 \2:' {} \; +--e '1d' \ +--e 's:^ok +([0-9]+)\t+(.*):PASS\: \1 \2:' \ +--e 's:^not ok +([0-9]+)\t+(.*):FAIL\: \1 \2:' {} \; info "$APP killed and removed" |