-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add fuzz test for range_reader (#2609)
* test: add fuzz target for fs reader Signed-off-by: dqhl76 <[email protected]> * fix: add different seek modes Signed-off-by: dqhl76 <[email protected]> * fix: add missing license header Signed-off-by: dqhl76 <[email protected]> * fix: fix format problems and rewrite seekfrom Signed-off-by: dqhl76 <[email protected]> * fix: make clippy happy Signed-off-by: dqhl76 <[email protected]> * feat: add service env setting Signed-off-by: dqhl76 <[email protected]> * fix: README Signed-off-by: dqhl76 <[email protected]> * fix: README Signed-off-by: dqhl76 <[email protected]> * feat: add checker Signed-off-by: dqhl76 <[email protected]> * feat: finish checker Signed-off-by: dqhl76 <[email protected]> * fix: make clippy happy Signed-off-by: dqhl76 <[email protected]> * fix: continue fight with clippy Signed-off-by: dqhl76 <[email protected]> * polish Signed-off-by: dqhl76 <[email protected]> --------- Signed-off-by: dqhl76 <[email protected]>
- Loading branch information
Showing
7 changed files
with
416 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -36,6 +36,8 @@ members = [ | |
|
||
"bin/oli", | ||
"bin/oay", | ||
|
||
"core/fuzz", | ||
] | ||
resolver = "2" | ||
|
||
|
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,5 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage | ||
tmp |
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,45 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
[package] | ||
edition = "2021" | ||
name = "opendal-fuzz" | ||
publish = false | ||
version = "0.0.0" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
anyhow = "1.0.71" | ||
arbitrary = { version = "1.3.0", features = ["derive"] } | ||
bytes = "1.2" | ||
dotenvy = "0.15.6" | ||
libfuzzer-sys = "0.4" | ||
opendal = { path = ".." } | ||
sha2 = { version = "0.10.6" } | ||
tokio = { version = "1", features = ["full"] } | ||
uuid = { version = "1.3.0", features = ["v4"] } | ||
|
||
[profile.release] | ||
debug = 1 | ||
|
||
[[bin]] | ||
doc = false | ||
name = "fuzz_reader" | ||
path = "fuzz_reader.rs" | ||
test = 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,40 @@ | ||
# Fuzz Test for OpenDAL | ||
|
||
fuzz test are used to test the robustness of the code. | ||
|
||
## Setup | ||
|
||
|
||
|
||
To run the fuzz tests, please copy the `.env.example`, which is at project root, to `.env` and change the values on need. | ||
|
||
Take `fs` for example, we need to change to enable behavior test on `fs` on `/tmp`. | ||
|
||
```dotenv | ||
OPENDAL_FS_TEST=false | ||
OPENDAL_FS_ROOT=/path/to/dir | ||
``` | ||
|
||
into | ||
|
||
```dotenv | ||
OPENDAL_FS_TEST=on | ||
OPENDAL_FS_ROOT=/tmp | ||
``` | ||
|
||
|
||
## Run | ||
|
||
List all fuzz targets. | ||
|
||
```bash | ||
cargo +nightly fuzz list | ||
``` | ||
|
||
Run a fuzz target(such as `reader`). | ||
|
||
```bash | ||
cargo +nightly fuzz run fuzz_reader | ||
``` | ||
|
||
For more details, please visit [cargo fuzz](https://rust-fuzz.github.io/book/cargo-fuzz/tutorial.html) or run the command cargo fuzz --help. |
Oops, something went wrong.