1#!/bin/bash 2# Copyright (C) 2015-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 3# This Source Code Form is subject to the terms of the Mozilla Public 4# License, v. 2.0. If a copy of the MPL was not distributed with this 5# file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7# Purpose: This script is needed to start the services with 8# one command. This is necessary as ctest - which is used to run the 9# tests - isn't able to start multiple binaries for one testcase. Therefore 10# the testcase simply executes this script. This script then runs the services 11# and checks that all exit successfully. 12 13if [ $# -lt 2 ] 14then 15 echo "Please pass a json file to this script and wether remote clients are allowed or not " 16 echo "For example: $0 security_test_config_client_external_allow.json --allow" 17 exit 1 18fi 19 20MASTER_JSON_FILE=$1 21SERVICE_JSON_FILE=${MASTER_JSON_FILE/client/service} 22ALLOW_DENY=$2 23 24FAIL=0 25 26export VSOMEIP_CONFIGURATION=$1 27export VSOMEIP_APPLICATION_NAME=routingmanagerd 28# start daemon 29../examples/routingmanagerd/./routingmanagerd & 30PID_VSOMEIPD=$! 31 32export VSOMEIP_CONFIGURATION=$1 33export VSOMEIP_APPLICATION_NAME=client-sample 34./security_test_client --remote $2 & 35PID_CLIENT=$! 36 37 38if [ ! -z "$USE_LXC_TEST" ]; then 39 echo "starting external security test on slave LXC" 40 ssh -tt -i $SANDBOX_ROOT_DIR/commonapi_main/lxc-config/.ssh/mgc_lxc/rsa_key_file.pub -o StrictHostKeyChecking=no root@$LXC_TEST_SLAVE_IP "bash -ci \"set -m; cd \\\$SANDBOX_TARGET_DIR/vsomeip_lib/test; ./security_test_external_slave_start.sh $SERVICE_JSON_FILE $2\"" & 41elif [ ! -z "$USE_DOCKER" ]; then 42 docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./security_test_external_slave_start.sh $SERVICE_JSON_FILE $2" & 43elif [ ! -z "$JENKINS" ]; then 44 ssh -tt -i $PRV_KEY -o StrictHostKeyChecking=no jenkins@$IP_SLAVE "bash -ci \"set -m; cd $WS_ROOT/build/test; ./security_test_external_slave_start.sh $SERVICE_JSON_FILE $2\" >> $WS_ROOT/slave_test_output 2>&1" & 45 46else 47cat <<End-of-message 48******************************************************************************* 49******************************************************************************* 50** Please now run: 51** security_test_external_slave_start.sh $SERVICE_JSON_FILE $2 52** from an external host to successfully complete this test. 53** 54** You probably will need to adapt the 'unicast' settings in 55** security_test_config_service_external_allow.json and 56** security_test_config_client_external_allow.json to your personal setup. 57******************************************************************************* 58******************************************************************************* 59End-of-message 60fi 61 62# Wait until client and service are finished 63for client_pid in "${PID_CLIENT}" 64do 65 if [ -n "$client_pid" ]; then 66 # Fail gets incremented if either client or service exit 67 # with a non-zero exit code 68 wait "$client_pid" || ((FAIL+=1)) 69 fi 70done 71 72kill $PID_VSOMEIPD 73kill $PID_CLIENT 74 75# Check if both exited successfully 76if [ $FAIL -eq 0 ] 77then 78 exit 0 79else 80 exit 1 81fi 82