Skip to content

Run every native test CI builds, and fail when one cannot be built - #160

Merged
kwsantiago merged 3 commits into
mainfrom
native-tests-cjson
Aug 3, 2026
Merged

Run every native test CI builds, and fail when one cannot be built#160
kwsantiago merged 3 commits into
mainfrom
native-tests-cjson

Conversation

@kwsantiago

@kwsantiago kwsantiago commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The native test job compiled 14 test binaries and executed 5. Three more were never built at all. Every check was green throughout.

What was not running

test_protocol, test_coordinator and test_coordinator_race are gated on ${CJSON_DIR}/cJSON.c, which lives under managed_components/. That directory is generated by the IDF component manager and excluded by .gitignore, and this job never runs an IDF build, so the path is absent on a fresh checkout. CMake configured those targets away with a STATUS message, and the job then guarded the run with [ ! -f ./test_protocol ] || ./test_protocol, so a binary that was never built read as a pass. The CI log shows it plainly:

-- Skipping test_protocol (cJSON not found)
-- Skipping test_coordinator (cJSON not found)

A further seven were compiled every run and never executed, because the list of tests to run was maintained by hand and had drifted from the list of tests that exist: test_anti_glitch, test_hw_entropy, test_hw_entropy_sha, test_integration, test_psbt_fraud, test_secresult, test_self_test.

test_protocol covers protocol parsing, which is a trust boundary on this device. test_coordinator_race is a ThreadSanitizer race test. test_hw_entropy and test_self_test cover the entropy path behind the v0.2.1 fix.

Changes

cJSON discovery now prefers the vendored copy when a build has produced it, so tests compile the same cJSON as the firmware, and otherwise falls back to a system cJSON, which is what a bare checkout has. REQUIRE_ALL_TESTS turns "not found" into a configure error; CI sets it, so a dependency that quietly disappears fails the job instead of taking its tests with it. Local developers can still configure without it.

The job now runs every executable it built rather than a fixed list, so a new test is picked up by existing it, and collects failures instead of stopping at the first.

Verification

Both discovery paths were exercised. With managed_components/ present, configuration reports cJSON: vendored. With it moved aside, reproducing a fresh checkout, it reports cJSON: system and all four previously-skipped targets build and pass.

The full suite was built and run locally before changing the job, to confirm that enabling seven previously-unexecuted binaries would not turn CI red: 18 built, 18 passed, 0 failed.

Summary by CodeRabbit

  • Tests

    • Expanded native test execution to automatically run all built test programs and report failures consistently.
    • Improved handling of cJSON-dependent tests, supporting both bundled and system installations.
    • Added an option to require all tests and treat unavailable test dependencies as failures when enabled.
  • Chores

    • Updated continuous integration setup to install required native testing dependencies and validate the complete test suite.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kwsantiago, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a7a5fb53-fc7d-4b15-90a5-58fcf55425f2

📥 Commits

Reviewing files that changed from the base of the PR and between 739054c and bdfd016.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Walkthrough

The native test setup now supports vendored or system cJSON. CI enables all tests, discovers every built test executable, records failures, and fails the job when any test fails.

Changes

Native test infrastructure

Layer / File(s) Summary
cJSON discovery and test target wiring
.github/workflows/ci.yml, test/native/CMakeLists.txt
CMake detects vendored or system cJSON. cJSON-dependent tests build only when cJSON is available, unless REQUIRE_ALL_TESTS makes it required. The resolved sources, headers, and libraries are used by the native test targets.
Complete native test execution
.github/workflows/ci.yml
CI installs libcjson-dev, enables REQUIRE_ALL_TESTS, runs every built test_* executable, accumulates failures, and exits nonzero when a test fails.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: wksantiago

Poem

A rabbit checks each test in line,
With cJSON ready, all can run fine.
No missing test slips away,
Failures speak at close of day.
Hop, hop—builds report what they say!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main CI change: build and run every native test, and fail when a required test cannot be built.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch native-tests-cjson

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 150: Fix the unmatched double quote in the native-test step’s echo
command so the “All native tests passed.” message is a complete shell string and
the workflow can parse and execute the build and tests.
- Around line 127-150: Add a job-level permissions block to the native-tests job
with contents set to read, without granting additional scopes unless an existing
command in that job explicitly requires them. Keep the current test execution
steps unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68a19eaa-1096-4a8c-b3ee-4a6f48ab5844

📥 Commits

Reviewing files that changed from the base of the PR and between 47336e8 and 739054c.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • test/native/CMakeLists.txt

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
@kwsantiago
kwsantiago merged commit 1095abb into main Aug 3, 2026
12 checks passed
@kwsantiago
kwsantiago deleted the native-tests-cjson branch August 3, 2026 21:05
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.

1 participant