aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-17 11:57:52 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-17 11:57:52 +0100
commit48a9df043df64887cb99e03d7613379c947d11d8 (patch)
tree897d94bcc55c481a82878c5d2de5ec3369df33ed /tests
parenta54421dd976fd8081e96c11c2621076876c9986b (diff)
downloadBobinkCOpcUa-48a9df043df64887cb99e03d7613379c947d11d8.tar.gz
BobinkCOpcUa-48a9df043df64887cb99e03d7613379c947d11d8.zip
Add configurable log level as optional CLI argument
All three programs now accept an optional second argument [log-level] (trace, debug, info, warning, error, fatal) defaulting to info. The level is applied by setting the logger context pointer directly, avoiding a memory leak that would occur from overwriting the heap-allocated logger struct. Also documents the ASan leak-check workflow in CLAUDE.md.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run_test.sh46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/run_test.sh b/tests/run_test.sh
index 5173fa3..8a87824 100755
--- a/tests/run_test.sh
+++ b/tests/run_test.sh
@@ -29,18 +29,18 @@ FAILURES=0
# ── cleanup ────────────────────────────────────────────────────
cleanup() {
- [ -n "$LDS_PID" ] && kill "$LDS_PID" 2>/dev/null && wait "$LDS_PID" 2>/dev/null
- [ -n "$SR_PID" ] && kill "$SR_PID" 2>/dev/null && wait "$SR_PID" 2>/dev/null
- [ -n "$TMPFILE" ] && rm -f "$TMPFILE"
+ [ -n "$LDS_PID" ] && kill "$LDS_PID" 2>/dev/null && wait "$LDS_PID" 2>/dev/null
+ [ -n "$SR_PID" ] && kill "$SR_PID" 2>/dev/null && wait "$SR_PID" 2>/dev/null
+ [ -n "$TMPFILE" ] && rm -f "$TMPFILE"
}
trap cleanup EXIT
# ── port check ─────────────────────────────────────────────────
for port in $LDS_PORT $SR_PORT; do
- if ss -tlnp 2>/dev/null | grep -q ":${port} "; then
- echo "FAIL: port $port is already in use"
- exit 1
- fi
+ if ss -tlnp 2>/dev/null | grep -q ":${port} "; then
+ echo "FAIL: port $port is already in use"
+ exit 1
+ fi
done
# ── start LDS ──────────────────────────────────────────────────
@@ -48,8 +48,8 @@ build/ServerLDS "$CONFIG_DIR/server_lds.conf" >/dev/null 2>&1 &
LDS_PID=$!
sleep 2
if ! kill -0 "$LDS_PID" 2>/dev/null; then
- echo "FAIL: ServerLDS exited prematurely"
- exit 1
+ echo "FAIL: ServerLDS exited prematurely"
+ exit 1
fi
# ── start ServerRegister ───────────────────────────────────────
@@ -57,8 +57,8 @@ build/ServerRegister "$CONFIG_DIR/server_register.conf" >/dev/null 2>&1 &
SR_PID=$!
sleep 3
if ! kill -0 "$SR_PID" 2>/dev/null; then
- echo "FAIL: ServerRegister exited prematurely"
- exit 1
+ echo "FAIL: ServerRegister exited prematurely"
+ exit 1
fi
# ── run client ─────────────────────────────────────────────────
@@ -70,13 +70,13 @@ CLIENT_OUTPUT=$(<"$TMPFILE")
# ── validation checks ─────────────────────────────────────────
check() {
- local label="$1" result="$2"
- if [ "$result" -eq 0 ]; then
- echo "PASS: $label"
- else
- echo "FAIL: $label"
- FAILURES=$((FAILURES + 1))
- fi
+ local label="$1" result="$2"
+ if [ "$result" -eq 0 ]; then
+ echo "PASS: $label"
+ else
+ echo "FAIL: $label"
+ FAILURES=$((FAILURES + 1))
+ fi
}
# 1. Exit code
@@ -97,10 +97,10 @@ check "endpoint contains $EXPECTED_POLICY" $?
# ── result ─────────────────────────────────────────────────────
if [ "$FAILURES" -ne 0 ]; then
- echo ""
- echo "--- client output ---"
- echo "$CLIENT_OUTPUT"
- echo "--- end ---"
- exit 1
+ echo ""
+ echo "--- client output ---"
+ echo "$CLIENT_OUTPUT"
+ echo "--- end ---"
+ exit 1
fi
exit 0