Skip to content

Commit

Permalink
ci: store fuzz artifacts in s3 (#4678)
Browse files Browse the repository at this point in the history
  • Loading branch information
jouho authored Aug 7, 2024
1 parent 87deea1 commit 1511c51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/fuzz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ifndef CORPUS_UPLOAD_LOC
export CORPUS_UPLOAD_LOC="none"
endif

ifndef ARTIFACT_UPLOAD_LOC
export ARTIFACT_UPLOAD_LOC="none"
endif

ifndef FUZZ_TESTS
export FUZZ_TESTS=${TESTS}
endif
Expand Down Expand Up @@ -72,7 +76,7 @@ run_tests:: $(FUZZ_TESTS) ld-preload
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}; \
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}; \
export LIBCRYPTO_ROOT=${LIBCRYPTO_ROOT}; \
./runFuzzTest.sh $${test_name} ${FUZZ_TIMEOUT_SEC} ${CORPUS_UPLOAD_LOC}; done; \
./runFuzzTest.sh $${test_name} ${FUZZ_TIMEOUT_SEC} ${CORPUS_UPLOAD_LOC} ${ARTIFACT_UPLOAD_LOC}; done; \
}
./calcTotalCov.sh

Expand Down
21 changes: 20 additions & 1 deletion tests/fuzz/runFuzzTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ usage() {
exit 1
}

if [ "$#" -ne "3" ]; then
if [ "$#" -ne "4" ]; then
usage
fi

TEST_NAME=$1
FUZZ_TIMEOUT_SEC=$2
CORPUS_UPLOAD_LOC=$3
ARTIFACT_UPLOAD_LOC=$4
MIN_TEST_PER_SEC="1000"
MIN_FEATURES_COVERED="100"

Expand Down Expand Up @@ -201,6 +202,24 @@ then
if [ $EXPECTED_TEST_FAILURE == 1 ];
then
# Store corpus to S3 to be used for debugging if the test is negative
unset LD_PRELOAD
unset LD_LIBRARY_PATH
if [ "$CORPUS_UPLOAD_LOC" != "none" ]; then
printf "Zipping corpus files...\n"
zip -r ./corpus/${TEST_NAME}.zip ./corpus/${TEST_NAME}/
printf "Uploading zipped corpus file to S3 bucket...\n"
aws s3 cp ./corpus/${TEST_NAME}.zip $CORPUS_UPLOAD_LOC/${TEST_NAME}/corpus_$(date +%Y-%m-%d-%T).zip
fi
# Store generated output files in the S3 bucket.
if [ "$ARTIFACT_UPLOAD_LOC" != "none" ]; then
printf "Uploading output files to S3 bucket...\n"
aws s3 cp ./${TEST_NAME}_output.txt ${ARTIFACT_UPLOAD_LOC}/${TEST_NAME}/output_$(date +%Y-%m-%d-%T).txt
aws s3 cp ./${TEST_NAME}_results.txt ${ARTIFACT_UPLOAD_LOC}/${TEST_NAME}/results_$(date +%Y-%m-%d-%T).txt
fi
# Clean up LibFuzzer corpus files if the test is negative.
printf "\n"
rm -f leak-* crash-*
Expand Down

0 comments on commit 1511c51

Please sign in to comment.