From 57e2e7a27c582fe025acd0e6a1c3d37e0e19536e Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Tue, 10 May 2022 09:58:51 +0530 Subject: [PATCH 1/2] Migrate cbor example to pytest framework --- examples/protocols/cbor/example_test.py | 44 ------------------------- examples/protocols/cbor/pytest_cbor.py | 42 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 examples/protocols/cbor/example_test.py create mode 100644 examples/protocols/cbor/pytest_cbor.py diff --git a/examples/protocols/cbor/example_test.py b/examples/protocols/cbor/example_test.py deleted file mode 100644 index 03ca7a2243..0000000000 --- a/examples/protocols/cbor/example_test.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import unicode_literals - -import re -import textwrap - -import ttfw_idf - - -@ttfw_idf.idf_example_test(env_tag='Example_WIFI_Protocols') -def test_examples_cbor(env, extra_data): - - dut = env.get_dut('cbor', 'examples/protocols/cbor') - dut.start_app() - dut.expect(re.compile(r'example: encoded buffer size \d+')) - dut.expect('example: convert CBOR to JSON') - parsed_info = dut.expect(re.compile(r'\[\{"chip":"(\w+)","unicore":(\w+),"ip":\[(\d+),(\d+),(\d+),(\d+)\]\},' - r'3.1400001049041748' - r',"simple\(99\)","2019-07-10 09:00:00\+0000","undefined"\]')) - dut.expect('example: decode CBOR manually') - - dut.expect(re.compile(textwrap.dedent(r''' - Array\[\s+ - Map{{\s+ - chip\s+ - {}\s+ - unicore\s+ - {}\s+ - ip\s+ - Array\[\s+ - {}\s+ - {}\s+ - {}\s+ - {}\s+ - \]\s+ - }}\s+ - 3.14\s+ - simple\(99\)\s+ - 2019-07-10 09:00:00\+0000\s+ - undefined\s+ - \]'''.format(*parsed_info)).replace('{', r'\{').replace('}', r'\}'))) - - -if __name__ == '__main__': - test_examples_cbor() diff --git a/examples/protocols/cbor/pytest_cbor.py b/examples/protocols/cbor/pytest_cbor.py new file mode 100644 index 0000000000..e10530f5a8 --- /dev/null +++ b/examples/protocols/cbor/pytest_cbor.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +from __future__ import unicode_literals + +import textwrap + +import pytest +from pytest_embedded import Dut + + +@pytest.mark.supported_targets +@pytest.mark.wifi +def test_examples_cbor(dut: Dut) -> None: + + dut.expect(r'example: encoded buffer size \d+') + dut.expect('example: convert CBOR to JSON') + parsed_info = dut.expect(r'\[\{"chip":"(\w+)","unicore":(\w+),"ip":\[(\d+),(\d+),(\d+),(\d+)\]\},' + r'3.1400001049041748' + r',"simple\(99\)","2019-07-10 09:00:00\+0000","undefined"\]') + dut.expect('example: decode CBOR manually') + + dut.expect(textwrap.dedent(r''' + Array\[\s+ + Map{{\s+ + chip\s+ + {}\s+ + unicore\s+ + {}\s+ + ip\s+ + Array\[\s+ + {}\s+ + {}\s+ + {}\s+ + {}\s+ + \]\s+ + }}\s+ + 3.14\s+ + simple\(99\)\s+ + 2019-07-10 09:00:00\+0000\s+ + undefined\s+ + \]'''.format(parsed_info[1].decode(), parsed_info[2].decode(), parsed_info[3].decode(), + parsed_info[4].decode(), parsed_info[5].decode(),parsed_info[6].decode())).replace('{', r'\{').replace('}', r'\}')) From 1c0987814b73f954e5bd8027bc1990182f447019 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Tue, 10 May 2022 15:01:03 +0530 Subject: [PATCH 2/2] target-test.yml: Add job for wifi runner --- .gitlab/ci/target-test.yml | 10 ++++++++++ pytest.ini | 1 + 2 files changed, 11 insertions(+) diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index ae09296711..cd2c6a0be7 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -91,6 +91,16 @@ example_test_pytest_esp32_ethernet_ota: TARGET: ESP32 ENV_MARKER: ethernet_ota +example_test_pytest_esp32_wifi: + extends: + - .pytest_examples_dir_template + - .rules:test:example_test-esp32 + needs: + - build_pytest_examples_esp32 + variables: + TARGET: ESP32 + ENV_MARKER: wifi + example_test_pytest_esp32_ethernet_ip101: extends: - .pytest_examples_dir_template diff --git a/pytest.ini b/pytest.ini index a386445b25..c8621c26f1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -34,6 +34,7 @@ markers = ethernet_ota: ethernet OTA runners flash_encryption: Flash Encryption runners ir_transceiver: runners with a pair of IR transmitter and receiver + wifi: wifi runner # log related log_cli = True