mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-23 23:37:31 +02:00
add(esp_modem): Add unit test to check polymorphic delete
This commit is contained in:
@ -12,4 +12,4 @@ project(host_modem_test)
|
|||||||
idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
idf_component_get_property(esp_modem esp_modem COMPONENT_LIB)
|
||||||
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_COMPILER_CXX_EXCEPTIONS")
|
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_COMPILER_CXX_EXCEPTIONS")
|
||||||
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_IDF_TARGET_LINUX")
|
target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_IDF_TARGET_LINUX")
|
||||||
target_link_options(${esp_modem} INTERFACE -fsanitize=address)
|
target_link_options(${esp_modem} INTERFACE -fsanitize=address -fsanitize=undefined)
|
||||||
|
@ -7,12 +7,27 @@
|
|||||||
|
|
||||||
using namespace esp_modem;
|
using namespace esp_modem;
|
||||||
|
|
||||||
|
TEST_CASE("Test polymorphic delete for custom device/dte", "[esp_modem]")
|
||||||
|
{
|
||||||
|
auto term = std::make_unique<LoopbackTerm>(true);
|
||||||
|
auto dte = std::make_shared<DTE>(std::move(term));
|
||||||
|
CHECK(term == nullptr);
|
||||||
|
esp_modem_dce_config_t dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG("APN");
|
||||||
|
|
||||||
|
// Create custom device and DTE manually to check for a potential undefined behaviour
|
||||||
|
auto device = new GenericModule(std::move(dte), &dce_config);
|
||||||
|
device->power_down();
|
||||||
|
delete device;
|
||||||
|
auto custom_dte = new DTE(std::make_unique<LoopbackTerm>(false));
|
||||||
|
custom_dte->command("AT", nullptr, 0);
|
||||||
|
delete custom_dte;
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("DCE AT parser", "[esp_modem]")
|
TEST_CASE("DCE AT parser", "[esp_modem]")
|
||||||
{
|
{
|
||||||
auto term = std::make_unique<LoopbackTerm>(true);
|
auto term = std::make_unique<LoopbackTerm>(true);
|
||||||
auto dte = std::make_shared<DTE>(std::move(term));
|
auto dte = std::make_shared<DTE>(std::move(term));
|
||||||
CHECK(term == nullptr);
|
CHECK(term == nullptr);
|
||||||
|
|
||||||
esp_modem_dce_config_t dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG("APN");
|
esp_modem_dce_config_t dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG("APN");
|
||||||
esp_netif_t netif{};
|
esp_netif_t netif{};
|
||||||
auto dce = create_BG96_dce(&dce_config, dte, &netif);
|
auto dce = create_BG96_dce(&dce_config, dte, &netif);
|
||||||
|
Reference in New Issue
Block a user