def test_custom_bootloader_impl_example(app: IdfApp, dut: Dut) -> None: # Expect to read a message from the custom bootloader # This message is defined in the Kconfig file, retrieve it while deleting # leading and trailing quotes (") welcome_message = app.sdkconfig['EXAMPLE_BOOTLOADER_WELCOME_MESSAGE'] dut.expect_exact(welcome_message) # Expect to read a message from the user application dut.expect_exact('Application started!')
def test_flash_suspend_example(dut: Dut) -> None: dut.expect_exact('found partition') res = dut.expect(r'During Erase, ISR callback function\(in flash\) response time:\s+(\d+(\.\d{1,2})) us') response_time = res.group(1).decode('utf8') assert 0 <= float(response_time) < 40 res = dut.expect(r'During Erase, ISR callback function\(in iram\) response time:\s+(\d+(\.\d{1,2})) us') response_time = res.group(1).decode('utf8') assert 0 <= float(response_time) < 5
def test_temp_sensor_example(dut: Dut) -> None: dut.expect_exact('Install temperature sensor') dut.expect_exact('Enable temperature sensor') dut.expect_exact('Read temperature') temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5) # Because the example test only run in the normal temperature environment. So this assert range is meaningful assert 0 < float(temp_value.group(1).decode('utf8')) < 50 temp_value = dut.expect(r'Temperature value (\d+\.\d+) .*', timeout=5) assert 0 < float(temp_value.group(1).decode('utf8')) < 50
def test_timer_group_example(dut: Dut): # type: ignore dut.expect(r'Init timer with auto-reload', timeout=5) res = dut.expect(r'Timer auto reloaded, count value in ISR: (\d+)', timeout=5) reloaded_count = res.group(1).decode('utf8') assert 0 <= int(reloaded_count) < 10 alarm_increase_step = 500000 dut.expect(r'Init timer without auto-reload') for i in range(1, 5): res = dut.expect(r'Timer alarmed at (\d+)', timeout=3) alarm_count = res.group(1).decode('utf8') assert (i * alarm_increase_step - 10) < int(alarm_count) < (i * alarm_increase_step + 10)
def test_custom_bootloader_hooks_example(dut: Dut) -> None: # Expect to read both hooks messages dut.expect_exact('This hook is called BEFORE bootloader initialization') dut.expect_exact('This hook is called AFTER bootloader initialization')
def test_gptimer_example(dut: Dut) -> None: dut.expect_exact('install pcnt unit') dut.expect_exact('set glitch filter') dut.expect_exact('install pcnt channels') dut.expect_exact('set edge and level actions for pcnt channels') dut.expect_exact('add watch points and register callbacks') dut.expect_exact('clear pcnt unit') dut.expect_exact('start pcnt unit') res = dut.expect(r'Pulse count: (\d+)') count_val = res.group(1).decode('utf8') assert -100 <= int(count_val) <= 100
def test_gptimer_example(dut: Dut) -> None: dut.expect(r'Create timer handle', timeout=5) dut.expect(r'Start timer, stop it at alarm event', timeout=5) res = dut.expect(r'Timer stopped, count=(\d+)', timeout=30) stopped_count = res.group(1).decode('utf8') assert (1000000 - 10) < int(stopped_count) < (1000000 + 10) dut.expect(r'Set count value') dut.expect(r'Get count value') res = dut.expect(r'Timer count value=(\d+)', timeout=5) count_val = res.group(1).decode('utf8') assert int(count_val) == 100 dut.expect(r'Start timer, auto-reload at alarm event', timeout=5) res = dut.expect(r'Timer reloaded, count=(\d+)', timeout=5) reloaded_count = res.group(1).decode('utf8') assert 0 <= int(reloaded_count) < 10 dut.expect(r'Stop timer') dut.expect(r'Update alarm value dynamically') for i in range(1, 5): res = dut.expect(r'Timer alarmed, count=(\d+)', timeout=5) alarm_count = res.group(1).decode('utf8') assert (i * 1000000 - 10) < int(alarm_count) < (i * 1000000 + 10) dut.expect(r'Stop timer') dut.expect(r'Delete timer')
def test_temp_sensor_example(dut: Dut) -> None: dut.expect_exact('Initializing Temperature sensor') dut.expect_exact('Temperature sensor started') temp_value = dut.expect(r'Temperature out celsius (\d+\.\d+)', timeout=30) # Because the example test only run in the normal temperature environment. So this assert range is meaningful assert 0 < float(temp_value.group(1)) < 45