Skip to content

fix(tests): print the real total in test_boot_log's summary - #170

Merged
Aswin-V merged 1 commit into
masterfrom
fix/test-boot-log-summary-format
Nov 9, 2026
Merged

Aswin-V merged 1 commit into
masterfrom
fix/test-boot-log-summary-format

Conversation

@Kartikey1306

@Kartikey1306 Kartikey1306 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

tests/unit/test_boot_log.c:303 printed its summary with printf("\n%d/%d tests passed\n", tests_passed): two conversions, one argument. Every run printed 11/<garbage> tests passed (11/-1999466112 on 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

  • feat — New feature
  • fix — Bug fix
  • docs — Documentation only
  • style — Formatting, no code change
  • refactor — Code restructuring without behavior change
  • test — Add or fix tests
  • build — Build system or dependency changes
  • ci — CI/CD pipeline changes
  • perf — Performance improvement

Changes

  • tests/unit/test_boot_log.c: add tests_run, incremented by RUN before each test, and print tests_passed, tests_run. A failed ASSERT calls exit(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.
    • What gets the flag: those test programs, including the non-test sources they compile directly: core/keystore.c, stage0/jump_stage1.c, stage0/recovery_entry.c, stage0/watchdog.c and the generated test_production_key.c. All of them compile cleanly with it today.
    • What does not: the eboot_core, eboot_hal and eboot_stage1 libraries, every firmware or cross build (tests/ is only added for native builds, CMakeLists.txt:519), the fuzz harnesses in tests/fuzz/, and MSVC.
    • GCC scope: on GCC, -Werror=format also turns -Wformat-overflow and -Wformat-truncation into 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 truncating snprintf in a test.

Testing

  • Unit tests pass (ctest --test-dir build --output-on-failure): 36/36
  • Integration tests pass (not run; no integration suite touched)
  • Manual testing performed: the summary line before and after
  • New tests added for new functionality: the build guard is the regression check. With it, the old test_boot_log.c fails to build at line 303.

macOS arm64, Apple clang (CommandLineTools, SDKROOT=MacOSX26.5.sdk), base 8f292909, head bdfe6d3.

Check Command Result
Defect at base 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) FAIL (reproduces): 11/-1999466112 tests passed on 3 of 3 runs; the build warns -Wformat-insufficient-args
Fail before: guard + old test_boot_log.c same build, tests/CMakeLists.txt from head, test_boot_log.c from base FAIL (expected): test_boot_log.c:303:19: error: more '%' conversions than data arguments [-Werror,-Wformat-insufficient-args], build exit 1
Pass after: build same build at head PASS: exit 0, 0 format warnings (the only warning is the existing dev-key #warning in core/keystore.c:45)
Where the flag lands jq over compile_commands.json 42 compile entries carry -Werror=format, all in test targets; 0 of the 42 eboot_core/eboot_hal/eboot_stage1 library objects do
Summary line ./build/tests/eboot_test_boot_log | tail -1 PASS: 11/11 tests passed
Unit tests ctest --test-dir build --output-on-failure --no-tests=error -j2 --timeout 120 PASS: 36/36
Linux GCC (12.3.0) master CI run 41501662283, "Build & Test (Linux x86_64)" log, grep Wformat 1 format warning in that job, and it is test_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 evidence
Whitespace git diff --check 8f292909 HEAD PASS

Out of scope: the ARM cross build on master has 10 -Wformat= warnings in core/power_init.c:84, core/bmc_handoff.c:55 and core/ecc_scrub.c:65 (uint32_t is long unsigned int on newlib). This PR doesn't touch library or firmware flags; they are worth a separate issue.

Pre-Submission Checklist

  • Code compiles without warnings (-Wall -Wextra -Werror for C): no new warnings; the existing dev-key #warning remains
  • All existing tests pass
  • New tests added for new functionality: build guard, see Testing
  • Documentation updated if API changed (no API change)
  • Commit messages follow (): convention
  • Branch is rebased on latest master (8f292909)

Related Issues

None besides the closing issue.

Closing issue

Fixes #169

Screenshots / Logs

Before and after

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 Clang and 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:

  • Fix the boot-log unit test summary to report the actual number of tests run instead of reading a missing format argument.

Build:

  • Treat printf format warnings as build errors for native unit-test executables built with GCC and Clang.

Tests:

  • Use the unit-test build configuration as a regression check for format-string argument mismatches.

Summary by CodeRabbit

  • Tests
    • Test summaries now show the number of tests passed alongside the total number run.
  • Build
    • GNU and Clang builds apply stricter format-warning checks to applicable test executables. Other compiler types and non-executable targets are unchanged.

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
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Make format warnings errors for registered GCC and Clang unit-test executables to prevent similar summary-format bugs from passing unnoticed.

  • tests/CMakeLists.txt L330-343

Tests

Count tests as they start and use that count in the test_boot_log summary, fixing its missing printf argument.

  • tests/unit/test_boot_log.c L21, L36, L305

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kody-ai

kody-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown

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. 😎

@qodo-code-review

Copy link
Copy Markdown

ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The test build now treats format warnings as errors for matching GNU and Clang eboot_ executables. The boot-log test counts each test invocation and uses that count in its final passed/total summary.

Changes: Test format reporting

Layer / File(s) Summary
Format checks and test summary
tests/unit/test_boot_log.c, tests/CMakeLists.txt
The boot-log test counts each RUN invocation and prints the count in its passed/total summary. GNU and Clang builds apply -Werror=format to matching eboot_ executable targets.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to bdfe6

The test summary reports the run count, and format mismatches are guarded in eligible test builds. No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #169 has two coding requirements.

1. Correct summary line (11/11 tests passed). Source evidence supports this. The head diff of tests/unit/test_boot_log.c adds static int tests_run, increment…
Provide the tests/CMakeLists.txt hunk, or the head file content after the target namespace guard, so the -Werror=format block can be checked. The check must confirm which targets receive the flag and that the eboot_core, eboot_hal and eboot…
Passed Passed checks: 4 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the test_boot_log summary now prints the real total. It also uses the conventional fix(tests) prefix. The objectives confirm the summary now counts tests as RUN starts…
Out of Scope Changes check Passed The changes reported for this PR touch two files: tests/unit/test_boot_log.c and tests/CMakeLists.txt. The test_boot_log.c change is the direct fix for the wrong summary line in #169. The tests/CMakeL…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the main change: the test_boot_log summary now prints the real total. It also uses the conventional fix(tests) prefix. The objectives confirm the summary now counts tests as RUN starts them and prints tests_passed/tests_run, which matches the title. The title does not mention the added -Werror=format build change, but that is a secondary change, so the title remains accurate and specific.

Full details: Out of Scope Changes check

Explanation

The changes reported for this PR touch two files: tests/unit/test_boot_log.c and tests/CMakeLists.txt. The test_boot_log.c change is the direct fix for the wrong summary line in #169. The tests/CMakeLists.txt change is the build guard that #169 requests. The PR description and the supplied summary report no library, firmware, or cross-build flag changes. No unrelated change was found in the verified source. The exact extent of the CMake guard was not confirmed from source (see the linked-issue assessment). The guard is tied to #169 in any case.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

Full details: Linked Issues check

Explanation

Issue #169 has two coding requirements.

  1. Correct summary line (11/11 tests passed). Source evidence supports this. The head diff of tests/unit/test_boot_log.c adds static int tests_run, increments it in RUN before each test, and prints tests_passed, tests_run. Each RUN call increments both counters, and a failed ASSERT exits before the summary. The two values match when the line prints. The 11/11 output comes from PR logs and was not rerun here.

  2. A format or argument mismatch in a test fails the build. Not verified. The tests/CMakeLists.txt diff was unavailable because changed blobs are missing from the checkout. Reading the head file returned only the first 16000 bytes. The block after the target namespace guard, where the -Werror=format logic should be, was cut off. The base file could not be read. The AI-generated summary reports +14 lines that apply -Werror=format to GNU and Clang builds of eboot_ executable targets. That summary is not source evidence.

Resolution

Provide the tests/CMakeLists.txt hunk, or the head file content after the target namespace guard, so the -Werror=format block can be checked. The check must confirm which targets receive the flag and that the eboot_core, eboot_hal and eboot_stage1 libraries do not.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f91eb8bc-2c6a-4a7f-b7ca-633dcfd4e2e5
Commits

Reviewing files that changed from the base of the PR and between 8f29290 and bdfe6d3.

Files selected for processing: 2

  • tests/CMakeLists.txt
  • tests/unit/test_boot_log.c

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix boot log test summary and enforce format checks

🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Fix the boot log test summary to print the actual number of tests run.
• Make format warnings build errors for GCC and Clang unit-test executables, preventing similar
 mistakes.
Diagram

graph TD
  A["Boot log suite"] --> B["RUN counters"] --> C["Pass summary"]
  D["Native CMake"] --> E{"GCC or Clang?"} -->|Yes| F["Test executables"] --> G["Format errors"]
Loading
High-Level Assessment

The scoped approach fits the defect: count tests rather than hardcode the total, and enforce format checks where the faulty output originated. Applying the flag to shared libraries or firmware would broaden the change without addressing this test-program regression.

Files changed (2) +17 / -1

Bug fix (1) +3 / -1
test_boot_log.cPrint the actual boot log test total +3/-1

Print the actual boot log test total

• Counts tests when RUN starts them and supplies that count as the missing printf argument. The summary now reports the actual passed and run totals instead of reading an undefined argument.

tests/unit/test_boot_log.c

Other (1) +14 / -0
CMakeLists.txtMake unit-test format warnings build errors +14/-0

Make unit-test format warnings build errors

• Applies -Werror=format to executable targets registered in this directory when using GCC or Clang. The flag covers sources compiled directly into those executables without changing linked libraries, fuzz targets, or firmware builds.

tests/CMakeLists.txt

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Qodo Logo

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@Aswin-V
Aswin-V merged commit 26b3d0f into master Nov 9, 2026
36 checks passed
@Aswin-V
Aswin-V deleted the fix/test-boot-log-summary-format branch November 9, 2026 19:15
@Aswin-V

Aswin-V commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Premise: pass — master tests/unit/test_boot_log.c:303 prints "%d/%d" with one argument (garbage second value); fixes #169.
Contract: n/a — test-only (tests_run counter; -Werror=format for unit-test targets).
CI: https://github.com/embeddedos-org/eBoot/pull/170/checks @ bdfe6d3 (36 checks green).
Integration: n/a.
Reviewer: loop run 2026-11-09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_boot_log prints "11/<garbage> tests passed": its summary printf has two %d and one argument

2 participants