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# services 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 services and checks if all of them exit successfully. 12 13FAIL=0 14 15start_services(){ 16 export VSOMEIP_CONFIGURATION=npdu_test_service_npdu.json 17 18 # Start the routing manager daemon 19 export VSOMEIP_APPLICATION_NAME=npdu_test_routing_manager_daemon_service_side 20 ./npdu_test_rmd_service_side & 21 22 # sleep 1 second to let the RMD startup. 23 sleep 1 24 25 # Start service 1 26 export VSOMEIP_APPLICATION_NAME=npdu_test_service_one 27 ./npdu_test_service_1 $* & 28 29 # Start service 2 30 export VSOMEIP_APPLICATION_NAME=npdu_test_service_two 31 ./npdu_test_service_2 $* & 32 33 # Start service 3 34 export VSOMEIP_APPLICATION_NAME=npdu_test_service_three 35 ./npdu_test_service_3 $* & 36 37 # Start service 4 38 export VSOMEIP_APPLICATION_NAME=npdu_test_service_four 39 ./npdu_test_service_4 $* & 40} 41 42wait_for_bg_processes(){ 43 # Wait until client and service are finished 44 for job in $(jobs -p) 45 do 46 # Fail gets incremented if one of the jobs exit 47 # with a non-zero exit code 48 wait $job || ((FAIL+=1)) 49 done 50 51 # Check if everything exited successfully 52 if [ $FAIL -eq 0 ] 53 then 54 echo "All services exited successfully" 55 else 56 echo "Something went wrong" 57 exit 1 58 fi 59} 60 61start_services 62wait_for_bg_processes 63 64exit 0 65