From 30022703a0008250e7f9d3709311a74909bcb1b2 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Wed, 18 Dec 2024 19:13:41 +0100 Subject: [PATCH] Fix connection test with asan --- tests/connection_restore.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/connection_restore.py b/tests/connection_restore.py index f5b25f498..e3ed7363f 100644 --- a/tests/connection_restore.py +++ b/tests/connection_restore.py @@ -1,6 +1,7 @@ import subprocess import time import sys +import os import threading ROUTER_INIT_TIMEOUT_S = 3 @@ -11,15 +12,22 @@ ZENOH_PORT = "7447" ROUTER_ARGS = ['-l', f'tcp/0.0.0.0:{ZENOH_PORT}', '--no-multicast-scouting'] +STDBUF_CMD = ["stdbuf", "-o0"] DIR_EXAMPLES = "build/examples" -ACTIVE_CLIENT_COMMAND = ["stdbuf", "-o0", f'{DIR_EXAMPLES}/z_pub', '-e', f'tcp/127.0.0.1:{ZENOH_PORT}'] -PASSIVE_CLIENT_COMMAND = ["stdbuf", "-o0", f'{DIR_EXAMPLES}/z_sub', '-e', f'tcp/127.0.0.1:{ZENOH_PORT}'] +ACTIVE_CLIENT_COMMAND = STDBUF_CMD + [f'{DIR_EXAMPLES}/z_pub', '-e', f'tcp/127.0.0.1:{ZENOH_PORT}'] +PASSIVE_CLIENT_COMMAND = STDBUF_CMD + [f'{DIR_EXAMPLES}/z_sub', '-e', f'tcp/127.0.0.1:{ZENOH_PORT}'] + +LIBASAN_PATH = subprocess.run(["gcc", "-print-file-name=libasan.so"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip() def run_process(command, output_collector, process_list): + env = os.environ.copy() + if LIBASAN_PATH: + env["LD_PRELOAD"] = LIBASAN_PATH + print(f"Run {command}") - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env) process_list.append(process) for line in iter(process.stdout.readline, ''): print("--", line.strip()) @@ -194,7 +202,7 @@ def main(): print("Usage: sudo python3 ./connection_restore.py /path/to/zenohd") sys.exit(1) - router_command = [sys.argv[1]] + ROUTER_ARGS + router_command = STDBUF_CMD + [sys.argv[1]] + ROUTER_ARGS test_connction_drop(router_command) test_router_restart(router_command)