summaryrefslogtreecommitdiffstats
path: root/afm-test
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-08-01 17:53:21 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-08-16 13:52:02 +0000
commit01343266b1d75f75f1b3271d79323094dc400be5 (patch)
tree77f87ba9b5b6487b1a4abbb0cec0169c8ac2d063 /afm-test
parentf8129b73691310f4576c7033310d59d4b80fefb3 (diff)
Added afm-test script
This script will be in charge of launching the test binding app. Change-Id: I34d74d173f9f00d916a61b912b0e285b350ead99 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'afm-test')
-rwxr-xr-xafm-test63
1 files changed, 63 insertions, 0 deletions
diff --git a/afm-test b/afm-test
new file mode 100755
index 0000000..0be7737
--- /dev/null
+++ b/afm-test
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+###########################################################################
+# Copyright (C) 2017, 2018 IoT.bzh
+#
+# Author: Romain Forlot <romain.forlot@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+ function usage() {
+cat >&2 << EOF
+Usage: $0 <path>
+path: path to the test wgt file
+EOF
+}
+
+function error() {
+ echo "ERR: $@" >&2
+ exit 1
+}
+function info() {
+ echo "INF: $@" >&2
+}
+
+# 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)
+[[ "$APP" == "null" ]] && error "Widget contains error. Abort"
+
+# 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
+RUNNING=$?
+while [[ $RUNNING -eq 0 ]]
+do
+ ps -ef | grep -v grep | grep -q $pid
+ RUNNING=$?
+done
+
+# Terminate the App
+afm-util kill $pid >&2
+afm-util remove $APP >&2
+
+info "$APP killed and removed"
+