ci(esp_event): upgrade host test to Catch2 as a component, fix build

- use espressif/catch2 component
- fix build issues after FreeRTOS upgrade
- enable test app build in CI
This commit is contained in:
Ivan Grokhotkov
2023-11-27 14:27:37 +01:00
parent 96f49c2603
commit 79a2c15477
5 changed files with 17 additions and 7 deletions

View File

@@ -0,0 +1,3 @@
components/esp_event/host_test:
enable:
- if: IDF_TARGET == "linux"

View File

@@ -1,3 +1,8 @@
idf_component_register(SRCS "esp_event_test.cpp" idf_component_register(SRCS "esp_event_test.cpp"
INCLUDE_DIRS "../../" $ENV{IDF_PATH}/tools/catch INCLUDE_DIRS "../../"
REQUIRES esp_event cmock) REQUIRES esp_event cmock
WHOLE_ARCHIVE)
# Currently 'main' for IDF_TARGET=linux is defined in freertos component.
# Since we are using a freertos mock here, need to let Catch2 provide 'main'.
target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)

View File

@@ -7,12 +7,11 @@
CONDITIONS OF ANY KIND, either express or implied. CONDITIONS OF ANY KIND, either express or implied.
*/ */
#define CATCH_CONFIG_MAIN
#include <stdio.h> #include <stdio.h>
#include "esp_event.h" #include "esp_event.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include "fixtures.hpp" #include "fixtures.hpp"

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -9,11 +9,12 @@
#include "esp_event.h" #include "esp_event.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
extern "C" { extern "C" {
#include "Mocktask.h" #include "Mocktask.h"
#include "Mockqueue.h" #include "Mockqueue.h"
#include "Mockidf_additions.h"
} }
/** /**
@@ -129,11 +130,11 @@ struct MockTask : public CMockFix {
xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdFALSE); xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdFALSE);
} else if (flags == CreateAnd::IGNORE) { } else if (flags == CreateAnd::IGNORE) {
xTaskCreatePinnedToCore_IgnoreAndReturn(pdTRUE); xTaskCreatePinnedToCore_IgnoreAndReturn(pdTRUE);
xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task);
vTaskDelete_Ignore(); vTaskDelete_Ignore();
} else { } else {
xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdTRUE); xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdTRUE);
xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task);
vTaskDelete_Expect(task); vTaskDelete_Expect(task);
} }
} }