Remove old tests and reexport libfuzzer from fuzzing module (#69)

* Remove unused regalloc2-test crate

This code doesn't build, and Chris says it's "a really old harness that
existed prior to building the fuzzing and was used mainly to profile and
get stats before integration with Cranelift".

* Re-export libfuzzer/arbitrary from fuzzing module

This avoids needing to keep dependencies on `arbitrary` in sync across
the three different Cargo.toml files in this project.

However, before version 0.4.2, libfuzzer-sys only supported using its
macros if it was available at the top-level `libfuzzer_sys` path, which
breaks when re-exporting it. So I'm upgrading to that version (or the
newest patch release of it).

Upgrading libfuzzer-sys in turn brings in the 1.0 release of the
arbitrary crate, with a minor API change along the way.
This commit is contained in:
Jamey Sharp
2022-08-03 14:28:37 -07:00
committed by GitHub
parent 1f915bb9b6
commit 47cb8234b6
12 changed files with 23 additions and 166 deletions

View File

@@ -11,8 +11,6 @@ cargo-fuzz = true
[dependencies]
regalloc2 = { path = "../", features = ["fuzzing"] }
libfuzzer-sys = "0.3"
arbitrary = { version = "^0.4.6", features = ["derive"] }
log = { version = "0.4.8", default-features = false }
env_logger = "0.8.3"

View File

@@ -4,15 +4,11 @@
*/
#![no_main]
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
use regalloc2::fuzzing::{domtree, fuzz_target, postorder};
use regalloc2::Block;
use std::collections::HashSet;
use regalloc2::{
fuzzing::{domtree, postorder},
Block,
};
#[derive(Clone, Debug)]
struct CFG {
num_blocks: usize,
@@ -20,7 +16,7 @@ struct CFG {
succs: Vec<Vec<Block>>,
}
impl Arbitrary for CFG {
impl Arbitrary<'_> for CFG {
fn arbitrary(u: &mut Unstructured) -> Result<CFG> {
let num_blocks = u.int_in_range(1..=1000)?;
let mut succs = vec![];
@@ -111,7 +107,7 @@ struct TestCase {
path: Path,
}
impl Arbitrary for TestCase {
impl Arbitrary<'_> for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
let cfg = CFG::arbitrary(u)?;
let path = Path::choose_from_cfg(&cfg, u)?;

View File

@@ -4,9 +4,8 @@
*/
#![no_main]
use libfuzzer_sys::fuzz_target;
use regalloc2::fuzzing::func::Func;
use regalloc2::fuzzing::fuzz_target;
fuzz_target!(|func: Func| {
let _ = env_logger::try_init();

View File

@@ -4,18 +4,17 @@
*/
#![no_main]
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
use regalloc2::fuzzing::checker::Checker;
use regalloc2::fuzzing::func::{Func, Options};
use regalloc2::fuzzing::fuzz_target;
#[derive(Clone, Debug)]
struct TestCase {
func: Func,
}
impl Arbitrary for TestCase {
impl Arbitrary<'_> for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
Ok(TestCase {
func: Func::arbitrary_with_options(

View File

@@ -4,9 +4,8 @@
*/
#![no_main]
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
use regalloc2::fuzzing::fuzz_target;
use regalloc2::fuzzing::moves::{MoveAndScratchResolver, ParallelMoves};
use regalloc2::{Allocation, PReg, RegClass, SpillSlot};
use std::collections::{HashMap, HashSet};
@@ -17,7 +16,7 @@ struct TestCase {
available_pregs: Vec<Allocation>,
}
impl Arbitrary for TestCase {
impl Arbitrary<'_> for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<Self> {
let mut ret = TestCase {
moves: vec![],

View File

@@ -4,11 +4,10 @@
*/
#![no_main]
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
use regalloc2::fuzzing::cfg::CFGInfo;
use regalloc2::fuzzing::func::{Func, Options};
use regalloc2::fuzzing::fuzz_target;
use regalloc2::fuzzing::ssa::validate_ssa;
#[derive(Debug)]
@@ -16,7 +15,7 @@ struct TestCase {
f: Func,
}
impl Arbitrary for TestCase {
impl Arbitrary<'_> for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<Self> {
Ok(TestCase {
f: Func::arbitrary_with_options(