mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
- Update fuzz test section in CI to just compile the fuzz test targets,
instead of actually running the tests. - Fix "Crate Features" documentation - Update lines to have a maximum of 79 columns in README.md - Remove unnecessary files. - Cleanup fuzz_glob test. Signed-off-by: William Johnson <wjohnson@whamcloud.com>
This commit is contained in:
parent
5fde1fe661
commit
492b05f8d2
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
@ -217,20 +217,26 @@ jobs:
|
||||
run: cargo doc --no-deps --document-private-items --workspace
|
||||
|
||||
fuzz_testing:
|
||||
name: Run Fuzz Tests
|
||||
name: Compile Fuzz Test Targets
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages (Ubuntu)
|
||||
- name: Install required packages (Ubuntu)
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++ --yes
|
||||
|
||||
- uses: dtolnay/rust-toolchain@nightly
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- run: cargo fuzz_install
|
||||
- name: Install Fuzzer
|
||||
run: cargo install cargo-fuzz
|
||||
working-directory: fuzz
|
||||
|
||||
- run: ./scripts/run-all.sh
|
||||
- name: Verify fuzz targets build
|
||||
run: cargo check
|
||||
working-directory: fuzz
|
||||
|
@ -16,19 +16,6 @@ globs as matching.
|
||||
|
||||
This example shows how to match a single glob against a single file path.
|
||||
|
||||
|
||||
# Crate features
|
||||
|
||||
This crate includes optional features that can be enabled if necessary. These features are
|
||||
not required but may be useful depending on the use case.
|
||||
|
||||
The following features are available:
|
||||
|
||||
* **arbitrary** -
|
||||
Enabling this feature introduces a public dependency on the
|
||||
[`arbitrary`](https://crates.io/crates/arbitrary)
|
||||
crate. Namely, it implements the `Arbitrary` trait from that crate for the
|
||||
[`Glob`] type. This feature is disabled by default.
|
||||
```
|
||||
use globset::Glob;
|
||||
|
||||
@ -107,6 +94,19 @@ Standard Unix-style glob syntax is supported:
|
||||
|
||||
A `GlobBuilder` can be used to prevent wildcards from matching path separators,
|
||||
or to enable case insensitive matching.
|
||||
|
||||
# Crate Features
|
||||
|
||||
This crate includes optional features that can be enabled if necessary.
|
||||
These features are not required but may be useful depending on the use case.
|
||||
|
||||
The following features are available:
|
||||
|
||||
* **arbitrary** -
|
||||
Enabling this feature introduces a public dependency on the
|
||||
[`arbitrary`](https://crates.io/crates/arbitrary)
|
||||
crate. Namely, it implements the `Arbitrary` trait from that crate for the
|
||||
[`Glob`] type. This feature is disabled by default.
|
||||
*/
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
@ -1,4 +0,0 @@
|
||||
[alias]
|
||||
fuzz_install = "install cargo-fuzz"
|
||||
fuzz_list = "fuzz list"
|
||||
fuzz_run = "fuzz run"
|
@ -2,14 +2,22 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
Fuzz testing produces pseudo-random / arbitrary data that is used to find stability issues within a code base. While Rust provides a strong type system, this does not guarantee that an object will convert properly from one struct to another. It is the responsibility of the developer to ensure that a struct is converted properly. Fuzz testing will generate input within the domain of each property. This arbitrary data can then be used to convert from ObjectA to ObjectB and then back. This type of testing will help catch bugs that the type system is not able to see.
|
||||
Fuzz testing produces pseudo-random / arbitrary data that is used to find
|
||||
stability issues within a code base. While Rust provides a strong type system,
|
||||
this does not guarantee that an object will convert properly from one struct
|
||||
to another. It is the responsibility of the developer to ensure that a struct
|
||||
is converted properly. Fuzz testing will generate input within the domain of
|
||||
each property. This arbitrary data can then be used to convert from ObjectA
|
||||
to ObjectB and then back. This type of testing will help catch bugs that the
|
||||
type system is not able to see.
|
||||
|
||||
## Installation
|
||||
|
||||
This crate relies on the `cargo-fuzz` component. To install this component, run the following from the `fuzz` directory:
|
||||
This crate relies on the `cargo-fuzz` component. To install this component,
|
||||
run the following from the `fuzz` directory:
|
||||
|
||||
```bash
|
||||
cargo fuzz_install
|
||||
cargo install cargo-fuzz
|
||||
```
|
||||
|
||||
## Listing Targets
|
||||
@ -17,7 +25,7 @@ cargo fuzz_install
|
||||
Once installed, fuzz targets can be listed by running the following command:
|
||||
|
||||
```bash
|
||||
cargo fuzz_list
|
||||
cargo fuzz list
|
||||
```
|
||||
|
||||
This command will print out a list of all targets that can be tested.
|
||||
@ -27,13 +35,18 @@ This command will print out a list of all targets that can be tested.
|
||||
To run a fuzz test, the target must be specified:
|
||||
|
||||
```bash
|
||||
cargo fuzz_run <target>
|
||||
cargo fuzz run <target>
|
||||
```
|
||||
|
||||
Note that the above will run the fuzz test indefinitely. Use the `-max_total_time=<num seconds>` flag to specify how many seconds the test should run for:
|
||||
Note that the above will run the fuzz test indefinitely. Use the
|
||||
`-max_total_time=<num seconds>` flag to specify how many seconds the test
|
||||
should run for:
|
||||
|
||||
```bash
|
||||
cargo fuzz_run <target> -- -max_total_time=5
|
||||
cargo fuzz run <target> -- -max_total_time=5
|
||||
```
|
||||
|
||||
The above command will run the fuzz test for five seconds. If the test completes without error it will show how many tests were run successfully. The test will abort and return a non-zero error code if it is able to produce an error. The arbitrary input will be displayed in the event of a failure.
|
||||
The above command will run the fuzz test for five seconds. If the test
|
||||
completes without error it will show how many tests were run successfully.
|
||||
The test will abort and return a non-zero error code if it is able to produce
|
||||
an error. The arbitrary input will be displayed in the event of a failure.
|
||||
|
@ -1,13 +1,10 @@
|
||||
#![no_main]
|
||||
|
||||
extern crate globset;
|
||||
extern crate libfuzzer_sys;
|
||||
|
||||
use globset::Glob;
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use std::str::FromStr;
|
||||
|
||||
fuzz_target!(|glob_str: &str| {
|
||||
use globset::Glob;
|
||||
|
||||
libfuzzer_sys::fuzz_target!(|glob_str: &str| {
|
||||
let Ok(glob) = Glob::new(glob_str) else {
|
||||
return;
|
||||
};
|
||||
|
@ -1,3 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
profile = "default"
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# Number of seconds to run the script. Default to 5 minutes.
|
||||
duration="${1:-300}"
|
||||
start_time=$SECONDS
|
||||
elapsed_time=0
|
||||
|
||||
while (( $elapsed_time < $duration )); do
|
||||
for target in $(cargo fuzz_list); do cargo fuzz_run $target --release -- -max_total_time=60 -verbosity=0; done
|
||||
|
||||
elapsed_time=$(($SECONDS - $start_time))
|
||||
done
|
Loading…
Reference in New Issue
Block a user