Skip to content

Test Python bindings in CI#2161

Merged
kabeor merged 6 commits intocapstone-engine:nextfrom
peace-maker:python_difftest_ci
Sep 15, 2023
Merged

Test Python bindings in CI#2161
kabeor merged 6 commits intocapstone-engine:nextfrom
peace-maker:python_difftest_ci

Conversation

@peace-maker
Copy link
Copy Markdown
Contributor

There is a test setup for the python bindings in the bindings/Makefile, which compare the output of the /tests/test_<arch> programs with the equivalent bindings/python/test_<arch>.py scripts. They weren't run in CI and the tests were heavily out of sync.

Comparing text output is annoying and the test-case coverage of the instructions in those old test binaries doesn't test all of the possible encodings, but this hopefully gets the job done of keeping the python bindings from getting out of sync.

This is the second attempt at #2086, this time with smaller changes outside the tests. The PPC bindings and ARM constants needed a little tweak in the last second which might be better off in a seperate PR again.. There always seems to be something while the codebase keeps moving -.-

There used to be tests comparing the output of the C test_* programs with
the equivalent test in the binding language. Update the tests to match
the Python bindings.
Don't build libcapstone using make again when running setup.py.
Use the library we built earlier.
print("\tgroups_count: %u" % len(insn.groups))

print_read_write_regs(insn)
print("\tgroups_count: %u" % len(insn.groups))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Better use formatted strings for those cases (f"\tgroups_count: {len(insn.groups)}" and the like). Also below and above. Its easier for future editing IMHO.
Maybe doesn't matter that much. Since this should be replaced anyway by some proper testing code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(f-strings aren't supported in python 2 too)

Copy link
Copy Markdown
Contributor

@XVilka XVilka left a comment

Choose a reason for hiding this comment

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

@kabeor @aquynh take a look please

@kabeor
Copy link
Copy Markdown
Member

kabeor commented Sep 15, 2023

Awesome, thanks!

@kabeor kabeor merged commit 9334b33 into capstone-engine:next Sep 15, 2023
@peace-maker peace-maker deleted the python_difftest_ci branch September 15, 2023 06:44
@Rot127 Rot127 mentioned this pull request Feb 1, 2026
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.

4 participants