On Wed, Jan 29, 2025 at 03:36:01PM +0100, Anna Emese Nyiri wrote:
> diff --git a/tools/testing/selftests/net/test_so_rcv.sh 
> b/tools/testing/selftests/net/test_so_rcv.sh
> new file mode 100755
> index 000000000000..12d37f9ab905
> --- /dev/null
> +++ b/tools/testing/selftests/net/test_so_rcv.sh
> @@ -0,0 +1,56 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +HOST=127.0.0.1
> +PORT=1234
> +TOTAL_TESTS=0
> +FAILED_TESTS=0
> +
> +declare -A TESTS=(
> +     ["SO_RCVPRIORITY"]="-P 2"
> +     ["SO_RCVMARK"]="-M 3"
> +)
> +
> +check_result() {
> +     ((TOTAL_TESTS++))
> +     if [ "$1" -ne 0 ]; then
> +             ((FAILED_TESTS++))
> +     fi
> +}
> +
> +for test_name in "${!TESTS[@]}"; do
> +     echo "Running $test_name test"
> +     arg=${TESTS[$test_name]}
> +
> +     ./so_rcv_listener $arg $HOST $PORT &
> +     LISTENER_PID=$!
> +
> +     if ./cmsg_sender $arg $HOST $PORT; then

In addition to the other comments, please run both binaries in a
namespace that the test creates at the beginning via setup_ns() (from
lib.sh) and deletes at the end via cleanup_ns().

Thanks for adding the test.

> +             echo "Sender succeeded for $test_name"
> +     else
> +             echo "Sender failed for $test_name"
> +             kill "$LISTENER_PID" 2>/dev/null
> +             wait "$LISTENER_PID"
> +             check_result 1
> +             continue
> +     fi
> +
> +     wait "$LISTENER_PID"
> +     LISTENER_EXIT_CODE=$?
> +
> +     if [ "$LISTENER_EXIT_CODE" -eq 0 ]; then
> +             echo "Rcv test OK for $test_name"
> +             check_result 0
> +     else
> +             echo "Rcv test FAILED for $test_name"
> +             check_result 1
> +     fi
> +done
> +
> +if [ "$FAILED_TESTS" -ne 0 ]; then
> +     echo "FAIL - $FAILED_TESTS/$TOTAL_TESTS tests failed"
> +     exit 1
> +else
> +     echo "OK - All $TOTAL_TESTS tests passed"
> +     exit 0
> +fi
> -- 
> 2.43.0
> 

Reply via email to