mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/cbor_example_pytest_migration' into 'master'
cbor example pytest migration See merge request espressif/esp-idf!18052
This commit is contained in:
commit
361b40c994
@ -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
|
||||
|
@ -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()
|
42
examples/protocols/cbor/pytest_cbor.py
Normal file
42
examples/protocols/cbor/pytest_cbor.py
Normal file
@ -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'\}'))
|
@ -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
|
||||
|
||||
## multi-dut markers
|
||||
multi_dut_generic: tests should be run on generic runners, at least have two duts connected.
|
||||
|
Loading…
x
Reference in New Issue
Block a user