diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BUILD.bazel | 18 | ||||
-rwxr-xr-x | examples/check_for_finding.sh | 25 |
2 files changed, 26 insertions, 17 deletions
diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 0d5f6bc4..6c1a81ef 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -168,11 +168,7 @@ java_fuzz_target_test( ) java_binary( - name = "JsonSanitizerDenylistCrash", - args = [ - "com.example.JsonSanitizerDenylistFuzzer", - "$(location :json_sanitizer_denylist_crash)", - ], + name = "JsonSanitizerReplayerCrash", data = [ ":json_sanitizer_denylist_crash", ], @@ -184,18 +180,20 @@ java_binary( ) sh_test( - name = "JsonSanitizerDenylistCrashTest", + name = "JsonSanitizerReplayerCrashTest", srcs = ["check_for_finding.sh"], args = [ - "$(location :JsonSanitizerDenylistCrash)", + "jazzer/$(rootpath :JsonSanitizerReplayerCrash)", "com.example.JsonSanitizerDenylistFuzzer", - "$(location :json_sanitizer_denylist_crash)", + "jazzer/$(rootpath :json_sanitizer_denylist_crash)", ], data = [ - ":JsonSanitizerDenylistCrash", + ":JsonSanitizerReplayerCrash", ":json_sanitizer_denylist_crash", ], - target_compatible_with = SKIP_ON_WINDOWS, + deps = [ + "@bazel_tools//tools/bash/runfiles", + ], ) java_fuzz_target_test( diff --git a/examples/check_for_finding.sh b/examples/check_for_finding.sh index f60c011c..afe110c6 100755 --- a/examples/check_for_finding.sh +++ b/examples/check_for_finding.sh @@ -13,17 +13,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -eval "$@" +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v2 --- + +# Temporarily disable exit on error since we expect the command below to fail. +set +e +"$(rlocation "$1")" "$2" "$(rlocation "$3")" "${@:4}" +declare -i exit_code=$? +set -e + # Assert that we either found a crash in java (exit code 77) or an ASan crash # (exit code 76). -declare -i exit_code=$? if [ $exit_code -eq 77 ] || [ $exit_code -eq 76 ] then - if [ "$(ls "$DEFAULT_CRASH_PREFIX/")" ]; then - exit 0 - else - exit 1 - fi + exit 0 else echo "Unexpected exit code: $exit_code" exit 1 |