Add initial support for cargo-fuzz
This commit is contained in:
parent
913cba02f7
commit
9bc23dd4c6
|
@ -0,0 +1,4 @@
|
|||
Cargo.lock
|
||||
target
|
||||
corpus
|
||||
artifacts
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
[package]
|
||||
name = "tectonic-fuzz"
|
||||
version = "0.0.1"
|
||||
authors = ["Automatically generated"]
|
||||
publish = false
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies.tectonic]
|
||||
path = ".."
|
||||
[dependencies.libfuzzer-sys]
|
||||
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "compile"
|
||||
path = "fuzz_targets/compile.rs"
|
|
@ -0,0 +1,9 @@
|
|||
#![no_main]
|
||||
#[macro_use] extern crate libfuzzer_sys;
|
||||
extern crate tectonic;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if let Ok(data) = std::str::from_utf8(data) {
|
||||
let _ = tectonic::latex_to_pdf(data);
|
||||
}
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PARENT="$HERE/../"
|
||||
|
||||
(test -x "${HOME}/.cargo/bin/cargo-fuzz" || cargo install cargo-fuzz)
|
||||
|
||||
# it is important for `cargo fuzz` to be run from the project root
|
||||
cd "$PARENT"
|
||||
|
||||
mkdir -p "$HERE/corpus"
|
||||
rustup override set nightly
|
||||
|
||||
# run `compile` target using `seeds` as a start point and put new corpus state into `corpus` using 4 parallel jobs
|
||||
cargo fuzz run compile "$HERE/corpus" "$HERE/seeds" -j 4 --all-features
|
|
@ -0,0 +1,4 @@
|
|||
\documentclass{article}
|
||||
\begin{document}
|
||||
Hello, world!
|
||||
\end{document}
|
Loading…
Reference in New Issue