ci: migrate examples/cxx ttfw test scripts to pytest

pull/11189/head
Fu Hanxi 2023-04-06 11:44:13 +08:00
rodzic b932b8eb94
commit 50950d5a5c
7 zmienionych plików z 59 dodań i 90 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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.')