Skip to content

Commit 60483b5

Browse files
gh #98 Updated httpserver up logic in ut_control_test.sh
1 parent 155307c commit 60483b5

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

tests/src/ut_control_test.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,26 @@ cd "$(dirname "$0")"
2727

2828
export LD_LIBRARY_PATH=/usr/lib:/lib:/home/root:${MY_DIR}
2929

30-
# Start HTTP server in background
31-
python3 -m http.server 8000 &
32-
HTTP_PID=$!
33-
34-
# Register cleanup trap to stop HTTP server on exit
35-
trap '
36-
kill $HTTP_PID 2>/dev/null || true
37-
wait $HTTP_PID 2>/dev/null || true
38-
' EXIT
30+
HTTP_PORT=8000
31+
HTTP_PID=""
32+
33+
# Check if HTTP server is already running
34+
if ! lsof -iTCP:${HTTP_PORT} -sTCP:LISTEN >/dev/null 2>&1; then
35+
python3 -m http.server ${HTTP_PORT} &
36+
HTTP_PID=$!
37+
fi
38+
39+
# Cleanup only if this script started the server
40+
cleanup() {
41+
if [[ -n "$HTTP_PID" ]]; then
42+
kill "$HTTP_PID" 2>/dev/null || true
43+
wait "$HTTP_PID" 2>/dev/null || true
44+
fi
45+
}
46+
trap cleanup EXIT
3947

4048
# Run test
41-
./ut_control_test "$@"
49+
LSAN_OPTIONS="suppressions=../../lsan.supp print_suppressions=1" ./ut_control_test "$@"
4250
UT_STATUS=$?
4351

44-
# Exit with same status as UT test
45-
exit $UT_STATUS
52+
exit $UT_STATUS

0 commit comments

Comments
 (0)