xref: /aosp_15_r20/external/bazelbuild-rules_go/tests/legacy/extldflags_rpath/extldflags_rpath_test.sh (revision 9bb1b549b6a84214c53be0924760be030e66b93a)
1#!/bin/sh
2
3if [ $# -ne 1 ]; then
4  echo "usage: $0 binaryfile" >&1
5  exit 1
6fi
7
8binaryfile=$1
9os=$(uname)
10case $os in
11  Linux)
12    output=$(readelf --dynamic "$binaryfile")
13    ;;
14  Darwin)
15    output=$(otool -l "$binaryfile")
16    ;;
17  *)
18    echo "unsupported platform: $os" >&1
19    exit 1
20esac
21
22for path in /foo /bar ; do
23  if ! echo "$output" | grep --quiet "$path" ; then
24    echo "$binaryfile: could not find $path in rpaths" >&1
25    exit 1
26  fi
27done
28