test: fix checking output / initrd content

shellcheck correctly complains:

```
In debian/tests/qemu-klibc line 13:
! lsinitramfs "${INITRAMFS}" | grep -qw busybox
^-- SC2251 (info): This ! is not on a condition and skips errexit. Use `&& exit 1` instead, or make sure $? is checked.

Did you mean:
 lsinitramfs "${INITRAMFS}" | grep -qw busybox && exit 1

In debian/tests/qemu-panic-shell line 30:
! grep -qF "(initramfs) " "${OUTPUT}"
^-- SC2251 (info): This ! is not on a condition and skips errexit. Use `&& exit 1` instead, or make sure $? is checked.

Did you mean:
 grep -qF "(initramfs) " "${OUTPUT}" && exit 1

For more information:
  https://www.shellcheck.net/wiki/SC2251 -- This ! is not on a condition and ...
```

So the result oft those checks were just ignored. Fix that and add error
messages for the failure case. Otherwise there would be no output
explaining the exit code.

Note: The recommendation from https://www.shellcheck.net/wiki/SC2251
would cause qemu-panic-shell to always fail:
https://github.com/koalaman/shellcheck/issues/3121
This commit is contained in:
Benjamin Drung 2025-02-24 11:36:02 +01:00
parent 84115f9118
commit a83ddc24ff
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ BUSYBOX=n
FSTYPE=ext2
EOF
build_initramfs
! lsinitramfs "${INITRAMFS}" | grep -qw busybox
! lsinitramfs "${INITRAMFS}" | grep -qw busybox || { echo "Error: busybox found in ${INITRAMFS}!" >&2; exit 1; }
build_rootfs_ext2

View File

@ -28,9 +28,9 @@ grep -qF "(initramfs) " "${OUTPUT}"
run_qemu_nocheck "panic=-1"
check_no_network_configuration
grep -qF "Rebooting automatically due to panic= boot argument" "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}" || { echo "Error: '(initramfs) ' found in output log!" >&2; exit 1; }
run_qemu_nocheck "panic=0"
check_no_network_configuration
grep -qF "Halting automatically due to panic= boot argument" "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}"
! grep -qF "(initramfs) " "${OUTPUT}" || { echo "Error: '(initramfs) ' found in output log!" >&2; exit 1; }