Skip to content

Commit 3dcdc55

Browse files
authored
Merge pull request #450 from madsmtm/move-fuzzing
Move fuzzing crate
2 parents 486daca + e13a5e0 commit 3dcdc55

File tree

20 files changed

+122
-131
lines changed

20 files changed

+122
-131
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,11 @@ jobs:
733733
with:
734734
path: ~/.cargo/bin/cargo-fuzz
735735
# Change this key if we update the required cargo-fuzz version
736-
key: cargo-fuzz-${{ github.job }}-${{ matrix.name }}-v0-11-1
736+
key: cargo-fuzz-${{ github.job }}-${{ matrix.name }}-v0-11-2
737737

738738
- name: Install cargo-fuzz
739739
if: ${{ matrix.fuzz && steps.fuzz-cache.outputs.cache-hit != 'true' }}
740-
run: cargo install cargo-fuzz --version=^0.11.1
740+
run: cargo install cargo-fuzz --version=^0.11.2
741741

742742
- name: Test Foundation
743743
run: cargo test $ARGS --features=$INTERESTING_FEATURES,catch-all,Foundation
@@ -754,14 +754,14 @@ jobs:
754754
- name: Run fuzzing
755755
if: ${{ matrix.fuzz }}
756756
run: |
757-
# Run each target for 100000 runs (approx. 5 seconds), and timeout
758-
# after 2 seconds.
757+
# Run each fuzz target for 100000 runs (approx. 5 seconds), and
758+
# timeout after 2 seconds.
759759
#
760760
# We specify the number of runs explicitly instead of using
761761
# `max_total_time`, to get more determinism.
762-
for target in $(cargo-fuzz list)
762+
for fuzz_target in $(cargo-fuzz list --fuzz-dir=./crates/test-fuzz/)
763763
do
764-
cargo-fuzz run $target $ARGS -- -runs=10000 -timeout=2 -jobs=10
764+
cargo-fuzz run --fuzz-dir=./crates/test-fuzz/ $fuzz_target $ARGS,fuzz-all -- -runs=10000 -timeout=2 -jobs=10
765765
done
766766
767767
# Check if the fuzzer encountered something that should be added to

Cargo.lock

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

crates/test-fuzz/Cargo.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[package]
2+
name = "test-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4"
12+
objc2 = { path = "../objc2", default-features = false }
13+
icrate = { path = "../icrate", default-features = false }
14+
15+
[features]
16+
default = ["apple", "std"]
17+
std = ["icrate/std"]
18+
# Runtime
19+
apple = ["icrate/apple"]
20+
gnustep-1-7 = ["icrate/gnustep-1-7"]
21+
gnustep-1-8 = ["gnustep-1-7", "icrate/gnustep-1-8"]
22+
gnustep-1-9 = ["gnustep-1-8", "icrate/gnustep-1-9"]
23+
gnustep-2-0 = ["gnustep-1-9", "icrate/gnustep-2-0"]
24+
gnustep-2-1 = ["gnustep-2-0", "icrate/gnustep-2-1"]
25+
26+
# The features required for fuzzing all targets (used by CI)
27+
fuzz-all = ["icrate/Foundation", "icrate/Foundation_NSString"]
28+
29+
[[bin]]
30+
name = "class"
31+
path = "fuzz_targets/class.rs"
32+
test = false
33+
doc = false
34+
35+
[[bin]]
36+
name = "sel"
37+
path = "fuzz_targets/sel.rs"
38+
test = false
39+
doc = false
40+
41+
[[bin]]
42+
name = "encoding_parse"
43+
path = "fuzz_targets/encoding_parse.rs"
44+
test = false
45+
doc = false
46+
47+
[[bin]]
48+
name = "nsstring"
49+
path = "fuzz_targets/nsstring.rs"
50+
test = false
51+
doc = false
52+
required-features = ["icrate/Foundation", "icrate/Foundation_NSString"]

crates/test-fuzz/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Fuzzing `objc2`
2+
3+
Run using `cargo-fuzz` (note: you must specify the `--fuzz-dir` argument).
4+
5+
```sh
6+
cargo +nightly fuzz run --fuzz-dir=crates/test-fuzz/ $fuzz_target
7+
```
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)