From a9ed589501a89a359f4c30b184f3d611ba0fa4da Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 19 Jul 2022 11:03:16 +0800 Subject: [PATCH] ci: fixed flakey light sleep example test A wake-up from timer would trigger before the gpio wakeup in certain cases, failing the test. Change the regex to only expect the GPIO wakeup, so that even if there is an extra timer wakeup it wont fail the test. --- examples/system/light_sleep/pytest_light_sleep.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/system/light_sleep/pytest_light_sleep.py b/examples/system/light_sleep/pytest_light_sleep.py index ea99aefe50..4f9025aa59 100644 --- a/examples/system/light_sleep/pytest_light_sleep.py +++ b/examples/system/light_sleep/pytest_light_sleep.py @@ -18,6 +18,8 @@ def test_light_sleep(dut: Dut) -> None: ENTERING_SLEEP_STR = 'Entering light sleep' EXIT_SLEEP_REGEX = r'Returned from light sleep, reason: (\w+), t=(\d+) ms, slept for (\d+) ms' + EXIT_SLEEP_PIN_REGEX = r'Returned from light sleep, reason: (pin), t=(\d+) ms, slept for (\d+) ms' + EXIT_SLEEP_UART_REGEX = r'Returned from light sleep, reason: (uart), t=(\d+) ms, slept for (\d+) ms' WAITING_FOR_GPIO_STR = r'Waiting for GPIO\d to go high...' WAKEUP_INTERVAL_MS = 2000 @@ -44,9 +46,9 @@ def test_light_sleep(dut: Dut) -> None: logging.info('Pulling GPIO0 low using DTR') dut.serial.proc.setDTR(True) time.sleep(1) - match = dut.expect(EXIT_SLEEP_REGEX) + match = dut.expect(EXIT_SLEEP_PIN_REGEX) logging.info('Got third sleep period, wakeup from {}, slept for {}'.format(match.group(1), match.group(3))) - assert(match.group(1).decode('utf8') == 'pin' and int(match.group(3)) < WAKEUP_INTERVAL_MS) + assert(int(match.group(3)) < WAKEUP_INTERVAL_MS) dut.expect(WAITING_FOR_GPIO_STR) logging.info('Is waiting for GPIO...') @@ -58,9 +60,9 @@ def test_light_sleep(dut: Dut) -> None: # Write 'U' to uart, 'U' in ascii is 0x55 which contains 8 edges in total dut.write('U') time.sleep(1) - match = dut.expect(EXIT_SLEEP_REGEX) + match = dut.expect(EXIT_SLEEP_UART_REGEX) logging.info('Got third sleep period, wakeup from {}, slept for {}'.format(match.group(1), match.group(3))) - assert(match.group(1).decode('utf8') == 'uart' and int(match.group(3)) < WAKEUP_INTERVAL_MS) + assert(int(match.group(3)) < WAKEUP_INTERVAL_MS) logging.info('Went to sleep again') match = dut.expect(EXIT_SLEEP_REGEX)