Skip to content

Commit edec2a9

Browse files
Mic92Ericson2314
authored andcommitted
tests: apply suggestions from shellcheck
Re-cherry-pick for the files that were not in the last cherry-pick. (cherry picked from commit be4b846)
1 parent aeaaa42 commit edec2a9

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

tests/change-abi.sh

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
11
#! /bin/sh -e
22

3-
SCRATCH=scratch/$(basename $0 .sh)
3+
SCRATCH=scratch/$(basename "$0" .sh)
44

5-
rm -rf ${SCRATCH}
6-
mkdir -p ${SCRATCH}
5+
rm -rf "${SCRATCH}"
6+
mkdir -p "${SCRATCH}"
77

8-
cp simple-pie ${SCRATCH}/simple-pie
8+
cp simple-pie "${SCRATCH}/simple-pie"
99

1010
# Save the old OS ABI
11-
OLDABI=`../src/patchelf --print-os-abi ${SCRATCH}/simple-pie`
11+
OLDABI=$(../src/patchelf --print-os-abi "${SCRATCH}/simple-pie")
1212
# Ensure it's not empty
1313
test -n "$OLDABI"
1414

1515
# Change OS ABI and verify it has been changed
16-
{
17-
echo "System V"
18-
echo "HP-UX"
19-
echo "NetBSD"
20-
echo "Linux"
21-
echo "GNU Hurd"
22-
echo "Solaris"
23-
echo "AIX"
24-
echo "IRIX"
25-
echo "FreeBSD"
26-
echo "Tru64"
27-
echo "OpenBSD"
28-
echo "OpenVMS"
29-
} | {
30-
while IFS="\n" read ABI; do
31-
echo "Set OS ABI to '$ABI'..."
32-
../src/patchelf --set-os-abi "$ABI" ${SCRATCH}/simple-pie
33-
34-
echo "Check is OS ABI is '$ABI'..."
35-
NEWABI=`../src/patchelf --print-os-abi ${SCRATCH}/simple-pie`
36-
test "$NEWABI" = "$ABI"
37-
done
38-
}
16+
for ABI in "System V" "HP-UX" "NetBSD" "Linux" "GNU Hurd" "Solaris" "AIX" "IRIX" "FreeBSD" "Tru64" "OpenBSD" "OpenVMS"; do
17+
echo "Set OS ABI to '$ABI'..."
18+
../src/patchelf --set-os-abi "$ABI" "${SCRATCH}/simple-pie"
19+
20+
echo "Check is OS ABI is '$ABI'..."
21+
NEWABI=$(../src/patchelf --print-os-abi "${SCRATCH}/simple-pie")
22+
test "$NEWABI" = "$ABI"
23+
done
3924

4025
# Reset OS ABI to the saved one
41-
../src/patchelf --set-os-abi "$OLDABI" ${SCRATCH}/simple-pie
26+
../src/patchelf --set-os-abi "$OLDABI" "${SCRATCH}/simple-pie"
4227

4328
# Verify we still can run the executable
44-
${SCRATCH}/simple-pie
29+
"${SCRATCH}/simple-pie"

tests/empty-note.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#! /bin/sh -e
22

3-
SCRATCH=scratch/$(basename $0 .sh)
3+
SCRATCH=scratch/$(basename "$0" .sh)
44

5-
rm -rf ${SCRATCH}
6-
mkdir -p ${SCRATCH}
7-
cp $(dirname $(readlink -f $0))/empty-note ${SCRATCH}/
5+
rm -rf "${SCRATCH}"
6+
mkdir -p "${SCRATCH}"
7+
cp "$(dirname "$(readlink -f "$0")")/empty-note" "${SCRATCH}/"
88

99
# Running --set-interpreter on this binary should not produce the following
1010
# error:
1111
# patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections
12-
../src/patchelf --set-interpreter ld-linux-x86-64.so.2 ${SCRATCH}/empty-note
12+
../src/patchelf --set-interpreter ld-linux-x86-64.so.2 "${SCRATCH}/empty-note"

0 commit comments

Comments
 (0)