• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (C) 2015-2019 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 routing manager daemon and the
8# clients with one command. This is necessary as ctest - which is used to run
9# the tests - isn't able to start multiple binaries for one testcase. Therefore
10# the testcase simply executes this script. This script then runs the routing
11# manager daemon and the clients and checks if all of them exit successfully.
12
13if [ $# -lt 2 ]; then
14    echo "Error: Please pass a protocol and communication mode to this script."
15    echo "Valid protocols are [UDP,TCP]."
16    echo "Valid communication modes are [sync, async]."
17    echo "For example $> $0 UDP sync"
18    exit 1;
19fi
20
21FAIL=0
22PROTOCOL=$1
23COMMUNICATION_MODE=$2
24
25start_clients(){
26    export VSOMEIP_CONFIGURATION=npdu_test_client_npdu.json
27
28    # Start the routing manager daemon
29    export VSOMEIP_APPLICATION_NAME=npdu_test_routing_manager_daemon_client_side
30    ./npdu_test_rmd_client_side &
31
32    # sleep 1 second to let the RMD startup.
33    sleep 1
34    # Start client 1
35    export VSOMEIP_APPLICATION_NAME=npdu_test_client_one
36    ./npdu_test_client_1 $* &
37
38    # Start client 2
39    export VSOMEIP_APPLICATION_NAME=npdu_test_client_two
40    ./npdu_test_client_2 $* &
41
42    # Start client 3
43    export VSOMEIP_APPLICATION_NAME=npdu_test_client_three
44    ./npdu_test_client_3 $* &
45
46    # Start client 4
47    export VSOMEIP_APPLICATION_NAME=npdu_test_client_four
48    ./npdu_test_client_4 $* &
49}
50
51wait_for_bg_processes(){
52    # Wait until client and service are finished
53    for job in $(jobs -p)
54    do
55        # Fail gets incremented if one of the jobs exit
56        # with a non-zero exit code
57        wait $job || ((FAIL+=1))
58    done
59
60    # Check if everything exited successfully
61    if [ $FAIL -eq 0 ]
62    then
63        echo "All clients exited successfully"
64    else
65        echo "Something went wrong"
66        exit 1
67    fi
68}
69
70
71echo "Contacting services via $PROTOCOL"
72start_clients --$PROTOCOL --max-payload-size $PROTOCOL --$COMMUNICATION_MODE
73wait_for_bg_processes
74
75exit 0
76