summaryrefslogtreecommitdiffstats
path: root/tests/no-rpath-prebuild.sh
blob: 0fc96d26a53a303c0628f501ade25f101192e1ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /bin/sh -e
ARCH="$1"
SCRATCH=scratch/no-rpath-$ARCH

if [ -z "$ARCH" ]; then
  ARCH=$(basename $0 .sh | sed -e 's/.*-//')
fi

if [ -z "$ARCH" ] || [ $ARCH = prebuild ] ; then
  echo "Architecture required"
  exit 1
fi

no_rpath_bin="${srcdir}/no-rpath-prebuild/no-rpath-$ARCH"

if [ ! -f $no_rpath_bin ]; then
  echo "no 'no-rpath' binary for '$ARCH' in '${srcdir}/no-rpath-prebuild'"
  exit 1
fi

rm -rf ${SCRATCH}
mkdir -p ${SCRATCH}

cp $no_rpath_bin ${SCRATCH}/no-rpath

oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
if test -n "$oldRPath"; then exit 1; fi
../src/patchelf \
  --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \
  --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath

newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
if ! echo "$newRPath" | grep -q '/foo:/bar'; then
    echo "incomplete RPATH"
    exit 1
fi

if [ "$(../src/patchelf --print-interpreter $no_rpath_bin)" \
     = "$(../src/patchelf --print-interpreter ../src/patchelf)" ]; then
    cd ${SCRATCH} && ./no-rpath
fi