xref: /aosp_15_r20/external/jazzer-api/examples/check_for_finding.sh (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1*33edd672SMark#!/usr/bin/env bash
2*33edd672SMark# Copyright 2021 Code Intelligence GmbH
3*33edd672SMark#
4*33edd672SMark# Licensed under the Apache License, Version 2.0 (the "License");
5*33edd672SMark# you may not use this file except in compliance with the License.
6*33edd672SMark# You may obtain a copy of the License at
7*33edd672SMark#
8*33edd672SMark#      http://www.apache.org/licenses/LICENSE-2.0
9*33edd672SMark#
10*33edd672SMark# Unless required by applicable law or agreed to in writing, software
11*33edd672SMark# distributed under the License is distributed on an "AS IS" BASIS,
12*33edd672SMark# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*33edd672SMark# See the License for the specific language governing permissions and
14*33edd672SMark# limitations under the License.
15*33edd672SMark
16*33edd672SMark# --- begin runfiles.bash initialization v2 ---
17*33edd672SMark# Copy-pasted from the Bazel Bash runfiles library v2.
18*33edd672SMarkset -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
19*33edd672SMarksource "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
20*33edd672SMark  source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
21*33edd672SMark  source "$0.runfiles/$f" 2>/dev/null || \
22*33edd672SMark  source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
23*33edd672SMark  source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
24*33edd672SMark  { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
25*33edd672SMark# --- end runfiles.bash initialization v2 ---
26*33edd672SMark
27*33edd672SMark# Temporarily disable exit on error since we expect the command below to fail.
28*33edd672SMarkset +e
29*33edd672SMark"$(rlocation "$1")" "$2" "$(rlocation "$3")" "${@:4}"
30*33edd672SMarkdeclare -i exit_code=$?
31*33edd672SMarkset -e
32*33edd672SMark
33*33edd672SMark# Assert that we either found a crash in java (exit code 77) or an ASan crash
34*33edd672SMark# (exit code 76).
35*33edd672SMarkif [ $exit_code -eq 77 ] || [ $exit_code -eq 76 ]
36*33edd672SMarkthen
37*33edd672SMark  exit 0
38*33edd672SMarkelse
39*33edd672SMark  echo "Unexpected exit code: $exit_code"
40*33edd672SMark  exit 1
41*33edd672SMarkfi
42