|
| 1 | +# Copyright 2023 The Bazel Authors. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# --- begin runfiles.bash initialization v3 --- |
| 16 | +# Copy-pasted from the Bazel Bash runfiles library v3. |
| 17 | +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 18 | +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 19 | + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 20 | + source "$0.runfiles/$f" 2>/dev/null || \ |
| 21 | + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 22 | + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 23 | + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 24 | +# --- end runfiles.bash initialization v3 --- |
| 25 | +set +e |
| 26 | + |
| 27 | +bin=$(rlocation $BIN_RLOCATION) |
| 28 | +if [[ -z "$bin" ]]; then |
| 29 | + echo "Unable to locate test binary: $BIN_RLOCATION" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +bin_link_layer_1=$TEST_TMPDIR/link1 |
| 34 | +ln -s "$bin" "$bin_link_layer_1" |
| 35 | +bin_link_layer_2=$TEST_TMPDIR/link2 |
| 36 | +ln -s "$bin_link_layer_1" "$bin_link_layer_2" |
| 37 | + |
| 38 | +result=$(RUNFILES_DIR='' RUNFILES_MANIFEST_FILE='' $bin) |
| 39 | +result_link_layer_1=$(RUNFILES_DIR='' RUNFILES_MANIFEST_FILE='' $bin_link_layer_1) |
| 40 | +result_link_layer_2=$(RUNFILES_DIR='' RUNFILES_MANIFEST_FILE='' $bin_link_layer_2) |
| 41 | + |
| 42 | +if [[ "$result" != "$result_link_layer_1" ]]; then |
| 43 | + echo "Output from test does not match output when invoked via a link;" |
| 44 | + echo "Output from test:" |
| 45 | + echo "$result" |
| 46 | + echo "Output when invoked via a link:" |
| 47 | + echo "$result_link_layer_1" |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | +if [[ "$result" != "$result_link_layer_2" ]]; then |
| 51 | + echo "Output from test does not match output when invoked via a link to a link;" |
| 52 | + echo "Output from test:" |
| 53 | + echo "$result" |
| 54 | + echo "Output when invoked via a link to a link:" |
| 55 | + echo "$result_link_layer_2" |
| 56 | + exit 1 |
| 57 | +fi |
| 58 | + |
| 59 | +exit 0 |
0 commit comments