Skip to content

Commit

Permalink
fix buildspec syntax
Browse files Browse the repository at this point in the history
run all fuzz tests

fix syntax error

run tests in parallel

modify coverage summary

modify coverage output

update comment

simplify output

test shorter runtime

remove comments
  • Loading branch information
jouho committed Dec 6, 2024
1 parent 37a5205 commit 224a017
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion codebuild/spec/buildspec_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ phases:
on-failure: ABORT
commands:
# -L: Restrict tests to names matching the pattern 'fuzz'
- cmake --build build/ --target test -- ARGS="-L fuzz --output-on-failure -j (nproc)"
- cmake --build build/ --target test -- ARGS="-L fuzz --output-on-failure -j $(nproc)"
19 changes: 6 additions & 13 deletions codebuild/spec/buildspec_fuzz_scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
version: 0.2

env:
compute-type:
- BUILD_GENERAL1_LARGE
image:
- 024603541914.dkr.ecr.us-west-2.amazonaws.com/docker:ubuntu22codebuild
privileged-mode: true
variables:
CC: "/usr/bin/clang"
CXX: "/usr/bin/clang++"
Expand All @@ -34,26 +29,24 @@ phases:
build:
on-failure: ABORT
commands:
#TODO: change fuzz timeout back to 27000
- |
cmake . -Bbuild \
-DCMAKE_PREFIX_PATH=/usr/local/$S2N_LIBCRYPTO \
-DS2N_FUZZ_TEST=on \
-DFUZZ_TIMEOUT_SEC=60 \
-DFUZZ_TIMEOUT_SEC=27000 \
-DCOVERAGE=on \
-DBUILD_SHARED_LIBS=ON
- cmake --build ./build -- -j $(nproc)
post_build:
on-failure: ABORT
commands:
# -L: Restrict tests to labels matching the pattern 'fuzz'
# -R: Run the single fuzz test defined in ${FUZZ_TESTS}
# --timeout: override ctest's default timeout of 1500
- cmake --build build/ --target test -- ARGS="-L fuzz -R ${FUZZ_TESTS} --output-on-failure -j $(nproc) --timeout 28800"
- cmake --build build/ --target test -- ARGS="-L fuzz --output-on-failure -j $(nproc) --timeout 28800"
- ./tests/fuzz/calcTotalCov.sh

artifacts:
# upload all files in the coverage_report directory
files:
- '**/*'
base-directory: fuzz_coverage_report
# upload all files in the fuzz_coverage_report directory
files:
- '**/*'
base-directory: fuzz_coverage_report
9 changes: 6 additions & 3 deletions tests/fuzz/calcTotalCov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi

FUZZCOV_SOURCES="api bin crypto error stuffer tls utils"

printf "Calculating total s2n coverage... "
printf "Calculating total s2n coverage... \n"

# The llvm-profdata merge command warns that the profraws were created from different binaries (which is true) but
# works fine for what we care about (the s2n library). Therefore, for user clarity all output is suppressed.
Expand All @@ -39,5 +39,8 @@ llvm-cov export -instr-profile=tests/fuzz/profiles/merged_fuzz.profdata build/li

genhtml s2n_fuzz_cov.info --branch-coverage -q -o fuzz_coverage_report

S2N_COV=`grep -Eo '[0-9]*\.[0-9]*\%' s2n_fuzz_coverage.txt | tail -1`
printf "total s2n coverage from fuzz tests: %s\n" $S2N_COV
S2N_COV=`grep -Eo '[0-9]*\.[0-9]*\%' s2n_fuzz_coverage.txt | tail -3`
LINE_COV=$(echo $S2N_COV | cut -d' ' -f1)
FUNC_COV=$(echo $S2N_COV | cut -d' ' -f2)
BRANCH_COV=$(echo $S2N_COV | cut -d' ' -f3)
printf "Coverage Report:\nLine coverage: %s\nFunction coverage: %s\nBranch coverage: %s\n" "$LINE_COV" "$FUNC_COV" "$BRANCH_COV"
2 changes: 1 addition & 1 deletion tests/fuzz/runFuzzTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ASAN_OPTIONS+="symbolize=1"
LSAN_OPTIONS+="log_threads=1"
UBSAN_OPTIONS+="print_stacktrace=1"
NUM_CPU_THREADS=$(nproc)
LIBFUZZER_ARGS+="-timeout=5 -max_len=4096 -print_final_stats=1 -jobs=${NUM_CPU_THREADS} -workers=${NUM_CPU_THREADS} -max_total_time=${FUZZ_TIMEOUT_SEC}"
LIBFUZZER_ARGS+="-timeout=5 -max_len=4096 -print_final_stats=1 -workers=${NUM_CPU_THREADS} -max_total_time=${FUZZ_TIMEOUT_SEC}"

TEST_SPECIFIC_OVERRIDES="${BUILD_DIR_PATH}/lib/lib${TEST_NAME}_overrides.so"
GLOBAL_OVERRIDES="${BUILD_DIR_PATH}/lib/libglobal_overrides.so"
Expand Down

0 comments on commit 224a017

Please sign in to comment.