Skip to content

cstest: Compare the PPC branch details once and without requiring operands - #3058

Open
phix33 wants to merge 1 commit into
capstone-engine:nextfrom
phix33:cstest-ppc-bc-hoist
Open

cstest: Compare the PPC branch details once and without requiring operands#3058
phix33 wants to merge 1 commit into
capstone-engine:nextfrom
phix33:cstest-ppc-bc-hoist

Conversation

@phix33

@phix33 phix33 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

A ppc test case that supplies bc: expectations but no operands: passes without comparing anything. tests/details/ppc.yaml already has one (bdnzlrl+): change any of its bc: values to garbage —

             bo: 99            # was 25

and cstest tests/details/ppc.yaml still reports all tests succeeded.

  • test_expected_ppc returned early when expected->operands_count == 0, and the whole expected->bc block sat inside the operand loop so branch details were compared once per operand, or not at all for an operand-less case. The block is hoisted out of the loop and the early return replaced with a guard around the operand comparison only.
  • The operand loop now iterates expected->operands_count rather than actual->op_count: with the early return gone, the old bound would dereference a NULL expected->operands[i] for an operand-less case.

Test plan

One new case: bdnzflr 4*cr5+eq (4c 16 00 20) with a full bc: block and deliberately no operands:. Any wrong value in it (or in the existing bdnzlrl+ case) passes on unpatched next and fails with this fix.

The other arch comparers don't have this shape: only ppc keeps an instruction-wide block inside its operand loop; the aarch64/arm/sparc/x86 early returns skip operand comparisons only.

Closing issues

None.

@github-actions github-actions Bot added the PowerPC Arch label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant