aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-10-19 13:43:45 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-10-19 14:04:05 +0200
commitd474119d8e06bc269e37d14287e4b75367f5e130 (patch)
tree68d043012b59739777c179abde98d3ec6ba09c18
parentf14bd5d6b90be5cf8ecbc9d6f86ade5caed269ed (diff)
downloadjazzer-api-d474119d8e06bc269e37d14287e4b75367f5e130.tar.gz
Adapt replayer test for Windows
Also removes a copy-pasted check for a crash file that is not created by the replayer.
-rw-r--r--examples/BUILD.bazel18
-rwxr-xr-xexamples/check_for_finding.sh25
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