From 5ce9345f3835170a0d021b70fde844a69cfd8b38 Mon Sep 17 00:00:00 2001 From: AlexWells Date: Tue, 17 Sep 2024 15:45:50 +0100 Subject: [PATCH] Add logging to problematic test --- tests/conftest.py | 2 +- tests/sim_cothread_ioc.py | 9 +++++++++ tests/test_cothread.py | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 66ab41ee..5eb86769 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,7 +42,7 @@ def create_random_prefix(): return "".join(random.choice(string.ascii_uppercase) for _ in range(12)) # Can't use logging as it's not multiprocess safe, and -# alteratives are overkill +# alternatives are overkill def log(*args): print(datetime.now().strftime("%H:%M:%S"), *args) diff --git a/tests/sim_cothread_ioc.py b/tests/sim_cothread_ioc.py index fd54f838..e7e67336 100644 --- a/tests/sim_cothread_ioc.py +++ b/tests/sim_cothread_ioc.py @@ -7,6 +7,7 @@ from conftest import ADDRESS, log, select_and_recv if __name__ == "__main__": + log("sim_cothread_ioc starting") with Client(ADDRESS) as conn: import cothread @@ -18,16 +19,24 @@ import sim_records + log("sim_cothread_ioc records created") + # Run the IOC builder.LoadDatabase() softioc.iocInit() + log("sim_cothread_ioc ready") + conn.send("R") # "Ready" + log("sim_cothread_ioc waiting for Done") + select_and_recv(conn, "D") # "Done" # Attempt to ensure all buffers flushed - C code (from `import pvlog`) # may not be affected by these calls... sys.stdout.flush() sys.stderr.flush() + log("sim_cothread_ioc sending Done") + conn.send("D") # "Ready" diff --git a/tests/test_cothread.py b/tests/test_cothread.py index 51cb9d20..3586c9ca 100644 --- a/tests/test_cothread.py +++ b/tests/test_cothread.py @@ -2,7 +2,7 @@ from multiprocessing.connection import Listener -from conftest import requires_cothread, ADDRESS, select_and_recv +from conftest import requires_cothread, ADDRESS, log, select_and_recv @requires_cothread def test_cothread_ioc(cothread_ioc): @@ -12,8 +12,9 @@ def test_cothread_ioc(cothread_ioc): pre = cothread_ioc.pv_prefix with Listener(ADDRESS) as listener, listener.accept() as conn: - + log("test_cothread_ioc wait for Ready") select_and_recv(conn, "R") # "Ready" + log("test_cothread_ioc Ready received") # Start assert caget(pre + ":UPTIME").startswith("00:00:0") @@ -31,9 +32,12 @@ def test_cothread_ioc(cothread_ioc): with Context("pva") as ctx: assert ctx.get(pre + ":STRINGOUT") == "something" + log("test_cothread_ioc sending Done") conn.send("D") # "Done" + log("test_cothread_ioc waiting for Done") select_and_recv(conn, "D") # "Done" + log("test_cothread_ioc received Done") # Stop cothread_ioc.proc.send_signal(signal.SIGINT)