summaryrefslogtreecommitdiff
path: root/test/second_address_tests/conf/second_address_test_slave_starter.sh.in
blob: 8924163b84eca99771d345427430607424a5a29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Copyright (C) 2015-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 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/.

FAIL=0

if [ $# -lt 2 ]
then
    echo "Please pass a operation and communication mode to this script."
    echo "For example: $0 CLIENT UDP"
    echo "Valid operation modes include [SERVICE, CLIENT]"
    echo "Valid communication modes include [UDP, TCP]"
    exit 1
fi

OPERATIONMODE=$1
COMMUNICATIONMODE=$2

# Add second IP address to interface
ip addr add @TEST_IP_SLAVE_SECOND@/32 dev eth0

if [ "$OPERATIONMODE" = "CLIENT" ]; then
    SLAVE_APPLICATION=second_address_test_client
    export VSOMEIP_CONFIGURATION=second_address_test_slave_client.json

elif [ "$OPERATIONMODE" = "SERVICE" ]; then
    SLAVE_APPLICATION=second_address_test_service
    
    if [ "$COMMUNICATIONMODE" = "TCP" ]; then
        export VSOMEIP_CONFIGURATION=second_address_test_slave_service_tcp.json
    elif [ "$COMMUNICATIONMODE" = "UDP" ]; then
        export VSOMEIP_CONFIGURATION=second_address_test_slave_service_udp.json
    fi
fi

../examples/routingmanagerd/./routingmanagerd &
PID_VSOMEIPD=$!

./$SLAVE_APPLICATION $COMMUNICATIONMODE &
PID_SLAVE=$!

# Wait until all slaves are finished
for job in $PID_SLAVE
do
    # Fail gets incremented if a client exits with a non-zero exit code
    echo "waiting for $job"
    wait $job || FAIL=$(($FAIL+1))
done

# kill the services
kill $PID_VSOMEIPD
sleep 1

# Delete second IP address
ip addr del @TEST_IP_SLAVE_SECOND@/32 dev eth0

# Check if everything went well
exit $FAIL