From 4b73c4b308917df1c40dc419391d8ca6fa50afc7 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Wed, 9 Aug 2017 08:49:41 -0700 Subject: [PATCH] [infra] Update bad_build_check to work with some edge cases. --- infra/base-images/base-runner/bad_build_check | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/infra/base-images/base-runner/bad_build_check b/infra/base-images/base-runner/bad_build_check index 4aa6279d7..d4d587e5e 100755 --- a/infra/base-images/base-runner/bad_build_check +++ b/infra/base-images/base-runner/bad_build_check @@ -28,10 +28,15 @@ function check_instrumentation { fi if (( $CHECK_FAILED == 0 )); then - # Should be 90 at least. The "example" target has 93. Real targets have the - # following values: arduinojson: 413, libteken: 519, zlib: 586. + # The "example" target has 93 when built with ASan and 67 with UBSan. Real + # targets have greater values (arduinojson: 413, libteken: 519, zlib: 586). + local THRESHOLD_FOR_NUMBER_OF_EDGES=90 + if [[ $SANITIZER = undefined ]]; then + THRESHOLD_FOR_NUMBER_OF_EDGES=65 + fi + local NUMBER_OF_EDGES=$(sancov -print-coverage-pcs $FUZZER | wc -l) - if (( $NUMBER_OF_EDGES < 90 )); then + if (( $NUMBER_OF_EDGES < $THRESHOLD_FOR_NUMBER_OF_EDGES )); then echo "BAD BUILD: the code does not seem to have coverage instrumentation." CHECK_FAILED=1 fi @@ -127,6 +132,13 @@ function check_ubsan_build { local MSAN_CALLS=$3 local UBSAN_CALLS=$4 + if [[ "$FUZZING_ENGINE" != libfuzzer ]]; then + # Ignore UBSan checks for fuzzing engines other than libFuzzer because: + # A) we (probably) are not going to use those with UBSan + # B) such builds show indistinguishable number of calls to UBSan + return 0 + fi + # Perform all the checks for more verbose error message. local CHECK_FAILED=0