Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corpus_merge.sh: make macOS compatible #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions corpus_merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function measure_coverage {
export GODEBUG="fuzzdebug=1"

# Extract the number of inputs we're running on.
num_inputs=$(ls "${CACHE_DIR}/${FUZZ_TARGET}" | wc -l)
num_inputs=$(ls "${CACHE_DIR}/${FUZZ_TARGET}" | wc -l | xargs)

go test -run="^${FUZZ_TARGET}$" -fuzz="^${FUZZ_TARGET}$" \
-fuzztime="${num_inputs}x" -test.fuzzcachedir="${CACHE_DIR}" \
Expand Down Expand Up @@ -103,7 +103,7 @@ mkdir "${CACHE_DIR}/${FUZZ_TARGET}"
coverage=0
if [[ -n $(ls "${DEST_DIR}") ]]; then
cp "${DEST_DIR}"/* "${CACHE_DIR}/${FUZZ_TARGET}/"
coverage=$(measure_coverage)
coverage=$(measure_coverage | sed 's/[^0-9]*//g')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the current directory has numbers in it?

Also, can we move the stripping of CWD into measure_coverage itself?

fi
echo "Baseline coverage: ${coverage}"

Expand All @@ -124,7 +124,7 @@ for f in $(ls -rS "${SRC_DIR}"); do

# Add f to our cache dir and see if it increases coverage.
cp "${SRC_DIR}/${f}" "${CACHE_DIR}/${FUZZ_TARGET}/"
newcoverage=$(measure_coverage)
newcoverage=$(measure_coverage | sed 's/[^0-9]*//g')

if (( newcoverage > coverage )); then
coverage="${newcoverage}"
Expand Down