1#!/usr/bin/env python
2
3from __future__ import division, print_function, unicode_literals
4
5import re
6from typing import Any
7
8import ttfw_idf
9
10
11@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32s2', 'esp32c3'])
12def test_examples_pthread(env, _):  # type: (Any, Any) -> None
13    app_name = 'pthread'
14    dut = env.get_dut(app_name, 'examples/system/pthread')
15    dut.start_app()
16
17    # Note: this test doesn't really confirm anything, except that threads are created
18    # and stdout is not being corrupted by multiple threads printing ot it.
19    dut.expect(re.compile(r'Created thread 0x[\da-f]+'))
20    dut.expect(re.compile(r'Created larger stack thread 0x[\da-f]+'))
21    dut.expect(r'Threads have exited')
22    dut.expect(re.compile(r'Created thread 0x[\da-f]+ with new default config'))
23    dut.expect('Thread has exited')
24
25
26if __name__ == '__main__':
27    test_examples_pthread()
28