Skip to content

Commit 8475adf

Browse files
authored
Merge pull request #655 from david-cermak/fix/modem_target_catch2
[modem]: Update target test builds to use external Catch2
2 parents 29e5fbd + 554f022 commit 8475adf

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-17
lines changed

components/esp_modem/test/target/main/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
idf_component_register(SRCS "pppd_test.cpp"
22
"NetworkDCE.cpp"
3-
REQUIRES esp_modem)
3+
REQUIRES esp_modem catch2)
44

55
set_target_properties(${COMPONENT_LIB} PROPERTIES
66
CXX_STANDARD 17
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
espressif/catch2: "*"
3+
idf:
4+
version: ">=4.4"

components/esp_modem/test/target/main/pppd_test.cpp

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include "freertos/FreeRTOS.h"
1818
#include "freertos/event_groups.h"
1919

20+
#define CATCH_CONFIG_MAIN
21+
#include "catch2/catch_test_macros.hpp"
22+
#include "catch2/catch_session.hpp"
23+
2024
static const char *TAG = "pppd_test";
2125
static EventGroupHandle_t event_group = NULL;
2226

@@ -73,9 +77,6 @@ esp_err_t modem_init_network(esp_netif_t *netif);
7377
void modem_start_network();
7478
void modem_stop_network();
7579

76-
bool test_connect();
77-
bool test_disconnect();
78-
7980
extern "C" void app_main(void)
8081
{
8182

@@ -99,27 +100,41 @@ extern "C" void app_main(void)
99100
#endif
100101

101102
modem_start_network();
102-
103-
bool t1 = test_connect();
104-
bool t2 = test_disconnect();
105-
106-
if (t1 && t2) {
107-
ESP_LOGI(TAG, "All tests passed");
108-
} else {
103+
Catch::Session session;
104+
int numFailed = session.run();
105+
if (numFailed > 0) {
109106
ESP_LOGE(TAG, "Test FAILED!");
107+
} else {
108+
ESP_LOGI(TAG, "Test passed!");
110109
}
111110

112111
}
113112

114-
bool test_connect() //("Connect test", "[esp_modem]")
113+
TEST_CASE("Connect test", "[esp_modem]")
115114
{
116115
EventBits_t b = xEventGroupWaitBits(event_group, 1, pdTRUE, pdFALSE, pdMS_TO_TICKS(15000));
117-
return b == 1;
116+
CHECK(b == 1);
118117
}
119118

120-
bool test_disconnect() //("Disconnection test", "[esp_modem]")
119+
TEST_CASE("Disconnection test", "[esp_modem]")
121120
{
122121
modem_stop_network();
123122
EventBits_t b = xEventGroupWaitBits(event_group, 2, pdTRUE, pdFALSE, pdMS_TO_TICKS(15000));
124-
return b == 2;
123+
CHECK(b == 2);
124+
}
125+
126+
127+
extern "C" {
128+
129+
static void handle(int nr)
130+
{
131+
ESP_LOGE(TAG, "Signal handler %d", nr);
132+
}
133+
134+
_sig_func_ptr signal (int nr, _sig_func_ptr)
135+
{
136+
return handle;
137+
}
138+
139+
125140
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CONFIG_COMPILER_CXX_EXCEPTIONS=y
2-
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
2+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
33
CONFIG_LWIP_PPP_SUPPORT=y
4+
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
45
CONFIG_TEST_APP_AUTH=y
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
CONFIG_COMPILER_CXX_EXCEPTIONS=y
2-
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
2+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
33
CONFIG_LWIP_PPP_SUPPORT=y
4+
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

0 commit comments

Comments
 (0)