xref: /aosp_15_r20/external/jazzer-api/tests/src/test/shell/jazzer_from_path_test.sh (revision 33edd6723662ea34453766bfdca85dbfdd5342b8)
1#!/bin/bash
2# Copyright 2022 Code Intelligence GmbH
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Verify that the Jazzer launcher finds the jar when executed from PATH.
17
18
19# --- begin runfiles.bash initialization v3 ---
20# Copy-pasted from the Bazel Bash runfiles library v3.
21set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
22source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
23  source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
24  source "$0.runfiles/$f" 2>/dev/null || \
25  source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
26  source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
27  { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
28# --- end runfiles.bash initialization v3 ---
29
30# Unpack the release archive to a temporary directory.
31jazzer_release="$(rlocation "$1")"
32tmp="$(mktemp -d)"
33trap 'rm -r "$tmp"' EXIT
34# GNU tar on Windows requires --force-local to support colons in archives names,
35# macOS tar does not support it.
36tar -xzf "$jazzer_release" -C "$tmp" --force-local || tar -xzf "$jazzer_release" -C "$tmp"
37
38# Add the Jazzer launcher to PATH first so that it is picked over host Jazzer
39# installations.
40PATH="$tmp:$PATH"
41export PATH
42
43jazzer --version
44