mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(esp_tls): extends esp-tls test apps
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
components/esp-tls/test_apps:
|
||||
disable:
|
||||
- if: IDF_TARGET not in ["esp32c3"]
|
||||
reason: Testing on one target is enough
|
||||
@@ -1,2 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32-C3 |
|
||||
| ----------------- | -------- |
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES test_utils esp-tls unity
|
||||
WHOLE_ARCHIVE)
|
||||
|
||||
# Expose esp-tls private headers for internal component tests
|
||||
idf_component_get_property(esp_tls_dir esp-tls COMPONENT_DIR)
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE "${esp_tls_dir}/private_include")
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "memory_checks.h"
|
||||
#include "esp_tls.h"
|
||||
#include "esp_tls_private.h"
|
||||
#include "unity.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
@@ -59,6 +60,46 @@ const char *test_key_pem = "-----BEGIN PRIVATE KEY-----\n"\
|
||||
"Aogx44Fozd1t2hYcozPuZD4s\n"\
|
||||
"-----END PRIVATE KEY-----\n";
|
||||
|
||||
static ssize_t dummy_read(esp_tls_t *tls, char *data, size_t datalen) { return (ssize_t)datalen; }
|
||||
|
||||
TEST_CASE("esp_tls_conn_write/read reject NULL tls", "[esp-tls]")
|
||||
{
|
||||
char buf[16] = {0};
|
||||
TEST_ASSERT_EQUAL(-1, esp_tls_conn_write(NULL, buf, sizeof(buf)));
|
||||
TEST_ASSERT_EQUAL(-1, esp_tls_conn_read(NULL, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
TEST_CASE("esp_tls_conn_write reject NULL data buffer", "[esp-tls]")
|
||||
{
|
||||
esp_tls_t *tls = esp_tls_init();
|
||||
TEST_ASSERT_NOT_NULL(tls);
|
||||
TEST_ASSERT_EQUAL(-1, esp_tls_conn_write(tls, NULL, 16));
|
||||
esp_tls_conn_destroy(tls);
|
||||
}
|
||||
|
||||
TEST_CASE("esp_tls_conn_read accepts zero datalen", "[esp-tls]")
|
||||
{
|
||||
esp_tls_t *tls = esp_tls_init();
|
||||
TEST_ASSERT_NOT_NULL(tls);
|
||||
tls->is_tls = true;
|
||||
tls->read = dummy_read;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_tls_set_conn_state(tls, ESP_TLS_DONE));
|
||||
/* datalen=0 on read is used in some projects, to get the data in the SSL buffers */
|
||||
TEST_ASSERT_EQUAL(0, esp_tls_conn_read(tls, NULL, 0));
|
||||
esp_tls_conn_destroy(tls);
|
||||
}
|
||||
|
||||
TEST_CASE("esp_tls_conn_write/read reject unconnected tls", "[esp-tls]")
|
||||
{
|
||||
esp_tls_t *tls = esp_tls_init();
|
||||
TEST_ASSERT_NOT_NULL(tls);
|
||||
/* read/write function pointers are NULL right after init */
|
||||
char buf[16] = {0};
|
||||
TEST_ASSERT_EQUAL(-1, esp_tls_conn_write(tls, buf, sizeof(buf)));
|
||||
TEST_ASSERT_EQUAL(-1, esp_tls_conn_read(tls, buf, sizeof(buf)));
|
||||
esp_tls_conn_destroy(tls);
|
||||
}
|
||||
|
||||
TEST_CASE("esp-tls init deinit", "[esp-tls]")
|
||||
{
|
||||
struct esp_tls *tls = esp_tls_init();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
|
||||
def test_esp_tls(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases()
|
||||
@@ -0,0 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@idf_parametrize('config', ['default'], indirect=['config'])
|
||||
@idf_parametrize('target', ['esp32c3'], indirect=['target'])
|
||||
def test_esp_tls(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases()
|
||||
Reference in New Issue
Block a user