-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fuzzing tests: - As unit tests using `QuickCheck` - As `cargo fuzz` tests Both sets of tests use the same set fuzzing functions, running `cargo fuzz` is just a lot more intense.
- Loading branch information
1 parent
ea8669d
commit 85eea94
Showing
12 changed files
with
530 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ thiserror = "1.0.30" | |
|
||
[dev-dependencies] | ||
hex = "0.4.3" | ||
quickcheck = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[package] | ||
name = "monero-fuzz" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
|
||
[dependencies.randomx-rs] | ||
path = ".." | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[profile.release] | ||
debug = 1 | ||
|
||
[[bin]] | ||
name = "randomx_alloc_cache" | ||
path = "fuzz_targets/randomx_alloc_cache.rs" | ||
test = false | ||
doc = false | ||
|
||
[[bin]] | ||
name = "randomx_create_vm_with_cache_only" | ||
path = "fuzz_targets/randomx_create_vm_with_cache_only.rs" | ||
test = false | ||
doc = false | ||
|
||
[[bin]] | ||
name = "randomx_create_vm_with_cache_and_dataset" | ||
path = "fuzz_targets/randomx_create_vm_with_cache_and_dataset.rs" | ||
test = false | ||
doc = false | ||
|
||
[[bin]] | ||
name = "randomx_vm_calculate_hash_with_cache_only" | ||
path = "fuzz_targets/randomx_vm_calculate_hash_with_cache_only.rs" | ||
test = false | ||
doc = false | ||
|
||
[[bin]] | ||
name = "randomx_vm_calculate_hash_with_cache_and_dataset" | ||
path = "fuzz_targets/randomx_vm_calculate_hash_with_cache_and_dataset.rs" | ||
test = false | ||
doc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Fuzzing randomx-rs | ||
|
||
See https://rust-fuzz.github.io/book/cargo-fuzz.html for more information on fuzzing with cargo-fuzz. | ||
Install `cargo-fuzz` as per [installation instructions](https://rust-fuzz.github.io/book/cargo-fuzz/setup.html). | ||
|
||
|
||
**Note:** Fuzzing is not supported on Windows yet. | ||
|
||
To get a list of fuzz targets, from a terminal in the project root, run | ||
``` | ||
cargo fuzz list | ||
``` | ||
|
||
To run a fuzz test, from a terminal in the project root, run | ||
``` | ||
cargo +nightly fuzz run --release <fuzz_target_name> | ||
``` | ||
To run fuzz tests involving a cache and dataset, on error `libFuzzer: out-of-memory (malloc(2181038016))`, pass | ||
`-- -rss_limit_mb=<ram_upper_limit>` as argument to allow using more than 2 GB of RAM - 3GB recommended. | ||
``` | ||
cargo +nightly fuzz run --release <fuzz_target_name> -- -rss_limit_mb=3221225472 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use randomx_rs::test_utils::fuzz_randomx_alloc_cache; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_randomx_alloc_cache(data.to_vec()); | ||
}); |
8 changes: 8 additions & 0 deletions
8
fuzz/fuzz_targets/randomx_create_vm_with_cache_and_dataset.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use randomx_rs::test_utils::fuzz_randomx_create_vm_with_cache_and_dataset; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_randomx_create_vm_with_cache_and_dataset(data.to_vec()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use randomx_rs::test_utils::fuzz_randomx_create_vm_with_cache_only; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_randomx_create_vm_with_cache_only(data.to_vec()); | ||
}); |
8 changes: 8 additions & 0 deletions
8
fuzz/fuzz_targets/randomx_vm_calculate_hash_with_cache_and_dataset.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use randomx_rs::test_utils::fuzz_randomx_vm_calculate_hash_with_cache_and_dataset; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_randomx_vm_calculate_hash_with_cache_and_dataset(data.to_vec()); | ||
}); |
8 changes: 8 additions & 0 deletions
8
fuzz/fuzz_targets/randomx_vm_calculate_hash_with_cache_only.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use randomx_rs::test_utils::fuzz_randomx_vm_calculate_hash_with_cache_only; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_randomx_vm_calculate_hash_with_cache_only(data.to_vec()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.