Skip to content

Commit

Permalink
Add another simple test and merge lcov reports
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed May 20, 2024
1 parent f0819de commit 9483d88
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

16 changes: 16 additions & 0 deletions test/event_queue_test.c
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 9483d88

Please sign in to comment.