feat: add fuzz-clean-usbip app and extract shared fuzz-env
Adds `nix run .#fuzz-clean-usbip -- <target>` to re-check crash/oom/timeout artifacts and delete the ones that no longer reproduce (already fixed). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2e2a5961d6
commit
d49d371509
1 changed files with 51 additions and 3 deletions
54
flake.nix
54
flake.nix
|
|
@ -79,11 +79,14 @@
|
|||
};
|
||||
|
||||
apps = let
|
||||
fuzz-usbip = pkgs.writeShellScriptBin "fuzz-usbip" ''
|
||||
set -euo pipefail
|
||||
export PATH="${rust-nightly}/bin:${pkgs.cargo-fuzz}/bin:${pkgs.stdenv.cc}/bin:${pkgs.pkg-config}/bin:$PATH"
|
||||
fuzz-env = ''
|
||||
export PATH="${rust-nightly}/bin:${pkgs.cargo-fuzz}/bin:${pkgs.stdenv.cc}/bin:${pkgs.pkg-config}/bin:${pkgs.coreutils}/bin:$PATH"
|
||||
export PKG_CONFIG_PATH="${pkgs.libusb1.dev}/lib/pkgconfig''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"${pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux '':${pkgs.udev.dev}/lib/pkgconfig''}
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/lib"
|
||||
'';
|
||||
fuzz-usbip = pkgs.writeShellScriptBin "fuzz-usbip" ''
|
||||
set -euo pipefail
|
||||
${fuzz-env}
|
||||
if [ $# -eq 0 ]; then
|
||||
cargo fuzz list
|
||||
else
|
||||
|
|
@ -107,11 +110,56 @@
|
|||
fi
|
||||
fi
|
||||
'';
|
||||
fuzz-clean-usbip = pkgs.writeShellScriptBin "fuzz-clean-usbip" ''
|
||||
set -euo pipefail
|
||||
${fuzz-env}
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: fuzz-clean-usbip <target>"
|
||||
echo "Available targets:"
|
||||
cargo fuzz list
|
||||
exit 1
|
||||
fi
|
||||
target="$1"
|
||||
dir="fuzz/artifacts/$target"
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "No artifacts directory: $dir"
|
||||
exit 0
|
||||
fi
|
||||
shopt -s nullglob
|
||||
files=("$dir"/crash-* "$dir"/oom-* "$dir"/timeout-*)
|
||||
if [ ''${#files[@]} -eq 0 ]; then
|
||||
echo "No artifacts to test."
|
||||
exit 0
|
||||
fi
|
||||
echo "Building $target..."
|
||||
if ! cargo fuzz build "$target" 2>&1; then
|
||||
echo "Build failed — not touching artifacts."
|
||||
exit 1
|
||||
fi
|
||||
echo "Testing ''${#files[@]} artifacts for $target..."
|
||||
removed=0
|
||||
kept=0
|
||||
for f in "''${files[@]}"; do
|
||||
if timeout 30 cargo fuzz run "$target" "$f" -- -max_len=1048576 >/dev/null 2>&1; then
|
||||
rm "$f"
|
||||
removed=$((removed + 1))
|
||||
else
|
||||
kept=$((kept + 1))
|
||||
fi
|
||||
echo -ne "\r tested $((removed + kept))/''${#files[@]}, removed $removed, kept $kept"
|
||||
done
|
||||
echo ""
|
||||
echo "Done: removed $removed fixed, kept $kept still-crashing."
|
||||
'';
|
||||
in {
|
||||
fuzz-usbip = {
|
||||
type = "app";
|
||||
program = "${fuzz-usbip}/bin/fuzz-usbip";
|
||||
};
|
||||
fuzz-clean-usbip = {
|
||||
type = "app";
|
||||
program = "${fuzz-clean-usbip}/bin/fuzz-clean-usbip";
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue