Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): add fuzz test for range_reader #2609

Merged
merged 14 commits into from
Jul 17, 2023
46 changes: 46 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ members = [

"bin/oli",
"bin/oay",

"core/fuzz",
]
resolver = "2"

Expand Down
5 changes: 5 additions & 0 deletions core/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
corpus
artifacts
coverage
tmp
45 changes: 45 additions & 0 deletions core/fuzz/Cargo.toml
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"
dqhl76 marked this conversation as resolved.
Show resolved Hide resolved
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
40 changes: 40 additions & 0 deletions core/fuzz/README.md
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.
Loading