-
Notifications
You must be signed in to change notification settings - Fork 17
/
fuzz.sh
266 lines (249 loc) · 19.7 KB
/
fuzz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/env bash
# Automatic generated, DON'T MODIFY IT.
# @flag -h --help Print help information
# @flag -V --version Print version information
# {{ cargo fuzz init
# @cmd Initialize the fuzz directory
# @option -t --target[`_choice_target`] Name of the first fuzz target to create [default: fuzz_target_1]
# @option --fuzzing-workspace[true|false] <FUZZING_WORKSPACE> Whether to create a separate workspace for fuzz targets crate [default: false]
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information
# @flag -V --version Print version information
init() {
:;
}
# }} cargo fuzz init
# {{ cargo fuzz add
# @cmd Add a new fuzz target
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information
# @flag -V --version Print version information
# @arg target! Name of the new fuzz target
add() {
:;
}
# }} cargo fuzz add
# {{ cargo fuzz build
# @cmd Build fuzz targets
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target Name of the fuzz target to build, or build all targets if not supplied
build() {
:;
}
# }} cargo fuzz build
# {{ cargo fuzz check
# @cmd Type-check the fuzz targets
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target Name of the fuzz target to check, or check all targets if not supplied
check() {
:;
}
# }} cargo fuzz check
# {{ cargo fuzz fmt
# @cmd Print the `std::fmt::Debug` output for an input
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target! Name of fuzz target
# @arg input! Path to the input testcase to debug print
fmt() {
:;
}
# }} cargo fuzz fmt
# {{ cargo fuzz list
# @cmd List all the existing fuzz targets
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information
# @flag -V --version Print version information
list() {
:;
}
# }} cargo fuzz list
# {{ cargo fuzz run
# @cmd Run a fuzz target
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @option -j --jobs Number of concurrent jobs to run
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target! Name of the fuzz target
# @arg corpus* Custom corpus directories or artifact files
# @arg args* Additional libFuzzer arguments passed through to the binary
run() {
:;
}
# }} cargo fuzz run
# {{ cargo fuzz cmin
# @cmd Minify a corpus
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target! Name of the fuzz target
# @arg corpus The corpus directory to minify into
# @arg args* Additional libFuzzer arguments passed through to the binary
cmin() {
:;
}
# }} cargo fuzz cmin
# {{ cargo fuzz tmin
# @cmd Minify a test case
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @option -r --runs Number of minimization attempts to perform
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target! Name of the fuzz target
# @arg test_case! Path to the failing test case to be minimized
# @arg args* Additional libFuzzer arguments passed through to the binary
tmin() {
:;
}
# }} cargo fuzz tmin
# {{ cargo fuzz coverage
# @cmd Run program on the generated corpus and generate coverage information
# @flag -D --dev Build artifacts in development mode, without optimizations
# @flag -O --release Build artifacts in release mode, with optimizations
# @flag -a --debug-assertions Build artifacts with debug assertions and overflow checks enabled (default if not -O)
# @flag -v --verbose Build target with verbose output from `cargo build`
# @flag --no-default-features Build artifacts with default Cargo features disabled
# @flag --all-features Build artifacts with all Cargo features enabled
# @option --features*,[`_choice_feature`] Build artifacts with given Cargo feature enabled
# @option -s --sanitizer[address|leak|memory|thread|none] Use a specific sanitizer
# @flag --build-std Pass -Zbuild-std to Cargo, which will build the standard library with all the build settings for the fuzz target, including debug assertions, and a sanitizer if requested.
# @flag -c --careful enable "careful" mode: inspired by https://github.com/RalfJung/cargo-careful, this enables building the fuzzing harness along with the standard library (implies --build-std) with debug assertions and extra const UB and init checks
# @option --target[`_choice_target`] <TRIPLE> Target triple of the fuzz target
# @option -Z <FLAG> Unstable (nightly-only) flags to Cargo
# @option --target-dir <TARGET_DIR> Target dir option to pass to cargo build
# @flag --strip-dead-code Dead code is linked by default to prevent a potential error with some optimized targets.
# @flag --no-cfg-fuzzing By default the 'cfg(fuzzing)' compilation configuration is set.
# @flag --no-trace-compares Don't build with the `sanitizer-coverage-trace-compares` LLVM argument
# @option --fuzz-dir <FUZZ_DIR> The path to the fuzz project directory
# @option --llvm-path <LLVM_PATH> Sets the path to the LLVM bin directory.
# @flag -h --help Print help information (use `-h` for a summary)
# @flag -V --version Print version information
# @arg target! Name of the fuzz target
# @arg corpus* Custom corpus directories or artifact files
# @arg args* Additional libFuzzer arguments passed through to the binary
coverage() {
:;
}
# }} cargo fuzz coverage
. "$ARGC_COMPLETIONS_ROOT/utils/_argc_utils.sh"
_choice_feature() {
_helper_package_json | yq '.features | keys | .[]'
}
_choice_target() {
rustup target list --installed
}
_helper_metadata_json() {
cargo metadata --format-version 1 --no-deps
}
_helper_package_json() {
metadata_json="$(_helper_metadata_json)"
if [[ -n "$argc_package" ]]; then
echo "$metadata_json" | yq '.packages[] | select(.name == "'"$argc_package"'")'
else
workspace_root="$(echo "$metadata_json" | yq '.workspace_root')"
manifest_path="$(_argc_util_path_resolve -p "$workspace_root" Cargo.toml)"
echo "$metadata_json" | yq '.packages[] | select(.manifest_path == "'"$manifest_path"'")'
fi
}
command eval "$(argc --argc-eval "$0" "$@")"