1#!/bin/bash
2# Copyright (C) 2015-2017 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 client_id_test_diff_client_ids_diff_ports_slave.json"
17    exit 1
18fi
19
20FAIL=0
21
22# Start the services
23export VSOMEIP_APPLICATION_NAME=client_id_test_service_four
24export VSOMEIP_CONFIGURATION=$1
25./client_id_test_service 4 &
26
27export VSOMEIP_APPLICATION_NAME=client_id_test_service_five
28export VSOMEIP_CONFIGURATION=$1
29./client_id_test_service 5 &
30
31export VSOMEIP_APPLICATION_NAME=client_id_test_service_six
32export VSOMEIP_CONFIGURATION=$1
33./client_id_test_service 6 &
34
35
36# Wait until all applications are finished
37for job in $(jobs -p)
38do
39    # Fail gets incremented if one of the binaries exits
40    # with a non-zero exit code
41    wait $job || ((FAIL+=1))
42done
43
44# Check if both exited successfully
45if [ $FAIL -eq 0 ]
46then
47    exit 0
48else
49    exit 1
50fi
51