Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,17 @@ foreach(_t IN LISTS _eboot_test_targets)
endif()
endforeach()

# --- printf format guard ---
#
# A format warning in a unit-test program is an error: test_boot_log once
# printed "11/<garbage> tests passed" behind a warning nobody acted on.
# Applies to the unit-test programs in this directory (and the sources they
# compile directly); the libraries, firmware and tests/fuzz are unchanged.
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
foreach(_t IN LISTS _eboot_test_targets)
get_target_property(_type ${_t} TYPE)
if(_type STREQUAL "EXECUTABLE")
target_compile_options(${_t} PRIVATE -Werror=format)
endif()
endforeach()
endif()
4 changes: 3 additions & 1 deletion tests/unit/test_boot_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string.h>
#include <stdlib.h>

static int tests_run = 0;
static int tests_passed = 0;

#define ASSERT(condition) \
Expand All @@ -32,6 +33,7 @@ static int tests_passed = 0;
#define RUN(test) \
do { \
reset_fixture(); \
tests_run++; \
test(); \
tests_passed++; \
printf("[PASS] %s\n", #test); \
Expand Down Expand Up @@ -300,6 +302,6 @@ int main(void)
RUN(test_clear_reports_erase_failure);
RUN(test_append_does_not_advance_head_when_write_fails);
RUN(test_entry_layout_is_stable);
printf("\n%d/%d tests passed\n", tests_passed);
printf("\n%d/%d tests passed\n", tests_passed, tests_run);
return 0;
}
Loading