aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-20 18:49:44 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-08-22 11:24:29 +0200
commit91d3627b5f737e1b113c52e7364cdf18f174e70f (patch)
tree9a8d4f3a0db54273dfe563602de73441aaaed503
parent68c4abd337246eb03ffab9366764e565820494a3 (diff)
Enhance afm-test script
- Create a cleanup function to be called in case of error - Assume the app home directory to be able to retrieve the test results log file. - Use a sed script to make the output of test results compliant with ptest. Change-Id: I6e3f0ca59a1ca8fc7537955c440a4c55196b9ec6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rwxr-xr-xafm-test24
1 files changed, 18 insertions, 6 deletions
diff --git a/afm-test b/afm-test
index 0be7737..000ab4c 100755
--- a/afm-test
+++ b/afm-test
@@ -18,6 +18,14 @@
# limitations under the License.
###########################################################################
+trap cleanup SIGTERM SIGINT SIGABRT SIGHUP
+
+function cleanup() {
+ afm-util kill $pid >&2
+ afm-util remove $APP >&2
+ exit 1
+}
+
function usage() {
cat >&2 << EOF
Usage: $0 <path>
@@ -26,11 +34,11 @@ EOF
}
function error() {
- echo "ERR: $@" >&2
- exit 1
+ echo "FAIL: $@" >&2
+ cleanup
}
function info() {
- echo "INF: $@" >&2
+ echo "PASS: $@" >&2
}
# check application name passed as first arg
@@ -41,23 +49,27 @@ WGT=$1
INSTALL=$(afm-util install $WGT)
APP=$(echo $INSTALL | jq -r .added)
[[ "$APP" == "null" ]] && error "Widget contains error. Abort"
+APP_HOME=${HOME}/app-data/$(echo ${APP} |cut -d'@' -f1)
# 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"
-ps -ef | grep -v grep | grep -q $pid
+kill -0 $pid
RUNNING=$?
while [[ $RUNNING -eq 0 ]]
do
- ps -ef | grep -v grep | grep -q $pid
+ kill -0 $pid
RUNNING=$?
+ sleep 0.2
done
# Terminate the App
afm-util kill $pid >&2
afm-util remove $APP >&2
-info "$APP killed and removed"
+# Little sed script making compliant the output of test results for ptest.
+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:' ${APP_HOME}/test_results.log
+info "$APP killed and removed"