diff --git a/qemu/tests/payload-dir.sh b/qemu/tests/payload-dir.sh index 2cd8a81..6fd6f93 100755 --- a/qemu/tests/payload-dir.sh +++ b/qemu/tests/payload-dir.sh @@ -84,23 +84,33 @@ if OUT="$OUT1" BUSYBOX="$BUSYBOX_BIN" PAYLOAD_DIR="$ALT" \ IMG="$SCRATCH/$slot.1.img" extract_part "$OUT1/disk.img" "$slot" "$IMG" ui="$(debugfs -R "cat /usr/bin/warden-ui" "$IMG" 2>/dev/null)" - [ "$ui" = "alt-ui" ] \ - && pass "PAYLOAD_DIR: $slot carries the run's own warden-ui" \ - || fail "PAYLOAD_DIR: $slot warden-ui = '$ui', want 'alt-ui'" + if [ "$ui" = "alt-ui" ]; then + pass "PAYLOAD_DIR: $slot carries the run's own warden-ui" + else + fail "PAYLOAD_DIR: $slot warden-ui = '$ui', want 'alt-ui'" + fi tool="$(debugfs -R "cat /usr/bin/wthctl" "$IMG" 2>/dev/null)" - [ "$tool" = "linked tool" ] \ - && pass "PAYLOAD_DIR: $slot gets a symlinked entry's content" \ - || fail "PAYLOAD_DIR: $slot wthctl = '$tool', want the symlink target's content" + if [ "$tool" = "linked tool" ]; then + pass "PAYLOAD_DIR: $slot gets a symlinked entry's content" + else + fail "PAYLOAD_DIR: $slot wthctl = '$tool', want the symlink target's content" + fi mode="$(debugfs -R "stat /usr/bin/wthctl" "$IMG" 2>/dev/null | grep -oE 'Mode: *[0-7]+' | grep -oE '[0-7]+$')" - [ "$mode" = "0755" ] \ - && pass "PAYLOAD_DIR: $slot installs a regular 0755 file for the symlink" \ - || fail "PAYLOAD_DIR: $slot wthctl mode '$mode', want 0755" - debugfs -R "stat /usr/bin/warden-default-only" "$IMG" 2>&1 | grep -q 'File not found' \ - && pass "PAYLOAD_DIR: $slot has nothing from qemu/payload" \ - || fail "PAYLOAD_DIR: $slot carries qemu/payload's warden-default-only" - debugfs -R "stat /usr/bin/README.md" "$IMG" 2>&1 | grep -q 'File not found' \ - && pass "PAYLOAD_DIR: $slot skips the set's README.md" \ - || fail "PAYLOAD_DIR: $slot carries the set's README.md" + if [ "$mode" = "0755" ]; then + pass "PAYLOAD_DIR: $slot installs a regular 0755 file for the symlink" + else + fail "PAYLOAD_DIR: $slot wthctl mode '$mode', want 0755" + fi + if debugfs -R "stat /usr/bin/warden-default-only" "$IMG" 2>&1 | grep -q 'File not found'; then + pass "PAYLOAD_DIR: $slot has nothing from qemu/payload" + else + fail "PAYLOAD_DIR: $slot carries qemu/payload's warden-default-only" + fi + if debugfs -R "stat /usr/bin/README.md" "$IMG" 2>&1 | grep -q 'File not found'; then + pass "PAYLOAD_DIR: $slot skips the set's README.md" + else + fail "PAYLOAD_DIR: $slot carries the set's README.md" + fi done else fail "PAYLOAD_DIR: mkimage.sh exited nonzero with a valid payload dir (see $SCRATCH/mkimage1.log)" @@ -113,9 +123,11 @@ if OUT="$OUT2" BUSYBOX="$BUSYBOX_BIN" \ IMG="$SCRATCH/rootfs_a.2.img" extract_part "$OUT2/disk.img" rootfs_a "$IMG" ui="$(debugfs -R "cat /usr/bin/warden-ui" "$IMG" 2>/dev/null)" - [ "$ui" = "default-ui" ] \ - && pass "no PAYLOAD_DIR: rootfs_a carries qemu/payload's warden-ui" \ - || fail "no PAYLOAD_DIR: rootfs_a warden-ui = '$ui', want 'default-ui'" + if [ "$ui" = "default-ui" ]; then + pass "no PAYLOAD_DIR: rootfs_a carries qemu/payload's warden-ui" + else + fail "no PAYLOAD_DIR: rootfs_a warden-ui = '$ui', want 'default-ui'" + fi else fail "no PAYLOAD_DIR: mkimage.sh exited nonzero (see $SCRATCH/mkimage2.log)" fi @@ -146,9 +158,11 @@ printf 'page Demo\n' > "$SCRATCH/drive.txt" : > "$SCRATCH/zImage" err4="$(PAYLOAD_DIR="$EMPTY" PATH="$SCRATCH/nobin" "$BASH_BIN" "$QEMU_DIR/tests/ui-drive.sh" \ "$SCRATCH/zImage" "$SCRATCH/drive.txt" "$SCRATCH/drive-out" 2>&1)" -printf '%s' "$err4" | grep -qF "FATAL: no warden-ui in $EMPTY" \ - && pass "ui-drive.sh: a PAYLOAD_DIR without warden-ui is refused, naming the directory" \ - || fail "ui-drive.sh: PAYLOAD_DIR without warden-ui gave '$err4'" +if printf '%s' "$err4" | grep -qF "FATAL: no warden-ui in $EMPTY"; then + pass "ui-drive.sh: a PAYLOAD_DIR without warden-ui is refused, naming the directory" +else + fail "ui-drive.sh: PAYLOAD_DIR without warden-ui gave '$err4'" +fi chmod +x "$ALT/warden-ui" err5="$(PAYLOAD_DIR="$ALT" PATH="$SCRATCH/nobin" "$BASH_BIN" "$QEMU_DIR/tests/ui-drive.sh" \ "$SCRATCH/zImage" "$SCRATCH/drive.txt" "$SCRATCH/drive-out" 2>&1)"