diff --git a/examples/cxx/.build-test-rules.yml b/examples/cxx/.build-test-rules.yml deleted file mode 100644 index 70149243f5..0000000000 --- a/examples/cxx/.build-test-rules.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -examples/cxx/exceptions: - disable_test: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - temporary: true - reason: lack of runners - -examples/cxx/pthread: - disable_test: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - temporary: true - reason: lack of runners - -examples/cxx/rtti: - disable_test: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - temporary: true - reason: lack of runners diff --git a/examples/cxx/exceptions/example_test.py b/examples/cxx/exceptions/example_test.py deleted file mode 100644 index f7f5c3805e..0000000000 --- a/examples/cxx/exceptions/example_test.py +++ /dev/null @@ -1,23 +0,0 @@ -from __future__ import print_function - -import ttfw_idf - - -@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3']) -def test_examples_system_cpp_exceptions(env, extra_data): - dut = env.get_dut('cpp_exceptions_example', 'examples/cxx/exceptions') - # start test - dut.start_app() - lines = ['app_main starting', - 'In constructor, arg=42', - 'In constructor, arg=0', - 'In destructor, m_arg=42', - 'Exception caught: Exception in constructor', - 'app_main done' - ] - for line in lines: - dut.expect(line, timeout=2) - - -if __name__ == '__main__': - test_examples_system_cpp_exceptions() diff --git a/examples/cxx/exceptions/pytest_examples_cxx_exceptions.py b/examples/cxx/exceptions/pytest_examples_cxx_exceptions.py new file mode 100644 index 0000000000..0aa17b4c57 --- /dev/null +++ b/examples/cxx/exceptions/pytest_examples_cxx_exceptions.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded_idf.dut import IdfDut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_examples_cpp_exceptions(dut: IdfDut) -> None: + lines = [ + 'app_main starting', + 'In constructor, arg=42', + 'In constructor, arg=0', + 'In destructor, m_arg=42', + 'Exception caught: Exception in constructor', + 'app_main done', + ] + for line in lines: + dut.expect(line, timeout=2) diff --git a/examples/cxx/pthread/example_test.py b/examples/cxx/pthread/example_test.py deleted file mode 100644 index 759beae31e..0000000000 --- a/examples/cxx/pthread/example_test.py +++ /dev/null @@ -1,23 +0,0 @@ -from __future__ import unicode_literals - -import re - -import ttfw_idf - - -@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3']) -def test_examples_cpp_pthread(env, extra_data): - - dut = env.get_dut('cpp_pthread', 'examples/cxx/pthread') - dut.start_app() - - dut.expect_all(re.compile(r'pthread: This thread \(with the default name\) may run on any core.' - r'Core id: [01], prio: 5, minimum free stack: \d+ bytes.'), - re.compile(r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes.'), - re.compile(r'Thread [12]: This is the INHERITING thread with the same parameters as our parent, ' - r'including name. Core id: [01], prio: 5, minimum free stack: \d+ bytes.'), - re.compile(r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes')) - - -if __name__ == '__main__': - test_examples_cpp_pthread() diff --git a/examples/cxx/pthread/pytest_examples_cxx_pthread.py b/examples/cxx/pthread/pytest_examples_cxx_pthread.py new file mode 100644 index 0000000000..904e273f05 --- /dev/null +++ b/examples/cxx/pthread/pytest_examples_cxx_pthread.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded_idf.dut import IdfDut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_examples_cpp_pthread(dut: IdfDut) -> None: + dut.expect( + [ + r'pthread: This thread \(with the default name\) may run on any core.' + r'Core id: [01], prio: 5, minimum free stack: \d+ bytes\.', + r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes\.', + r'Thread [12]: This is the INHERITING thread with the same parameters as our parent, ' + r'including name. Core id: [01], prio: 5, minimum free stack: \d+ bytes\.', + r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes\.', + ], + expect_all=True, + ) diff --git a/examples/cxx/rtti/example_test.py b/examples/cxx/rtti/example_test.py deleted file mode 100644 index 80aab78c00..0000000000 --- a/examples/cxx/rtti/example_test.py +++ /dev/null @@ -1,25 +0,0 @@ -from __future__ import print_function - -import ttfw_idf - - -@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3']) -def test_cpp_rtti_example(env, extra_data): - dut = env.get_dut('cpp_rtti', 'examples/cxx/rtti') - dut.start_app() - - dut.expect('Type name of std::cout is: std::ostream') - dut.expect('Type name of std::cin is: std::istream') - dut.expect('Type of app_main is: void ()') - dut.expect('Type name of a lambda function is: app_main::{lambda(int, int)#1}') - - dut.expect('dynamic_cast(obj)=0') - dut.expect('dynamic_cast(obj)=0x') - dut.expect('dynamic_cast(obj)=0') - dut.expect('dynamic_cast(obj)=0x') - - dut.expect('Example finished.') - - -if __name__ == '__main__': - test_cpp_rtti_example() diff --git a/examples/cxx/rtti/pytest_examples_cxx_rtti.py b/examples/cxx/rtti/pytest_examples_cxx_rtti.py new file mode 100644 index 0000000000..d92432ae01 --- /dev/null +++ b/examples/cxx/rtti/pytest_examples_cxx_rtti.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pytest +from pytest_embedded_idf.dut import IdfDut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_cpp_rtti_example(dut: IdfDut) -> None: + dut.expect_exact('Type name of std::cout is: std::ostream') + dut.expect_exact('Type name of std::cin is: std::istream') + dut.expect_exact('Type of app_main is: void ()') + dut.expect_exact('Type name of a lambda function is: app_main::{lambda(int, int)#1}') + + dut.expect_exact('dynamic_cast(obj)=0') + dut.expect_exact('dynamic_cast(obj)=0x') + dut.expect_exact('dynamic_cast(obj)=0') + dut.expect_exact('dynamic_cast(obj)=0x') + + dut.expect_exact('Example finished.')