1
0
Fork 0
forked from koniifer/ableos

Added fuzzy tests

This commit is contained in:
Erin 2023-07-26 01:01:53 +02:00
parent 95c979cb83
commit f2ec9a3034
3 changed files with 61 additions and 0 deletions

5
hbvm/fuzz/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
target
artifacts
corpus
coverage
Cargo.lock

27
hbvm/fuzz/Cargo.toml Normal file
View file

@ -0,0 +1,27 @@
[package]
name = "hbvm-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
[dependencies.hbvm]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[profile.release]
debug = 1
[[bin]]
name = "vm"
path = "fuzz_targets/vm.rs"
test = false
doc = false

View file

@ -0,0 +1,29 @@
#![no_main]
use {
hbvm::vm::{
mem::{HandlePageFault, Memory, MemoryAccessReason, PageSize},
Vm,
},
libfuzzer_sys::fuzz_target,
};
fuzz_target!(|data: &[u8]| {
if let Ok(mut vm) = Vm::<_, 0>::new_validated(data, TestTrapHandler) {
let _ = vm.run();
}
});
struct TestTrapHandler;
impl HandlePageFault for TestTrapHandler {
fn page_fault(
&mut self,
_: MemoryAccessReason,
_: &mut Memory,
_: u64,
_: PageSize,
_: *mut u8,
) -> bool {
false
}
}