Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asm: re-allow prop-testing with cargo test #10185

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

abrown
Copy link
Contributor

@abrown abrown commented Feb 4, 2025

In #10110, I originally intended to use arbitrary implementations in two ways: for long-running fuzz testing (e.g., with OSS-Fuzz) but also for quick property testing with cargo test. This latter use case could replace the tedious emit tests we had to write in cranelift-codegen and find corner cases that we otherwise might not explore. It helped me during development: just run cargo test to check if anything is obviously wrong. arbtest seemed to be able to run ~1000 test cases and found mistakes well within the one second time limit I gave it.

@alexcrichton improved #10110 by avoiding Arbitrary implementations everywhere and unconditionally depending on the arbitrary crate. This was the right change, but it removed the ability to property test using cargo test. What this change does is retain the general intent of his change (no extra dependencies) but add Arbitrary implementations for cfg(test) as well to run property tests during cargo test.

The only downside I see here is the added complexity when conditionally compiling the fuzz-related bits: #[cfg(any(test, feature = "fuzz"))]. Perhaps there is a better way to do this, but this seemed to work fine. Let me know what you think.

@abrown abrown requested review from a team as code owners February 4, 2025 18:32
@abrown abrown requested review from fitzgen and removed request for a team February 4, 2025 18:32
@abrown abrown force-pushed the assembler-fuzzing branch from 55658a3 to a836890 Compare February 4, 2025 18:36
In bytecodealliance#10110, I originally intended to use `arbitrary` implementations in
two ways: for long-running fuzz testing (e.g., with OSS-Fuzz) but also
for quick property testing with `cargo test`. This latter use case could
replace the tedious emit tests we had to write in `cranelift-codegen`
_and_ find corner cases that we otherwise might not explore. It helped
me during development: just run `cargo test` to check if anything is
obviously wrong. `arbtest` seemed to be able to run ~1000 test cases and
found mistakes well within the one second time limit I gave it.

@alexcrichton improved bytecodealliance#10110 by avoiding `Arbitrary` implementations
everywhere and unconditionally depending on the `arbitrary` crate. This
was the right change, but it removed the ability to property test using
`cargo test`. What this change does is retain the general intent of his
change (no extra dependencies) but add `Arbitrary` implementations for
`cfg(test)` as well to run property tests during `cargo test`.

The only downside I see here is the added complexity when conditionally
compiling the fuzz-related bits: `#[cfg(any(test, feature = "fuzz"))]`.
Perhaps there is a better way to do this, but this seemed to work fine.
Let me know what you think.
@abrown abrown force-pushed the assembler-fuzzing branch from a836890 to 0c591c5 Compare February 4, 2025 18:40
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Feb 4, 2025
@abrown
Copy link
Contributor Author

abrown commented Feb 4, 2025

cc: @alexcrichton, you might want to make sure this lines up with what you were thinking.

@alexcrichton
Copy link
Member

A little wonky but seems reasonable to me 👍

@alexcrichton alexcrichton added this pull request to the merge queue Feb 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 4, 2025
@alexcrichton alexcrichton added this pull request to the merge queue Feb 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 5, 2025
@alexcrichton
Copy link
Member

No reliable network for you!

@alexcrichton alexcrichton added this pull request to the merge queue Feb 5, 2025
Merged via the queue into bytecodealliance:main with commit d7d605c Feb 5, 2025
39 checks passed
@abrown abrown deleted the assembler-fuzzing branch February 5, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants