mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
ci: Migrateunit test for mqtt test to unit test app
- Split mqtt and mqtt5 tests - Move common test code to a common component - Add necessary python scripts
This commit is contained in:
parent
826c927c09
commit
1acfc9b5e0
7
components/mqtt/.build-test-rules.yml
Normal file
7
components/mqtt/.build-test-rules.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/mqtt/test_apps:
|
||||||
|
disable_test:
|
||||||
|
- if: IDF_TARGET not in ["esp32", "esp32c2"]
|
||||||
|
temporary: false
|
||||||
|
reason: Not needed to test on all targets (chosen two, one for each architecture)
|
4
components/mqtt/test_apps/common/CMakeLists.txt
Normal file
4
components/mqtt/test_apps/common/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
idf_component_register(SRCS test_mqtt_connection.c
|
||||||
|
INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/include
|
||||||
|
PRIV_REQUIRES unity esp_event esp_netif esp_eth)
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
9
components/mqtt/test_apps/test_mqtt/CMakeLists.txt
Normal file
9
components/mqtt/test_apps/test_mqtt/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components"
|
||||||
|
"../common")
|
||||||
|
|
||||||
|
set(COMPONENTS main)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(esp_mqtt_client_test)
|
2
components/mqtt/test_apps/test_mqtt/README.md
Normal file
2
components/mqtt/test_apps/test_mqtt/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
|
@ -1,9 +1,9 @@
|
|||||||
set(srcs test_mqtt_client_broker.c test_mqtt_connection.c test_mqtt.c)
|
set(srcs test_mqtt_client_broker.c test_mqtt.c)
|
||||||
|
|
||||||
if(CONFIG_MQTT_PROTOCOL_5)
|
if(CONFIG_MQTT_PROTOCOL_5)
|
||||||
list(APPEND srcs test_mqtt5_client_broker.c test_mqtt5.c)
|
list(APPEND srcs test_mqtt5_client_broker.c test_mqtt5.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif spi_flash)
|
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif spi_flash common)
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
@ -11,33 +11,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "unity_fixture.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "unity_fixture_extras.h"
|
||||||
#include "unity.h"
|
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
#include "memory_checks.h"
|
#include "memory_checks.h"
|
||||||
#include "mqtt_client.h"
|
#include "mqtt_client.h"
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "test_mqtt_client_broker.h"
|
#include "test_mqtt_client_broker.h"
|
||||||
#include "test_mqtt_connection.h"
|
#include "test_mqtt_connection.h"
|
||||||
#include "esp_mac.h"
|
|
||||||
#include "esp_partition.h"
|
#include "esp_partition.h"
|
||||||
|
|
||||||
static void test_leak_setup(const char * file, long line)
|
TEST_GROUP(mqtt);
|
||||||
{
|
|
||||||
uint8_t mac[6];
|
TEST_SETUP(mqtt){
|
||||||
struct timeval te;
|
|
||||||
gettimeofday(&te, NULL); // get current time
|
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
|
||||||
printf("%s:%ld: time=%jd.%lds, mac:" MACSTR "\n", file, line, (intmax_t)te.tv_sec, te.tv_usec, MAC2STR(mac));
|
|
||||||
test_utils_record_free_mem();
|
test_utils_record_free_mem();
|
||||||
|
TEST_ESP_OK(test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("mqtt init with invalid url", "[mqtt][leaks=0]")
|
TEST_TEAR_DOWN(mqtt){
|
||||||
|
test_utils_finish_and_evaluate_leaks(test_utils_get_leak_level(ESP_LEAK_TYPE_WARNING, ESP_COMP_LEAK_ALL),
|
||||||
|
test_utils_get_leak_level(ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_ALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(mqtt, init_with_invalid_url)
|
||||||
{
|
{
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
|
||||||
const esp_mqtt_client_config_t mqtt_cfg = {
|
const esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
.broker.address.uri = "INVALID",
|
.broker.address.uri = "INVALID",
|
||||||
};
|
};
|
||||||
@ -45,9 +42,8 @@ TEST_CASE("mqtt init with invalid url", "[mqtt][leaks=0]")
|
|||||||
TEST_ASSERT_EQUAL(NULL, client );
|
TEST_ASSERT_EQUAL(NULL, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("mqtt init and deinit", "[mqtt][leaks=0]")
|
TEST(mqtt, init_and_deinit)
|
||||||
{
|
{
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
|
||||||
const esp_mqtt_client_config_t mqtt_cfg = {
|
const esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
// no connection takes place, but the uri has to be valid for init() to succeed
|
// no connection takes place, but the uri has to be valid for init() to succeed
|
||||||
.broker.address.uri = "mqtts://localhost:8883",
|
.broker.address.uri = "mqtts://localhost:8883",
|
||||||
@ -66,10 +62,13 @@ static const char* this_bin_addr(void)
|
|||||||
return binary_address;
|
return binary_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("mqtt enqueue and destroy outbox", "[mqtt][leaks=0]")
|
TEST(mqtt, enqueue_and_destroy_outbox)
|
||||||
{
|
{
|
||||||
const char * bin_addr = this_bin_addr();
|
const char * bin_addr = this_bin_addr();
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
|
||||||
|
// Reseting leak detection since this_bin_addr adds to allocated memory.
|
||||||
|
test_utils_record_free_mem();
|
||||||
|
TEST_ESP_OK(test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL));
|
||||||
const int messages = 20;
|
const int messages = 20;
|
||||||
const int size = 2000;
|
const int size = 2000;
|
||||||
const esp_mqtt_client_config_t mqtt_cfg = {
|
const esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
@ -93,7 +92,7 @@ TEST_CASE("mqtt enqueue and destroy outbox", "[mqtt][leaks=0]")
|
|||||||
/**
|
/**
|
||||||
* This test cases uses ethernet kit, so build and use it only if EMAC supported
|
* This test cases uses ethernet kit, so build and use it only if EMAC supported
|
||||||
*/
|
*/
|
||||||
TEST_CASE("mqtt broker tests", "[mqtt][test_env=UT_T2_Ethernet]")
|
TEST(mqtt, broker_tests)
|
||||||
{
|
{
|
||||||
test_case_uses_tcpip();
|
test_case_uses_tcpip();
|
||||||
connect_test_fixture_setup();
|
connect_test_fixture_setup();
|
||||||
@ -105,5 +104,19 @@ TEST_CASE("mqtt broker tests", "[mqtt][test_env=UT_T2_Ethernet]")
|
|||||||
|
|
||||||
connect_test_fixture_teardown();
|
connect_test_fixture_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SOC_EMAC_SUPPORTED
|
#endif // SOC_EMAC_SUPPORTED
|
||||||
|
|
||||||
|
|
||||||
|
TEST_GROUP_RUNNER(mqtt) {
|
||||||
|
RUN_TEST_CASE(mqtt, init_with_invalid_url);
|
||||||
|
RUN_TEST_CASE(mqtt, init_and_deinit);
|
||||||
|
RUN_TEST_CASE(mqtt, enqueue_and_destroy_outbox);
|
||||||
|
|
||||||
|
#if SOC_EMAC_SUPPORTED
|
||||||
|
RUN_TEST_CASE(mqtt, broker_tests);
|
||||||
|
#endif // SOC_EMAC_SUPPORTED
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void){
|
||||||
|
UNITY_MAIN(mqtt);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
11
components/mqtt/test_apps/test_mqtt/pytest_mqtt_ut.py
Normal file
11
components/mqtt/test_apps/test_mqtt/pytest_mqtt_ut.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.esp32c2
|
||||||
|
@pytest.mark.ethernet
|
||||||
|
def test_mqtt_client(dut: Dut) -> None:
|
||||||
|
dut.expect_unity_test_output()
|
3
components/mqtt/test_apps/test_mqtt/sdkconfig.defaults
Normal file
3
components/mqtt/test_apps/test_mqtt/sdkconfig.defaults
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# General options for additional checks
|
||||||
|
CONFIG_ESP_TASK_WDT_EN=n
|
||||||
|
CONFIG_UNITY_ENABLE_FIXTURE=y
|
9
components/mqtt/test_apps/test_mqtt5/CMakeLists.txt
Normal file
9
components/mqtt/test_apps/test_mqtt5/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components"
|
||||||
|
"../common")
|
||||||
|
|
||||||
|
set(COMPONENTS main)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(esp_mqtt5_client_test)
|
2
components/mqtt/test_apps/test_mqtt5/README.md
Normal file
2
components/mqtt/test_apps/test_mqtt5/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
|
5
components/mqtt/test_apps/test_mqtt5/main/CMakeLists.txt
Normal file
5
components/mqtt/test_apps/test_mqtt5/main/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(srcs test_mqtt5_client_broker.c test_mqtt5.c)
|
||||||
|
|
||||||
|
idf_component_register(SRCS "${srcs}"
|
||||||
|
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif spi_flash common)
|
||||||
|
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
14
components/mqtt/test_apps/test_mqtt5/main/Kconfig.projbuild
Normal file
14
components/mqtt/test_apps/test_mqtt5/main/Kconfig.projbuild
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
menu "ESP-MQTT Unit Test Config"
|
||||||
|
|
||||||
|
config MQTT_TEST_BROKER_URI
|
||||||
|
string "URI of the test broker"
|
||||||
|
default "mqtt://mqtt.eclipseprojects.io"
|
||||||
|
help
|
||||||
|
URL of an mqtt broker which this test connects to.
|
||||||
|
|
||||||
|
config MQTT5_TEST_BROKER_URI
|
||||||
|
string "URI of the test broker"
|
||||||
|
default "mqtt://mqtt.eclipseprojects.io"
|
||||||
|
help
|
||||||
|
URL of an mqtt broker which this test connects to.
|
||||||
|
endmenu
|
@ -5,62 +5,60 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "unity_fixture.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "unity_fixture_extras.h"
|
||||||
#include "unity.h"
|
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
#include "memory_checks.h"
|
#include "memory_checks.h"
|
||||||
#include "mqtt_client.h"
|
#include "mqtt_client.h"
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "test_mqtt5_client_broker.h"
|
#include "test_mqtt5_client_broker.h"
|
||||||
#include "test_mqtt_connection.h"
|
#include "test_mqtt_connection.h"
|
||||||
#include "esp_mac.h"
|
|
||||||
#include "esp_partition.h"
|
#include "esp_partition.h"
|
||||||
|
|
||||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C6, ESP32H2)
|
|
||||||
|
TEST_GROUP(mqtt5);
|
||||||
|
|
||||||
|
TEST_SETUP(mqtt5)
|
||||||
|
{
|
||||||
|
test_utils_record_free_mem();
|
||||||
|
TEST_ESP_OK(test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_TEAR_DOWN(mqtt5)
|
||||||
|
{
|
||||||
|
test_utils_finish_and_evaluate_leaks(test_utils_get_leak_level(ESP_LEAK_TYPE_WARNING, ESP_COMP_LEAK_ALL),
|
||||||
|
test_utils_get_leak_level(ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_ALL));
|
||||||
|
}
|
||||||
|
|
||||||
static esp_mqtt5_user_property_item_t user_property_arr[3] = {
|
static esp_mqtt5_user_property_item_t user_property_arr[3] = {
|
||||||
{"board", "esp32"},
|
{"board", "esp32"},
|
||||||
{"u", "user"},
|
{"u", "user"},
|
||||||
{"p", "password"}
|
{"p", "password"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_leak_setup(const char * file, long line)
|
TEST(mqtt5, init_with_invalid_url)
|
||||||
{
|
{
|
||||||
uint8_t mac[6];
|
|
||||||
struct timeval te;
|
|
||||||
gettimeofday(&te, NULL); // get current time
|
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
|
||||||
printf("%s:%ld: time=%ld.%lds, mac:" MACSTR "\n", file, line, te.tv_sec, te.tv_usec, MAC2STR(mac));
|
|
||||||
test_utils_record_free_mem();
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("mqtt5 init with invalid url", "[mqtt5][leaks=0]")
|
|
||||||
{
|
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
|
||||||
const esp_mqtt_client_config_t mqtt5_cfg = {
|
const esp_mqtt_client_config_t mqtt5_cfg = {
|
||||||
.broker.address.uri = "INVALID",
|
.broker.address.uri = "INVALID",
|
||||||
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
||||||
};
|
};
|
||||||
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt5_cfg);
|
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt5_cfg);
|
||||||
TEST_ASSERT_EQUAL(NULL, client );
|
TEST_ASSERT_EQUAL(NULL, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("mqtt5 init and deinit", "[mqtt5][leaks=0]")
|
TEST(mqtt5, init_and_deinit)
|
||||||
{
|
{
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
|
||||||
const esp_mqtt_client_config_t mqtt5_cfg = {
|
const esp_mqtt_client_config_t mqtt5_cfg = {
|
||||||
// no connection takes place, but the uri has to be valid for init() to succeed
|
// no connection takes place, but the uri has to be valid for init() to succeed
|
||||||
.broker.address.uri = "mqtts://localhost:8883",
|
.broker.address.uri = "mqtts://localhost:8883",
|
||||||
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
||||||
.credentials.username = "123",
|
.credentials.username = "123",
|
||||||
.credentials.authentication.password = "456",
|
.credentials.authentication.password = "456",
|
||||||
.session.last_will.topic = "/topic/will",
|
.session.last_will.topic = "/topic/will",
|
||||||
.session.last_will.msg = "i will leave",
|
.session.last_will.msg = "i will leave",
|
||||||
.session.last_will.msg_len = 12,
|
.session.last_will.msg_len = 12,
|
||||||
.session.last_will.qos = 1,
|
.session.last_will.qos = 1,
|
||||||
.session.last_will.retain = true,
|
.session.last_will.retain = true,
|
||||||
};
|
};
|
||||||
esp_mqtt5_connection_property_config_t connect_property = {
|
esp_mqtt5_connection_property_config_t connect_property = {
|
||||||
.session_expiry_interval = 10,
|
.session_expiry_interval = 10,
|
||||||
@ -88,25 +86,27 @@ TEST_CASE("mqtt5 init and deinit", "[mqtt5][leaks=0]")
|
|||||||
esp_mqtt_client_destroy(client);
|
esp_mqtt_client_destroy(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* this_bin_addr(void)
|
static const char *this_bin_addr(void)
|
||||||
{
|
{
|
||||||
esp_partition_mmap_handle_t out_handle;
|
esp_partition_mmap_handle_t out_handle;
|
||||||
const void *binary_address;
|
const void *binary_address;
|
||||||
const esp_partition_t* partition = esp_ota_get_running_partition();
|
const esp_partition_t *partition = esp_ota_get_running_partition();
|
||||||
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
|
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
|
||||||
return binary_address;
|
return binary_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("mqtt5 enqueue and destroy outbox", "[mqtt5][leaks=0]")
|
TEST(mqtt5, enqueue_and_destroy_outbox)
|
||||||
{
|
{
|
||||||
const char * bin_addr = this_bin_addr();
|
const char *bin_addr = this_bin_addr();
|
||||||
test_leak_setup(__FILE__, __LINE__);
|
// Reseting leak detection since this_bin_addr adds to allocated memory.
|
||||||
|
test_utils_record_free_mem();
|
||||||
|
TEST_ESP_OK(test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL));
|
||||||
const int messages = 20;
|
const int messages = 20;
|
||||||
const int size = 2000;
|
const int size = 2000;
|
||||||
const esp_mqtt_client_config_t mqtt5_cfg = {
|
const esp_mqtt_client_config_t mqtt5_cfg = {
|
||||||
// no connection takes place, but the uri has to be valid for init() to succeed
|
// no connection takes place, but the uri has to be valid for init() to succeed
|
||||||
.broker.address.uri = "mqtts://localhost:8883",
|
.broker.address.uri = "mqtts://localhost:8883",
|
||||||
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
.session.protocol_ver = MQTT_PROTOCOL_V_5,
|
||||||
};
|
};
|
||||||
esp_mqtt5_publish_property_config_t publish_property = {
|
esp_mqtt5_publish_property_config_t publish_property = {
|
||||||
.payload_format_indicator = 1,
|
.payload_format_indicator = 1,
|
||||||
@ -129,7 +129,7 @@ TEST_CASE("mqtt5 enqueue and destroy outbox", "[mqtt5][leaks=0]")
|
|||||||
}
|
}
|
||||||
int bytes_after = esp_get_free_heap_size();
|
int bytes_after = esp_get_free_heap_size();
|
||||||
// check that outbox allocated all messages on heap
|
// check that outbox allocated all messages on heap
|
||||||
TEST_ASSERT_GREATER_OR_EQUAL(messages*size, bytes_before - bytes_after);
|
TEST_ASSERT_GREATER_OR_EQUAL(messages * size, bytes_before - bytes_after);
|
||||||
|
|
||||||
esp_mqtt_client_destroy(client);
|
esp_mqtt_client_destroy(client);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ TEST_CASE("mqtt5 enqueue and destroy outbox", "[mqtt5][leaks=0]")
|
|||||||
/**
|
/**
|
||||||
* This test cases uses ethernet kit, so build and use it only if EMAC supported
|
* This test cases uses ethernet kit, so build and use it only if EMAC supported
|
||||||
*/
|
*/
|
||||||
TEST_CASE("mqtt5 broker tests", "[mqtt5][test_env=UT_T2_Ethernet]")
|
TEST(mqtt5, broker_tests)
|
||||||
{
|
{
|
||||||
test_case_uses_tcpip();
|
test_case_uses_tcpip();
|
||||||
connect_test_fixture_setup();
|
connect_test_fixture_setup();
|
||||||
@ -151,4 +151,22 @@ TEST_CASE("mqtt5 broker tests", "[mqtt5][test_env=UT_T2_Ethernet]")
|
|||||||
connect_test_fixture_teardown();
|
connect_test_fixture_teardown();
|
||||||
}
|
}
|
||||||
#endif // SOC_EMAC_SUPPORTED
|
#endif // SOC_EMAC_SUPPORTED
|
||||||
#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C6, ESP32H2)
|
|
||||||
|
TEST_GROUP_RUNNER(mqtt5)
|
||||||
|
{
|
||||||
|
#if !DISABLED_FOR_TARGETS(ESP32H2)
|
||||||
|
RUN_TEST_CASE(mqtt5, init_with_invalid_url);
|
||||||
|
RUN_TEST_CASE(mqtt5, init_and_deinit);
|
||||||
|
RUN_TEST_CASE(mqtt5, enqueue_and_destroy_outbox);
|
||||||
|
|
||||||
|
#if SOC_EMAC_SUPPORTED
|
||||||
|
RUN_TEST_CASE(mqtt5, broker_tests);
|
||||||
|
#endif // SOC_EMAC_SUPPORTED
|
||||||
|
#endif //!DISABLED_FOR_TARGETS(ESP32H2)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
UNITY_MAIN(mqtt5);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
11
components/mqtt/test_apps/test_mqtt5/pytest_mqtt5_ut.py
Normal file
11
components/mqtt/test_apps/test_mqtt5/pytest_mqtt5_ut.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.esp32c2
|
||||||
|
@pytest.mark.ethernet
|
||||||
|
def test_mqtt5_client(dut: Dut) -> None:
|
||||||
|
dut.expect_unity_test_output()
|
4
components/mqtt/test_apps/test_mqtt5/sdkconfig.defaults
Normal file
4
components/mqtt/test_apps/test_mqtt5/sdkconfig.defaults
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# General options for additional checks
|
||||||
|
CONFIG_ESP_TASK_WDT_EN=n
|
||||||
|
CONFIG_MQTT_PROTOCOL_5=y
|
||||||
|
CONFIG_UNITY_ENABLE_FIXTURE=y
|
@ -1,6 +1,6 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32c2"
|
CONFIG_IDF_TARGET="esp32c2"
|
||||||
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_phy esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc
|
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_phy esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc
|
||||||
CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE=n
|
CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE=n
|
||||||
CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT=y
|
CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT=y
|
||||||
CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC=n
|
CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC=n
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32c6"
|
CONFIG_IDF_TARGET="esp32c6"
|
||||||
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_phy esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc
|
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_phy esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32h2"
|
CONFIG_IDF_TARGET="esp32h2"
|
||||||
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc
|
TEST_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32c2"
|
CONFIG_IDF_TARGET="esp32c2"
|
||||||
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32c6"
|
CONFIG_IDF_TARGET="esp32c6"
|
||||||
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This config is split between targets since different component needs to be included
|
# This config is split between targets since different component needs to be included
|
||||||
CONFIG_IDF_TARGET="esp32h2"
|
CONFIG_IDF_TARGET="esp32h2"
|
||||||
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
TEST_COMPONENTS=mqtt
|
|
||||||
CONFIG_MQTT_PROTOCOL_5=y
|
|
||||||
CONFIG_MQTT5_TEST_BROKER_URI="mqtt://${EXAMPLE_MQTTV5_BROKER_TCP}"
|
|
||||||
CONFIG_LWIP_TCPIP_CORE_LOCKING=y
|
|
||||||
CONFIG_LWIP_CHECK_THREAD_SAFETY=y
|
|
Loading…
x
Reference in New Issue
Block a user