Skip to content

Commit

Permalink
feat(test): add fuzz test for range_reader (#2609)
Browse files Browse the repository at this point in the history
* 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
dqhl76 authored Jul 17, 2023
1 parent ffdd796 commit b2ae4a3
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 0 deletions.
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"
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

0 comments on commit b2ae4a3

Please sign in to comment.