2018-10-26 01:14:19 -04:00
|
|
|
from __future__ import print_function
|
2019-11-26 22:58:07 -05:00
|
|
|
|
|
|
|
import ttfw_idf
|
2018-10-26 01:14:19 -04:00
|
|
|
|
|
|
|
TASK_ITERATION_LIMIT = 10
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
TASK_ITERATION_POSTING = 'posting TASK_EVENTS:TASK_ITERATION_EVENT to {}, iteration {} out of ' + str(TASK_ITERATION_LIMIT)
|
|
|
|
TASK_ITERATION_HANDLING = 'handling TASK_EVENTS:TASK_ITERATION_EVENT from {}, iteration {}'
|
2018-10-26 01:14:19 -04:00
|
|
|
|
2018-12-04 02:32:48 -05:00
|
|
|
|
2021-03-12 01:05:17 -05:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
2018-10-26 01:14:19 -04:00
|
|
|
def test_user_event_loops_example(env, extra_data):
|
2021-03-12 01:05:17 -05:00
|
|
|
dut = env.get_dut('user_event_loops', 'examples/system/esp_event/user_event_loops')
|
2018-10-26 01:14:19 -04:00
|
|
|
|
|
|
|
dut.start_app()
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect('setting up')
|
|
|
|
dut.expect('starting event source')
|
|
|
|
dut.expect('starting application task')
|
|
|
|
print('Finished setup')
|
2018-10-26 01:14:19 -04:00
|
|
|
|
|
|
|
for iteration in range(1, TASK_ITERATION_LIMIT + 1):
|
|
|
|
loop = None
|
|
|
|
|
|
|
|
if (iteration % 2 == 0):
|
2021-01-25 21:49:01 -05:00
|
|
|
loop = 'loop_with_task'
|
2018-10-26 01:14:19 -04:00
|
|
|
else:
|
2021-01-25 21:49:01 -05:00
|
|
|
loop = 'loop_without_task'
|
2018-10-26 01:14:19 -04:00
|
|
|
|
|
|
|
dut.expect(TASK_ITERATION_POSTING.format(loop, iteration))
|
2021-01-25 21:49:01 -05:00
|
|
|
print('Posted iteration {} to {}'.format(iteration, loop))
|
2018-10-26 01:14:19 -04:00
|
|
|
dut.expect(TASK_ITERATION_HANDLING.format(loop, iteration))
|
2021-01-25 21:49:01 -05:00
|
|
|
print('Handled iteration {} from {}'.format(iteration, loop))
|
2018-10-26 01:14:19 -04:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect('deleting task event source')
|
|
|
|
print('Deleted task event source')
|
2018-10-26 01:14:19 -04:00
|
|
|
|
2018-12-04 02:32:48 -05:00
|
|
|
|
2018-10-26 01:14:19 -04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
test_user_event_loops_example()
|