|
| 1 | +# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +#!/bin/bash |
| 16 | + |
| 17 | +set -e |
| 18 | + |
| 19 | +PREFIX="@CMAKE_INSTALL_PREFIX@" |
| 20 | +EXAMPLE_DIR="@PROJECT_BINARY_DIR@/test/dds/communication" |
| 21 | +export EXAMPLE_DIR |
| 22 | + |
| 23 | +echo "[INFO] Starting discovery server" |
| 24 | +"$PREFIX/bin/fastdds" discovery -l 0.0.0.0 & |
| 25 | +SERVER_PID=$! |
| 26 | + |
| 27 | + |
| 28 | +# Publisher |
| 29 | +echo "[INFO] Starting publisher" |
| 30 | +"$EXAMPLE_DIR/DDSCommunicationPublisher" \ |
| 31 | + --xmlfile "$EXAMPLE_DIR/ds_client.xml" \ |
| 32 | + --wait 1 --samples 10 --loops 1 --seed 0 --magic T & |
| 33 | +PUB_PID=$! |
| 34 | + |
| 35 | +# Subscriber |
| 36 | +echo "[INFO] Starting subscriber" |
| 37 | +"$EXAMPLE_DIR/DDSCommunicationSubscriber" \ |
| 38 | + --xmlfile "$EXAMPLE_DIR/ds_client.xml" \ |
| 39 | + --samples 10 --seed 0 --magic T --rescan 2 & |
| 40 | +SUB_PID=$! |
| 41 | + |
| 42 | +sleep 15 |
| 43 | +# Discovery server process must still be running |
| 44 | +if ! kill "$SERVER_PID" 2>/dev/null; then |
| 45 | + echo "[ERROR] Discover server ended unexpectedly" |
| 46 | + exit 1 |
| 47 | +else |
| 48 | + echo "[INFO] Manually killing discovery server. Server execution successful" |
| 49 | +fi |
| 50 | + |
| 51 | +# PUBLISHER and SUBSCRIBER processes must end gracefully |
| 52 | +wait $PUB_PID |
| 53 | +wait $SUB_PID |
| 54 | +echo "[INFO] Test completed successfully" |
0 commit comments