forked from gentoo-utils/gentoo-utils
impl vercmp fuzzer
This commit is contained in:
43
fuzz/atom/vercmp/gencorpus.rs
Normal file
43
fuzz/atom/vercmp/gencorpus.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use std::{
|
||||
env,
|
||||
error::Error,
|
||||
fs::{self, OpenOptions},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use gentoo_utils::ebuild::repo::Repo;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let corpus_dir = PathBuf::from(
|
||||
env::args()
|
||||
.nth(1)
|
||||
.expect("expected corpus directory as first argument"),
|
||||
);
|
||||
|
||||
fs::create_dir_all(&corpus_dir)?;
|
||||
|
||||
let repo = Repo::new("/var/db/repos/gentoo");
|
||||
let mut versions = Vec::new();
|
||||
|
||||
for category in repo.categories()? {
|
||||
for ebuild in category?.ebuilds()? {
|
||||
let version = ebuild?.version().clone();
|
||||
|
||||
versions.push(version);
|
||||
}
|
||||
}
|
||||
|
||||
for (i, version) in versions.iter().enumerate() {
|
||||
let path = corpus_dir.as_path().join(i.to_string());
|
||||
let mut file = OpenOptions::new()
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.create(true)
|
||||
.open(path)?;
|
||||
|
||||
write!(file, "{version}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user