From f3648fefe040152bb1676d651ebf7d836cb8ac9e Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Thu, 19 Feb 2026 00:01:18 +0100 Subject: Refactor: reduce duplication and tighten helpers - Remove redundant applicationUri log in print_application_description - Use UA_SECURITY_POLICY_NONE_URI macro instead of hardcoded string - Extract _s_register_with_lds / _s_deregister_from_lds helpers - Rename signal handler param 'sign' to 'sig' for consistency - Add INT_MIN/INT_MAX bounds check to config_require_int - Extract shared test helpers into tests/test_helpers.sh --- tests/run_download_cert_test.sh | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'tests/run_download_cert_test.sh') diff --git a/tests/run_download_cert_test.sh b/tests/run_download_cert_test.sh index 3631c56..7dd7dfd 100755 --- a/tests/run_download_cert_test.sh +++ b/tests/run_download_cert_test.sh @@ -12,13 +12,14 @@ # --------------------------------------------------------------- set -uo pipefail +source "$(dirname "$0")/test_helpers.sh" + CONFIG_DIR="${1:?Usage: $0 }" LDS_PORT=14840 LDS_PID="" TMPFILE="" DOWNLOADED_CERT="" -FAILURES=0 # ── cleanup ──────────────────────────────────────────────────── cleanup() { @@ -28,39 +29,7 @@ cleanup() { } trap cleanup EXIT -# ── helpers ──────────────────────────────────────────────────── -wait_for_port() { - local port="$1" pid="$2" label="$3" i=0 - while [ $i -lt 50 ]; do - if ! kill -0 "$pid" 2>/dev/null; then - echo "FAIL: $label exited prematurely" - exit 1 - fi - if ss -tlnp 2>/dev/null | grep -q ":${port} "; then - return 0 - fi - sleep 0.1 - i=$((i + 1)) - done - echo "FAIL: $label did not listen on port $port within 5 s" - exit 1 -} - -check() { - local label="$1" result="$2" - if [ "$result" -eq 0 ]; then - echo "PASS: $label" - else - echo "FAIL: $label" - FAILURES=$((FAILURES + 1)) - fi -} - -# ── port check ───────────────────────────────────────────────── -if ss -tlnp 2>/dev/null | grep -q ":${LDS_PORT} "; then - echo "FAIL: port $LDS_PORT is already in use" - exit 1 -fi +assert_ports_free "$LDS_PORT" # ── start LDS ────────────────────────────────────────────────── build/bobink_opcua_discovery_server "$CONFIG_DIR/server_lds.conf" >/dev/null 2>&1 & -- cgit v1.2.3