Repository navigation
fix(tests): print the real total in test_boot_log's summary - #170
Conversation
test_boot_log ended with printf("\n%d/%d tests passed\n", tests_passed):
two conversions, one argument. The second %d read whatever was in the
next argument register, so every run printed "11/<garbage> tests passed"
(11/-1999466112 on macOS arm64, the same on three runs). The compiler
warned about it on every build (-Wformat-insufficient-args) and nothing
failed.
Count the tests as RUN starts them and print tests_passed/tests_run.
Guard the class as well: on GCC and Clang, the unit-test programs
registered in tests/CMakeLists.txt now compile with -Werror=format, so
a format warning in a test's output fails the build. That includes the
non-test sources those programs compile directly (core/keystore.c,
stage0/jump_stage1.c, stage0/recovery_entry.c, stage0/watchdog.c and the
generated test_production_key.c). The eboot_core, eboot_hal and
eboot_stage1 libraries, every firmware/cross build and the fuzz harnesses
in tests/fuzz are unchanged. On GCC, -Werror=format also makes
-Wformat-overflow and -Wformat-truncation errors in those programs.
Fail before / pass after (macOS arm64, Apple clang, Release, tests on):
- guard + old test_boot_log.c: build fails at test_boot_log.c:303:19,
"more '%' conversions than data arguments"
- guard + this fix: build OK, 0 format warnings, summary
"11/11 tests passed", ctest 36/36
Reviewer's GuideConfigurationMake format warnings errors for registered GCC and Clang unit-test executables to prevent similar summary-format bugs from passing unnoticed.
TestsCount tests as they start and use that count in the test_boot_log summary, fixing its missing printf argument.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
You've used all your free Kodus-paid PR reviews 🎁Your trial is still active — this just means the PR reviews we cover during the trial are used up. Connect your own AI key to keep Kody reviewing — unlimited reviews, on any plan (Free included). Want more trial reviews to finish evaluating before adding a key? Talk to our founders. 😎 |
|
ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
PR Summary by QodoFix boot log test summary and enforce format checks
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#169 test_boot_log prints "11/<garbage> tests passed": its summary printf has two %d and one argument · 2 of 2 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Print the actual test total in the boot-log summary | ✅ Met | tests_run increments for each RUN, and the summary prints tests_passed and tests_run. |
| 2 | Make format/argument mismatches in tests fail the build | ✅ Met | The CMake change adds -Werror=format to executable targets in this tests directory when using GCC or Clang. |
Sourcery assessment
Approved.
|
Premise: pass — master tests/unit/test_boot_log.c:303 prints "%d/%d" with one argument (garbage second value); fixes #169. |
Summary
tests/unit/test_boot_log.c:303printed its summary withprintf("\n%d/%d tests passed\n", tests_passed): two conversions, one argument. Every run printed11/<garbage> tests passed(11/-1999466112on macOS arm64). This PR prints the real total. It also makes a format warning in the unit-test programs a build error, so the next one fails the build instead of printing a wrong number.Type of Change
Changes
tests/unit/test_boot_log.c: addtests_run, incremented byRUNbefore each test, and printtests_passed, tests_run. A failedASSERTcallsexit(1), so the two numbers are always equal when the line prints. The point is to remove the undefined read and show the real count.tests/CMakeLists.txt: on GCC and Clang, the unit-test programs registered in this file compile with-Werror=format. The guard reuses the target list the namespace guard above it already collects.core/keystore.c,stage0/jump_stage1.c,stage0/recovery_entry.c,stage0/watchdog.cand the generatedtest_production_key.c. All of them compile cleanly with it today.eboot_core,eboot_halandeboot_stage1libraries, every firmware or cross build (tests/is only added for native builds,CMakeLists.txt:519), the fuzz harnesses intests/fuzz/, and MSVC.-Werror=formatalso turns-Wformat-overflowand-Wformat-truncationinto errors in those programs. Neither fires today (see the gcc 12.3 CI evidence below). Both depend on GCC version and optimisation level, so a newer GCC could flag an intentionally truncatingsnprintfin a test.Testing
test_boot_log.cfails to build at line 303.macOS arm64, Apple clang (CommandLineTools,
SDKROOT=MacOSX26.5.sdk), base8f292909, headbdfe6d3.cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DEBLDR_BUILD_TESTS=ON && cmake --build build -j2 && ./build/tests/eboot_test_boot_log | tail -1(base)11/-1999466112 tests passedon 3 of 3 runs; the build warns-Wformat-insufficient-argstest_boot_log.ctests/CMakeLists.txtfrom head,test_boot_log.cfrom basetest_boot_log.c:303:19: error: more '%' conversions than data arguments [-Werror,-Wformat-insufficient-args], build exit 1#warningincore/keystore.c:45)jqovercompile_commands.json-Werror=format, all in test targets; 0 of the 42eboot_core/eboot_hal/eboot_stage1library objects do./build/tests/eboot_test_boot_log | tail -111/11 tests passedctest --test-dir build --output-on-failure --no-tests=error -j2 --timeout 120grep Wformattest_boot_log.c:303:19, which this PR fixes. Nothing else for the guard to fail on. The head build on GCC is NOT RUN locally; this PR's CI run is the evidencegit diff --check 8f292909 HEADOut of scope: the ARM cross build on master has 10
-Wformat=warnings incore/power_init.c:84,core/bmc_handoff.c:55andcore/ecc_scrub.c:65(uint32_tislong unsigned inton newlib). This PR doesn't touch library or firmware flags; they are worth a separate issue.Pre-Submission Checklist
#warningremains8f292909)Related Issues
None besides the closing issue.
Closing issue
Fixes #169
Screenshots / Logs
Raw logs:
raw-run-before.log,raw-build-before.log,raw-after.log,ci-master-format-warnings.log.Additional Notes
Only the test harness and the test build change; no bootloader code changes. clang-cl would also report itself as
Clangand get the flag. No workflow uses clang-cl.Summary by Sourcery
Fix the boot-log test summary and prevent format-string warnings from producing misleading test results.
Bug Fixes:
Build:
Tests:
Summary by CodeRabbit