From 7ade650065a2693f41e3a858bfb25881bac06e9d Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 13 Dec 2024 15:30:20 +0100 Subject: ci: Run a fuzzy test also for the assembler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++-- lib/xixanta/fuzz/Cargo.toml | 7 +++++++ lib/xixanta/fuzz/fuzz_targets/fuzz_target_2.rs | 10 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 lib/xixanta/fuzz/fuzz_targets/fuzz_target_2.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db5bc23..589ccbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Run Clippy run: cargo clippy --all-targets --all-features - fuzz: + fuzz_parser: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -42,7 +42,28 @@ jobs: - name: Build with nightly run: cargo build --verbose - - name: Fuzzy testing + - name: Fuzzy test the parser run: | cd lib/xixanta cargo +nightly fuzz run fuzz_target_1 -- -max_total_time=180 + + fuzz_assembler: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update rust toolchain to nightly + run: | + rustup update nightly + rustup default nightly + + - name: Install cargo fuzz + run: cargo install cargo-fuzz + + - name: Build with nightly + run: cargo build --verbose + + - name: Fuzzy test the assembler + run: | + cd lib/xixanta + cargo +nightly fuzz run fuzz_target_2 -- -max_total_time=180 diff --git a/lib/xixanta/fuzz/Cargo.toml b/lib/xixanta/fuzz/Cargo.toml index 3b3498d..0c0376d 100644 --- a/lib/xixanta/fuzz/Cargo.toml +++ b/lib/xixanta/fuzz/Cargo.toml @@ -22,3 +22,10 @@ path = "fuzz_targets/fuzz_target_1.rs" test = false doc = false bench = false + +[[bin]] +name = "fuzz_target_2" +path = "fuzz_targets/fuzz_target_2.rs" +test = false +doc = false +bench = false diff --git a/lib/xixanta/fuzz/fuzz_targets/fuzz_target_2.rs b/lib/xixanta/fuzz/fuzz_targets/fuzz_target_2.rs new file mode 100644 index 0000000..111bae9 --- /dev/null +++ b/lib/xixanta/fuzz/fuzz_targets/fuzz_target_2.rs @@ -0,0 +1,10 @@ +#![no_main] + +use libfuzzer_sys::fuzz_target; +use xixanta::assembler::Assembler; +use xixanta::mapping::EMPTY; + +fuzz_target!(|data: &[u8]| { + let mut asm = Assembler::new(EMPTY.to_vec()); + let _ = asm.assemble(data); +}); -- cgit v1.2.3