summaryrefslogtreecommitdiff
path: root/NodeStateMachineTest/test/run_test.sh
diff options
context:
space:
mode:
authorMonika Forstner <Monika_Forstner@mentor.com>2020-09-16 10:20:03 +0200
committerMonika Forstner <Monika_Forstner@mentor.com>2020-09-16 10:50:27 +0200
commit2fb502b4bc23aa13fee1db3395b3cae5e34cc871 (patch)
treed9cd2c64522f190500dc53291b4fbcf5100b9720 /NodeStateMachineTest/test/run_test.sh
parent253d10aada6bf5cdfe307aaff55363f08194c85e (diff)
downloadnode-state-manager-release_NSM_CommonAPI.tar.gz
NSM Release 3.0release_NSM_CommonAPI
Diffstat (limited to 'NodeStateMachineTest/test/run_test.sh')
-rwxr-xr-xNodeStateMachineTest/test/run_test.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/NodeStateMachineTest/test/run_test.sh b/NodeStateMachineTest/test/run_test.sh
new file mode 100755
index 0000000..e5158a1
--- /dev/null
+++ b/NodeStateMachineTest/test/run_test.sh
@@ -0,0 +1,68 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# Script to run the NSM Tests
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+#!/bin/bash
+
+BUILD_DIR=$(readlink -f $(dirname $0)/..)
+
+# Make sure test command is given as argument:
+if [ -z $1 ]
+then
+ echo "No test command given."
+ echo "It is recommended to run the tests using ctest."
+ exit 1
+fi
+
+# Set exit handler:
+function on_exit
+{
+ echo "Exiting test script"
+ if [ ! -z $NSM_PID ]
+ then
+ echo "Killing NSM"
+ kill -9 $NSM_PID
+ fi
+}
+trap on_exit EXIT
+
+# Kill running NSM instances:
+pkill -f NodeStateManager
+
+# Delete old temp files:
+rm -rf /tmp/vsomeip*
+rm -rf /tmp/nsm*
+
+# Launch NSM:
+echo "Starting NSM"
+export LD_LIBRARY_PATH=$BUILD_DIR/NodeStateAccess:$BUILD_DIR/NodeStateMachineStub:$LD_LIBRARY_PATH
+$BUILD_DIR/NodeStateManager/NodeStateManager > /tmp/nsm_out 2>&1 & NSM_PID=$!
+sleep 2
+
+# Check if NSM launched successfully:
+ps -p $NSM_PID >/dev/null
+if (( $? != 0 ))
+then
+ echo "ERROR: NSM didn't launch successfully. See /tmp/nsm_out"
+ exit 1
+fi
+
+export WATCHDOG_USEC=1000000
+
+GTEST_OUTPUT_PREFIX=xml:/tmp/
+export GTEST_OUTPUT=${GTEST_OUTPUT_PREFIX}nsm_test_result_${1}.xml
+
+# Launch test command given as argument:
+echo "Running test \"$1\""
+$1
+exit $?