afl: add main file
for testing that crashes have been resolved previously, binary of the main crate was used, but targets may have more validation than simply checking for panics
This commit is contained in:
parent
3e56903885
commit
8f70f596b9
3 changed files with 24 additions and 3 deletions
5
Makefile
5
Makefile
|
@ -78,13 +78,12 @@ afl_quick:
|
||||||
afl_crash:
|
afl_crash:
|
||||||
set +e; \
|
set +e; \
|
||||||
for f in $$(find tests/afl/out -path '*/${AFL_TARGET_CRASH}/id*'); do \
|
for f in $$(find tests/afl/out -path '*/${AFL_TARGET_CRASH}/id*'); do \
|
||||||
echo "cat $$f | RUST_BACKTRACE=1 cargo run"; \
|
echo $$f; \
|
||||||
out=$$(cat $$f | RUST_BACKTRACE=1 cargo run 2>&1); \
|
out=$$(cat $$f | (cd tests/afl && RUST_BACKTRACE=1 cargo run ${AFL_TARGET} 2>&1)); \
|
||||||
if [ $$? -ne 0 ]; then \
|
if [ $$? -ne 0 ]; then \
|
||||||
echo; \
|
echo; \
|
||||||
echo "FAIL"; \
|
echo "FAIL"; \
|
||||||
echo "$$out"; \
|
echo "$$out"; \
|
||||||
echo "cat $$f | RUST_BACKTRACE=1 cargo run"; \
|
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
|
@ -2,11 +2,16 @@
|
||||||
name = "jotdown-afl"
|
name = "jotdown-afl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
default-run = "main"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
afl = "0.11"
|
afl = "0.11"
|
||||||
jotdown = { path = "../../", features = ["deterministic"] }
|
jotdown = { path = "../../", features = ["deterministic"] }
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "main"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "parse"
|
name = "parse"
|
||||||
path = "src/parse.rs"
|
path = "src/parse.rs"
|
||||||
|
|
17
tests/afl/src/main.rs
Normal file
17
tests/afl/src/main.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut args = std::env::args();
|
||||||
|
let _program = args.next();
|
||||||
|
let target = args.next().expect("no target");
|
||||||
|
assert_eq!(args.next(), None);
|
||||||
|
|
||||||
|
let f = match target.as_str() {
|
||||||
|
"parse" => jotdown_afl::parse,
|
||||||
|
_ => panic!("unknown target '{}'", target),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut input = Vec::new();
|
||||||
|
std::io::stdin().read_to_end(&mut input).unwrap();
|
||||||
|
f(&input);
|
||||||
|
}
|
Loading…
Reference in a new issue