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
7FAIL=0
8# Rejecting offer for which there is already a remote offer:
9# * start daemon
10# * start application which offers service
11# * start daemon remotely
12# * start same application which offers the same service again remotely
13#   -> should be rejected as there is already a service instance
14#   running in the network
15
16export VSOMEIP_CONFIGURATION=offer_test_external_slave.json
17# start daemon
18../examples/routingmanagerd/./routingmanagerd &
19PID_VSOMEIPD=$!
20sleep 1
21# Start the services
22./offer_test_service_external 2 &
23PID_SERVICE_TWO=$!
24sleep 1
25
26# Wait until all clients and services are finished
27for job in $PID_SERVICE_TWO
28do
29    # Fail gets incremented if a client exits with a non-zero exit code
30    wait $job || FAIL=$(($FAIL+1))
31done
32
33# kill the services
34kill $PID_VSOMEIPD
35sleep 1
36
37
38
39# Check if everything went well
40if [ $FAIL -eq 0 ]
41then
42    exit 0
43else
44    exit 1
45fi
46