From 9483d88a18dbe6d84ac4b86c30009c2b0ff19f52 Mon Sep 17 00:00:00 2001 From: erlingrj Date: Mon, 20 May 2024 22:54:51 +0200 Subject: [PATCH] Add another simple test and merge lcov reports --- test/CMakeLists.txt | 23 ++++++++++++----------- test/event_queue_test.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 test/event_queue_test.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d1250b0b..09f7f43c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,27 +21,28 @@ foreach(FILE ${TEST_SOURCES}) ) set_target_properties(${NAME} PROPERTIES C_CLANG_TIDY "") # Disable clang-tidy for this external lib. - if(TEST_COVERAGE) - set(COVERAGE_TARGET ${NAME}_cov) - setup_target_for_coverage_lcov( - NAME ${COVERAGE_TARGET} - EXECUTABLE ${NAME} +endforeach(FILE ${TEST_FILES}) + +if(TEST_COVERAGE) + setup_target_for_coverage_lcov( + NAME coverage + EXECUTABLE ctest EXCLUDE "external/Unity/**" - "examples/" + "examples/**" + "test/**" LCOV_ARGS --rc lcov_branch_coverage=1 - GENHTML_ARGS --rc lcov_branch_coverage=1) + GENHTML_ARGS --rc lcov_branch_coverage=1 + DEPENDENCIES reaction_queue_test_c event_queue_test_c) add_custom_target(run_lcov ALL - DEPENDS ${COVERAGE_TARGET} + DEPENDS coverage ) add_custom_command( TARGET run_lcov POST_BUILD - COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_BINARY_DIR} ${COVERAGE_TARGET} + COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_BINARY_DIR} coverage COMMENT "Running lcov on the test" ) endif() -endforeach(FILE ${TEST_FILES}) - diff --git a/test/event_queue_test.c b/test/event_queue_test.c new file mode 100644 index 00000000..bdd9191f --- /dev/null +++ b/test/event_queue_test.c @@ -0,0 +1,16 @@ +#include "unity.h" + +#define EVENT_QUEUE_SIZE 5 +#include "reactor-uc/queues.h" + +void test_insert(void) { + EventQueue q; + EventQueue_ctor(&q); + TEST_ASSERT_TRUE(q.empty(&q)); +} + +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_insert); + return UNITY_END(); +} \ No newline at end of file