From 3758177bf8c8a7f3c3a2789ad396a97fce16b196 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 15 May 2020 10:41:14 +0200 Subject: [PATCH] mdns-example: fail gracefully if mdns response not received within timeout If mdns answer hasn't been received within timeout, Value error would be raised, but the mdns-server-thread would still run, blocking CI jobs. Fixed by moving the raise statement within try-finally block --- examples/protocols/mdns/mdns_example_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/protocols/mdns/mdns_example_test.py b/examples/protocols/mdns/mdns_example_test.py index c6c356f9e..acd29ae72 100644 --- a/examples/protocols/mdns/mdns_example_test.py +++ b/examples/protocols/mdns/mdns_example_test.py @@ -117,11 +117,11 @@ def test_examples_protocol_mdns(env, extra_data): stop_mdns_server.set() thread1.join() raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP') - # 3. check the mdns name is accessible - if not esp_answered.wait(timeout=30): - raise ValueError('Test has failed: did not receive mdns answer within timeout') - # 4. check DUT output if mdns advertized host is resolved try: + # 3. check the mdns name is accessible + if not esp_answered.wait(timeout=30): + raise ValueError('Test has failed: did not receive mdns answer within timeout') + # 4. check DUT output if mdns advertized host is resolved dut1.expect(re.compile(r"mdns-test: Query A: tinytester.local resolved to: 127.0.0.1"), timeout=30) dut1.expect(re.compile(r"mdns-test: gethostbyname: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30) dut1.expect(re.compile(r"mdns-test: getaddrinfo: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30)