Эх сурвалжийг харах

Merge branch 'ci/migrate_cxx_related_ttfw_scripts' into 'master'

ci: migrate examples/cxx ttfw test scripts to pytest

Closes IDF-4807

See merge request espressif/esp-idf!23087
Fu Hanxi 2 жил өмнө
parent
commit
19b016e9c8

+ 0 - 19
examples/cxx/.build-test-rules.yml

@@ -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

+ 0 - 23
examples/cxx/exceptions/example_test.py

@@ -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()

+ 19 - 0
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)

+ 0 - 23
examples/cxx/pthread/example_test.py

@@ -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()

+ 20 - 0
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,
+    )

+ 0 - 25
examples/cxx/rtti/example_test.py

@@ -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<DerivedA*>(obj)=0')
-    dut.expect('dynamic_cast<DerivedB*>(obj)=0x')
-    dut.expect('dynamic_cast<DerivedB*>(obj)=0')
-    dut.expect('dynamic_cast<DerivedA*>(obj)=0x')
-
-    dut.expect('Example finished.')
-
-
-if __name__ == '__main__':
-    test_cpp_rtti_example()

+ 20 - 0
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<DerivedA*>(obj)=0')
+    dut.expect_exact('dynamic_cast<DerivedB*>(obj)=0x')
+    dut.expect_exact('dynamic_cast<DerivedB*>(obj)=0')
+    dut.expect_exact('dynamic_cast<DerivedA*>(obj)=0x')
+
+    dut.expect_exact('Example finished.')