Skip to content

fix: prevent false-positive test results on signature length mismatch#102

Open
GiGiKoneti wants to merge 1 commit into
merledu:masterfrom
GiGiKoneti:fix/test-signature-comparison
Open

fix: prevent false-positive test results on signature length mismatch#102
GiGiKoneti wants to merge 1 commit into
merledu:masterfrom
GiGiKoneti:fix/test-signature-comparison

Conversation

@GiGiKoneti

@GiGiKoneti GiGiKoneti commented Apr 29, 2026

Copy link
Copy Markdown

Problem

In manual_run_riscv_arch_test.py, when the DUT signature and the
Spike reference signature have different lengths, the comparison
function writes "Failed" to the log but does not return early.

Execution falls through into the for-else loop (line 56-63), which
iterates over min(len(nrv_sig), len(ref_sig)). If the shorter
prefix happens to match, the loop completes without break, and
Python's for-else semantics trigger the else block — writing
"Passed" for the same test that was already marked "Failed".

This means a test where the core produces a truncated or extended
signature can silently appear as "Passed" in the final report.

Fix

  • Added an early return after the length-mismatch check.
  • Replaced the for-else pattern with explicit return statements
    to make the control flow unambiguous.
  • Used range(len(nrv_sig)) instead of range(min(...)) since
    lengths are now guaranteed equal at that point.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved test validation to immediately flag signature mismatches, ensuring faster failure detection and more accurate test result reporting in RISC-V architecture testing.

When the DUT signature and reference signature have different lengths,
the comparison function writes 'Failed' but does not return early.
The subsequent for-else loop then iterates over the shorter prefix,
and if no mismatch is found within that prefix, the else-block writes
'Passed' for the same test.

This patch adds an early return after the length check and replaces
the for-else pattern with explicit returns to make the control flow
unambiguous.
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ddf129a-e27b-4a62-962c-8e4ba8e593b1

📥 Commits

Reviewing files that changed from the base of the PR and between d5148d4 and 2aab206.

📒 Files selected for processing (1)
  • manual_run_riscv_arch_test.py

📝 Walkthrough

Walkthrough

The simulate_and_compare function's control flow was modified to immediately fail and return when signature lengths mismatch, and to return on the first signature line difference rather than using break/else logic for determining pass/fail outcomes.

Changes

Cohort / File(s) Summary
Control Flow Refinement
manual_run_riscv_arch_test.py
Modified simulate_and_compare to immediately fail on signature length mismatches and return early on first differing line, replacing break/else logic with explicit return statements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through logic clean,
Where mismatches are quickly seen,
No more lingering in the fray,
Early returns save the day! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'fix: prevent false-positive test results on signature length mismatch' accurately and clearly summarizes the main change: fixing a bug where mismatched signature lengths could produce false-positive test results.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@GiGiKoneti

Copy link
Copy Markdown
Author

@Talha-Ahmed-1
Please review this PR

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