• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 1 ]
14then
15    echo "Please pass a json file to this script"
16    echo "For example: $0 e2e_test_client_external.json"
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=client-sample
28./e2e_test_client --remote &
29PID_CLIENT=$!
30
31
32if [ ! -z "$USE_LXC_TEST" ]; then
33    echo "starting external e2e test on slave LXC"
34    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; ./e2e_test_external_slave_start.sh $SERVICE_JSON_FILE\"" &
35elif [ ! -z "$USE_DOCKER" ]; then
36    docker exec $DOCKER_IMAGE sh -c "cd $DOCKER_TESTS && ./e2e_test_external_slave_start.sh $SERVICE_JSON_FILE" &
37elif [ ! -z "$JENKINS" ]; then
38    ssh -tt -i $PRV_KEY -o StrictHostKeyChecking=no jenkins@$IP_SLAVE "bash -ci \"set -m; cd $WS_ROOT/build/test; ./e2e_test_external_slave_start.sh $SERVICE_JSON_FILE\" >> $WS_ROOT/slave_test_output 2>&1" &
39
40else
41cat <<End-of-message
42*******************************************************************************
43*******************************************************************************
44** Please now run:
45** e2e_test_external_slave_start.sh $SERVICE_JSON_FILE
46** from an external host to successfully complete this test.
47**
48** You probably will need to adapt the 'unicast' settings in
49** e2e_test_service_external.json and
50** e2e_test_client_external.json to your personal setup.
51*******************************************************************************
52*******************************************************************************
53End-of-message
54fi
55
56# Wait until client and service are finished
57for client_pid in "${PID_CLIENT}"
58do
59    if [ -n "$client_pid" ]; then
60        # Fail gets incremented if either client or service exit
61        # with a non-zero exit code
62        wait "$client_pid" || ((FAIL+=1))
63    fi
64done
65
66kill $PID_CLIENT
67
68# Check if both exited successfully
69if [ $FAIL -eq 0 ]
70then
71    exit 0
72else
73    exit 1
74fi
75