From 5a23b82a9b1fb20039c9fa655b51b1e7f8ccbae1 Mon Sep 17 00:00:00 2001 From: Fredrik Olsson Date: Fri, 23 Jun 2023 06:48:55 +0200 Subject: [PATCH] We need to bind to the mcast group address in the call to socat to only get packets for the specific group, otherwise we get packets for all groups on the specific port. --- bash-init.sh | 2 +- tests/test_porla.bats | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bash-init.sh b/bash-init.sh index 6852262..479ebe1 100644 --- a/bash-init.sh +++ b/bash-init.sh @@ -8,7 +8,7 @@ function to_bus () { export to_bus function from_bus () { - socat "UDP4-RECV:12737,reuseaddr,ip-add-membership=239.111.42.$1:0.0.0.0" STDOUT + socat "UDP4-RECV:12737,bind=239.111.42.$1,reuseaddr,ip-add-membership=239.111.42.$1:0.0.0.0" STDOUT } export from_bus diff --git a/tests/test_porla.bats b/tests/test_porla.bats index 93d251d..f545e2a 100644 --- a/tests/test_porla.bats +++ b/tests/test_porla.bats @@ -37,3 +37,18 @@ teardown() { assert cmp --silent "$TMP_DIR"/test.txt "$TMP_DIR"/out.txt } + +@test "Single writer/listener|writer/listener chain on bus" { + bats_require_minimum_version 1.5.0 + + docker run -d -v "$TMP_DIR":/recordings --network=host porla "from_bus 37 | record /recordings/out.txt" + + docker run -d -v "$TMP_DIR":/recordings --network=host porla "from_bus 36 | to_bus 37" + + docker run -v "$TMP_DIR":/recordings --network=host porla "cat /recordings/test.txt | to_bus 36" + + assert_exists "$TMP_DIR"/out.txt + + assert cmp --silent "$TMP_DIR"/test.txt "$TMP_DIR"/out.txt + +}