🐛 Make payload_test fail when it aborts
payload_test.sh's new fat-bundle case never ran: bundle() read its directory argument after shifting it away, so set -u stopped the script at the first bundle. And the stop read as a pass: the script removed its scratch from an EXIT trap, and bash 3.2, macOS's, exits 0 from a set -u error where an EXIT trap is set, so make test went on green (measured: the same script exits 1 with no trap, 0 with one, even one that exits with the status it saw). bundle() keeps its directory in a local before it shifts, and the scratch is removed at the end of a run that finishes instead of from a trap; one that aborts leaves it for the next run, which removes it first.
This commit is contained in:
1 parent
2db6812618
commit
71ea77ffda
1 file changed
+7
-5
@@ -10,25 +10,26 @@
|
||||
# admission decision (rgfx_cdhash_allowed over kExecCDHashes, the arm64 hooks' allowed set)
|
||||
# takes the arm64 slice's hash, which third-party processes present, and the arm64e slice's,
|
||||
# which is kExecCDHash and comes first.
|
||||
# SCRATCH is removed first and at the end. Nothing is fetched.
|
||||
# SCRATCH is removed first and at the end of a run that finishes; one that aborts leaves it for
|
||||
# the next to remove. No EXIT trap removes it: bash 3.2, macOS's, exits 0 from a set -u error
|
||||
# where one is set, which would make an aborted run read as a pass. Nothing is fetched.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
S=$1
|
||||
rm -rf "$S"
|
||||
mkdir -p "$S"
|
||||
trap 'rm -rf "$S"' EXIT
|
||||
fails=0
|
||||
|
||||
# bundle DIR CODE [ARCH...]: a signed reims-graphics.bundle in DIR whose executable returns
|
||||
# CODE, with a slice for each ARCH (x86_64 alone where none is given).
|
||||
bundle() {
|
||||
local b=$1/reims-graphics.bundle code=$2
|
||||
local dir=$1 b=$1/reims-graphics.bundle code=$2
|
||||
shift 2
|
||||
local archs=()
|
||||
for a in "${@:-x86_64}"; do archs+=(-arch "$a"); done
|
||||
mkdir -p "$b/Contents/MacOS" "$b/Contents/Resources"
|
||||
printf 'int main(void) { return %d; }\n' "$code" > "$1/main.c"
|
||||
xcrun --sdk macosx clang "${archs[@]}" "$1/main.c" -o "$b/Contents/MacOS/reims-graphics"
|
||||
printf 'int main(void) { return %d; }\n' "$code" > "$dir/main.c"
|
||||
xcrun --sdk macosx clang "${archs[@]}" "$dir/main.c" -o "$b/Contents/MacOS/reims-graphics"
|
||||
touch "$b/Contents/Resources/wire-version-2"
|
||||
cat > "$b/Contents/Info.plist" <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -121,5 +122,6 @@ GE=$(python3 -I -c 'import sys; print(",".join(str(b) for b in bytes.fromhex(sys
|
||||
expect "an arm64 guest's kExecCDHash is the arm64e slice's" \
|
||||
"$(sed -n 's/^static const uint8_t kExecCDHash\[20\] = {\(.*\)};$/\1/p' "$S/build64/gen/RgfxGatePayload.h")" "$GE"
|
||||
|
||||
rm -rf "$S"
|
||||
[ $fails = 0 ] || exit 1
|
||||
echo "payload_test: all checks passed"
|
||||
Reference in new issue
Block a user