From f1aa0eb15be1bec20dd76d5c44325e8798ce406f Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Thu, 28 Jul 2022 17:48:40 +0530 Subject: [PATCH] example: Add coap_client example_test --- examples/protocols/.build-test-rules.yml | 7 +++---- examples/protocols/coap_client/README.md | 4 ++-- .../coap_client/pytest_coap_client_example.py | 21 +++++++++++++++++++ examples/protocols/coap_client/sdkconfig.ci | 8 +++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 examples/protocols/coap_client/pytest_coap_client_example.py create mode 100644 examples/protocols/coap_client/sdkconfig.ci diff --git a/examples/protocols/.build-test-rules.yml b/examples/protocols/.build-test-rules.yml index dd07fc0a53..37eb932ba0 100644 --- a/examples/protocols/.build-test-rules.yml +++ b/examples/protocols/.build-test-rules.yml @@ -53,10 +53,9 @@ examples/protocols/asio/udp_echo_server: reason: lack of runners examples/protocols/coap_client: - disable: - - if: IDF_TARGET == "esp32c2" - temporary: true - reason: target esp32c2 is not supported yet + disable_test: + - if: IDF_TARGET != "esp32" + reason: running this test on single platform is sufficient for coverage examples/protocols/coap_server: disable: diff --git a/examples/protocols/coap_client/README.md b/examples/protocols/coap_client/README.md index 6a3ea197d5..a9b39c55cd 100644 --- a/examples/protocols/coap_client/README.md +++ b/examples/protocols/coap_client/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | # CoAP client example diff --git a/examples/protocols/coap_client/pytest_coap_client_example.py b/examples/protocols/coap_client/pytest_coap_client_example.py new file mode 100644 index 0000000000..6e70feb74c --- /dev/null +++ b/examples/protocols/coap_client/pytest_coap_client_example.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import pexpect +import pytest +from pytest_embedded import Dut + + +@pytest.mark.esp32 +@pytest.mark.ethernet +def test_coap_example(dut: Dut) -> None: + dut.expect('Loaded app from partition at offset', timeout=30) + try: + dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]', timeout=30) + except pexpect.exceptions.TIMEOUT: + raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP/Ethernet') + + dut.expect('DNS lookup succeeded', timeout=30) + dut.expect('Received', timeout=30) + dut.expect(r'This server is using the Eclipse Californium \(Cf\) CoAP framework', timeout=30) + dut.expect(r'published under EPL\+EDL: http://www\.eclipse\.org/californium/', timeout=30) + dut.expect('Starting again!', timeout=30) diff --git a/examples/protocols/coap_client/sdkconfig.ci b/examples/protocols/coap_client/sdkconfig.ci new file mode 100644 index 0000000000..f958eb22e9 --- /dev/null +++ b/examples/protocols/coap_client/sdkconfig.ci @@ -0,0 +1,8 @@ +CONFIG_EXAMPLE_CONNECT_ETHERNET=y +CONFIG_EXAMPLE_CONNECT_WIFI=n +CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y +CONFIG_EXAMPLE_ETH_PHY_IP101=y +CONFIG_EXAMPLE_ETH_MDC_GPIO=23 +CONFIG_EXAMPLE_ETH_MDIO_GPIO=18 +CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5 +CONFIG_EXAMPLE_ETH_PHY_ADDR=1