5
5
# Define the fuzz directory relative to the project root
6
6
FUZZ_DIR=" fuzz"
7
7
8
- TOOLCHAIN=" nightly"
9
8
FEATURES=" libfuzzer_fuzz"
10
9
11
10
# --- Dependencies ---
12
- echo " Checking/installing dependencies..."
13
- # cargo-llvm-cov implicitly uses/installs necessary LLVM tools
14
- rustup +${TOOLCHAIN} component add llvm-tools-preview
15
- # Check if cargo-llvm-cov is installed, install if not
16
- if ! cargo +${TOOLCHAIN} --list | grep -q " llvm-cov" ; then
17
- echo " Installing cargo-llvm-cov..."
18
- cargo +${TOOLCHAIN} install cargo-llvm-cov
11
+ echo " Checking dependencies..."
12
+ # Check if llvm-tools is installed for the toolchain
13
+ if ! rustup component list | grep -q " llvm-tools.*(installed)" ; then
14
+ echo " Error: Required component 'llvm-tools' is not installed for the default toolchain."
15
+ echo " Please install it using: rustup component add llvm-tools"
16
+ exit 1
17
+ fi
18
+
19
+ # Check if cargo-llvm-cov is installed
20
+ if ! cargo --list | grep -q " llvm-cov" ; then
21
+ echo " Error: Required cargo subcommand 'llvm-cov' is not installed for the default toolchain."
22
+ echo " Please install it using: cargo install cargo-llvm-cov"
23
+ exit 1
19
24
fi
20
25
21
26
# Clean previous builds and coverage artifacts relative to project root
22
27
echo " Cleaning previous build and coverage artifacts..."
23
- cargo + ${TOOLCHAIN} clean
28
+ cargo clean
24
29
rm -rf target/llvm-cov-target
25
30
rm -rf target/coverage
26
31
27
32
echo " Running fuzz targets with cargo-llvm-cov to collect coverage..."
28
33
export RUSTFLAGS=" --cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
29
34
30
35
# Determine host triple dynamically for the --target flag
31
- HOST_TRIPLE=$( rustc + ${TOOLCHAIN} --version --verbose | grep host | cut -d' ' -f2)
36
+ HOST_TRIPLE=$( rustc --version --verbose | grep host | cut -d' ' -f2)
32
37
if [ -z " $HOST_TRIPLE " ]; then
33
38
echo " Error: Could not determine host triple."
34
39
exit 1
@@ -45,7 +50,7 @@ for TARGET_PATH in "$FUZZ_DIR"/src/bin/*_target.rs; do
45
50
46
51
if [ -d " $TARGET_CORPUS_DIR " ]; then
47
52
echo " Running cargo llvm-cov for target: $TARGET_NAME with corpus $TARGET_CORPUS_DIR "
48
- if ! CARGO_TARGET_DIR=./target cargo + ${TOOLCHAIN} llvm-cov run --no-report --manifest-path " $FUZZ_DIR /Cargo.toml" --target " $HOST_TRIPLE " --features " $COMBINED_FEATURES " --bin " $TARGET_NAME " -- " $TARGET_CORPUS_DIR " -runs=1; then
53
+ if ! CARGO_TARGET_DIR=./target cargo llvm-cov run --no-report --manifest-path " $FUZZ_DIR /Cargo.toml" --target " $HOST_TRIPLE " --features " $COMBINED_FEATURES " --bin " $TARGET_NAME " -- " $TARGET_CORPUS_DIR " -runs=1; then
49
54
echo " Warning: Execution of $TARGET_NAME with cargo-llvm-cov finished with non-zero status."
50
55
fi
51
56
else
0 commit comments