* [PATCH v4 0/9] Various fixes/improvements for tests
@ 2021-10-13 0:39 Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 1/9] tests: Fix partmap_test for arm*-efi, disk numbering has changed Glenn Washburn
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
Updates since v3:
* Dropped iso9660_test LANG patch
* Merged v3 in v2
* Rewrote commit message for #4 to hopefully be clearer
* Replace `...` with $(...)
These are mostly test improvement and fixes that stand on their own.
Glenn
Glenn Washburn (9):
tests: Fix partmap_test for arm*-efi, disk numbering has changed
tests: When checking squashfs fstime, use superblock last modified
time
tests: Add set -e to missing tests
tests: Do not occlude subshell error codes when used as input to the
test command
tests: Do not occlude grub-shell return code
tests: Make setup errors in grub-fs-tester hard errors
tests: A failure of mktemp should cause the test script to exit with
code 99
tests: Exit with skipped exit code when test not performed
tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell
tests/ahci_test.in | 19 ++++++++++++-------
tests/cdboot_test.in | 11 ++++++-----
tests/core_compress_test.in | 8 +++++---
tests/ehci_test.in | 19 ++++++++++++-------
tests/f2fs_test.in | 2 +-
tests/fddboot_test.in | 19 ++++++++++---------
tests/gettext_strings_test.in | 2 +-
tests/grub_cmd_date.in | 5 +++--
tests/grub_cmd_set_date.in | 6 +++---
tests/grub_cmd_sleep.in | 2 +-
tests/grub_cmd_test.in | 7 ++++---
tests/grub_script_blockarg.in | 3 ++-
tests/grub_script_expansion.in | 3 ++-
tests/gzcompress_test.in | 3 ++-
tests/hddboot_test.in | 9 +++++----
tests/lzocompress_test.in | 3 ++-
tests/netboot_test.in | 15 ++++++++-------
tests/ohci_test.in | 19 ++++++++++++-------
tests/partmap_test.in | 18 +++++++++---------
tests/pata_test.in | 13 +++++++------
tests/pseries_test.in | 2 +-
tests/syslinux_test.in | 2 +-
tests/test_sha512sum.in | 7 ++++---
tests/uhci_test.in | 19 ++++++++++++-------
tests/util/grub-fs-tester.in | 17 ++++++++++++-----
tests/xzcompress_test.in | 3 ++-
26 files changed, 139 insertions(+), 97 deletions(-)
Range-diff against v3:
1: 3a2cc2738 = 1: 3a2cc2738 tests: Fix partmap_test for arm*-efi, disk numbering has changed
2: 3da044f56 = 2: 3da044f56 tests: When checking squashfs fstime, use superblock last modified time
3: a061a35f5 = 3: a061a35f5 tests: Add set -e to missing tests
4: ab85eb4c8 ! 4: 5828e4c79 tests: Do not occlude subshell error codes
@@ Metadata
Author: Glenn Washburn <development@efficientek.com>
## Commit message ##
- tests: Do not occlude subshell error codes
+ tests: Do not occlude subshell error codes when used as input to the test command
- When a subshell's output is used as input to a "simple command", its return
- code is not checked. These subshells contain an execution of the grub-shell
- script which does the work of the actual test. If grub-shell returns an
- error code, the test should fail. So refactor to not have the subshell which
- contains grub-shell be direct input into a simple command (usually the test
- command). Mostly this is accomplished by having the output first go to a
- shell variable, and then using the shell variable in the simple command.
+ When using the output of a subshell as input, its error code is ignored in
+ the context of "set -e". Many test scripts use grub-shell in a subshell with
+ output used as an argument to the test command to test for expected output.
+ Refactor these tests so that the subshell output goes to a shell variable,
+ so that if the subshell errors the script will immediately exit with an
+ error code.
## tests/ahci_test.in ##
@@ tests/ahci_test.in: echo "hello" > "$outfile"
@@ tests/cdboot_test.in: case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}"
esac
-if [ "$(echo hello | "${grubshell}" --boot=cd)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --boot=cd`
++v=$(echo hello | "${grubshell}" --boot=cd)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/core_compress_test.in: case "${grub_modinfo_target_cpu}-${grub_modinfo_pla
-if [ "$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz`
++v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
-if [ "$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none`
++v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/fddboot_test.in: case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}
esac
-if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad"`
++v=$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/gzcompress_test.in: if ! which gzip >/dev/null 2>&1; then
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=gz)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --mkrescue-arg=--compress=gz`
++v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=gz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/hddboot_test.in: case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}
esac
-if [ "$(echo hello | "${grubshell}" --boot=hd)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --boot=hd`
++v=$(echo hello | "${grubshell}" --boot=hd)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/lzocompress_test.in: if ! which lzop >/dev/null 2>&1; then
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo`
++v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/netboot_test.in: case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}
esac
-if [ "$(echo hello | "${grubshell}" --boot=net)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --boot=net`
++v=$(echo hello | "${grubshell}" --boot=net)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
@@ tests/pata_test.in: echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")" != "Hello World" ]; then
-+v=`echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile"`
++v=$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
@@ tests/xzcompress_test.in: if ! which xz >/dev/null 2>&1; then
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=xz)" != "Hello World" ]; then
-+v=`echo hello | "${grubshell}" --mkrescue-arg=--compress=xz`
++v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=xz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
5: fac9d9cae = 5: 37097a173 tests: Do not occlude grub-shell return code
6: dae3591c4 = 6: c703a1b2f tests: Make setup errors in grub-fs-tester hard errors
7: 5f2fb19e9 = 7: 23a0d5358 tests: A failure of mktemp should cause the test script to exit with code 99
8: 2a2e491bd ! 8: a4d79a908 tests: Exit with skipped exit code when test not performed
@@ tests/cdboot_test.in: grubshell=@builddir@/grub-shell
+ exit 77;;
esac
- v=`echo hello | "${grubshell}" --boot=cd`
+ v=$(echo hello | "${grubshell}" --boot=cd)
## tests/core_compress_test.in ##
@@ tests/core_compress_test.in: grubshell=@builddir@/grub-shell
@@ tests/fddboot_test.in: grubshell=@builddir@/grub-shell
+ exit 77;;
esac
- v=`echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad"`
+ v=$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")
## tests/grub_cmd_date.in ##
@@ tests/grub_cmd_date.in: set -e
@@ tests/hddboot_test.in: grubshell=@builddir@/grub-shell
+ exit 77;;
esac
- v=`echo hello | "${grubshell}" --boot=hd`
+ v=$(echo hello | "${grubshell}" --boot=hd)
## tests/netboot_test.in ##
@@ tests/netboot_test.in: grubshell=@builddir@/grub-shell
@@ tests/netboot_test.in: grubshell=@builddir@/grub-shell
+ exit 77;;
esac
- v=`echo hello | "${grubshell}" --boot=net`
+ v=$(echo hello | "${grubshell}" --boot=net)
## tests/ohci_test.in ##
@@ tests/ohci_test.in: grubshell=@builddir@/grub-shell
9: 606b9b818 = 9: a7119dfc4 tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell
--
2.27.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 1/9] tests: Fix partmap_test for arm*-efi, disk numbering has changed
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
@ 2021-10-13 0:39 ` Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 2/9] tests: When checking squashfs fstime, use superblock last modified time Glenn Washburn
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
Perhaps using a newer UEFI firmware is the reason for the created test disk
showing up as hd2 instead of hd3.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/partmap_test.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
index 6ef518b0a..7353dc70e 100644
--- a/tests/partmap_test.in
+++ b/tests/partmap_test.in
@@ -89,7 +89,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
disk=arc/scsi0/disk0/rdisk0
;;
arm*-efi)
- disk=hd3
+ disk=hd2
;;
*)
disk=hd0
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 2/9] tests: When checking squashfs fstime, use superblock last modified time
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 1/9] tests: Fix partmap_test for arm*-efi, disk numbering has changed Glenn Washburn
@ 2021-10-13 0:39 ` Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 3/9] tests: Add set -e to missing tests Glenn Washburn
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
Currently, the filesystem timestamp check in grub-fs-tester uses the
squashfs image file's last modified timestamp and checks to see if that
time stamp is within 3 seconds of the superblock timestamp as determined by
grub. The image file's timestamp could be more than 3 seconds off if
mksquashfs takes more than 3 seconds to generate the image, as is the case
on a virtual machine. Instead use squashfs tools to get the filesystem
timestamp directly.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/util/grub-fs-tester.in | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index a28e07295..cba94233d 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -1356,6 +1356,12 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
# With some abstractions like mdraid flushing to disk
# may be delayed for a long time.
FSTIME="$UMOUNT_TIME";;
+ xsquash*)
+ # Creating the squash image may take more than a few
+ # seconds. Use the more accurate timestamp from the
+ # superblock.
+ FSTIME="$(unsquashfs -s "${FSIMAGEP}0.img" | grep ^Creation | awk '{print $6 " " $7 " " $8 " " $9 " " $10; }')"
+ FSTIME="$(date -d "$FSTIME" -u '+%Y-%m-%d %H:%M:%S')";;
*)
FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGEP}0.img"|awk '{print $6; }'|sed 's,_, ,g')";;
esac
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 3/9] tests: Add set -e to missing tests
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 1/9] tests: Fix partmap_test for arm*-efi, disk numbering has changed Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 2/9] tests: When checking squashfs fstime, use superblock last modified time Glenn Washburn
@ 2021-10-13 0:39 ` Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command Glenn Washburn
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
This helps to ensure that error codes do not get ignored.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/grub_cmd_test.in | 1 +
tests/grub_script_blockarg.in | 1 +
tests/test_sha512sum.in | 1 +
3 files changed, 3 insertions(+)
diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in
index 3399eb292..dac6f7d6a 100644
--- a/tests/grub_cmd_test.in
+++ b/tests/grub_cmd_test.in
@@ -1,4 +1,5 @@
#! @BUILD_SHEBANG@
+set -e
# create a randome file
empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
diff --git a/tests/grub_script_blockarg.in b/tests/grub_script_blockarg.in
index 6ea9b8c3d..134a43b05 100644
--- a/tests/grub_script_blockarg.in
+++ b/tests/grub_script_blockarg.in
@@ -1,4 +1,5 @@
#! @BUILD_SHEBANG@
+set -e
# Run GRUB script in a Qemu instance
# Copyright (C) 2010 Free Software Foundation, Inc.
diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in
index 027092a8b..d97b7ae2c 100644
--- a/tests/test_sha512sum.in
+++ b/tests/test_sha512sum.in
@@ -1,4 +1,5 @@
#! @BUILD_SHEBANG@
+set -e
# create a randome file
file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (2 preceding siblings ...)
2021-10-13 0:39 ` [PATCH v4 3/9] tests: Add set -e to missing tests Glenn Washburn
@ 2021-10-13 0:39 ` Glenn Washburn
2021-10-14 11:27 ` Daniel Kiper
2021-10-13 0:39 ` [PATCH v4 5/9] tests: Do not occlude grub-shell return code Glenn Washburn
` (4 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
When using the output of a subshell as input, its error code is ignored in
the context of "set -e". Many test scripts use grub-shell in a subshell with
output used as an argument to the test command to test for expected output.
Refactor these tests so that the subshell output goes to a shell variable,
so that if the subshell errors the script will immediately exit with an
error code.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/ahci_test.in | 7 ++++++-
tests/cdboot_test.in | 3 ++-
tests/core_compress_test.in | 6 ++++--
tests/ehci_test.in | 7 ++++++-
tests/fddboot_test.in | 3 ++-
tests/gzcompress_test.in | 3 ++-
tests/hddboot_test.in | 3 ++-
tests/lzocompress_test.in | 3 ++-
tests/netboot_test.in | 3 ++-
tests/ohci_test.in | 7 ++++++-
tests/pata_test.in | 3 ++-
tests/uhci_test.in | 7 ++++++-
tests/xzcompress_test.in | 3 ++-
13 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index d844fe680..56760326a 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -41,7 +41,12 @@ echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '(ahci0)/$outfile';" | "${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 " | tail -n 1)" != "Hello World" ]; then
+v=$(echo "nativedisk; source '(ahci0)/$outfile';" |
+ "${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none
+ -device ahci,id=ahci
+ -device ide-hd,drive=disk,bus=ahci.0" |
+ tail -n 1)
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
diff --git a/tests/cdboot_test.in b/tests/cdboot_test.in
index 75acdfedb..bf9549a6b 100644
--- a/tests/cdboot_test.in
+++ b/tests/cdboot_test.in
@@ -34,6 +34,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-if [ "$(echo hello | "${grubshell}" --boot=cd)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --boot=cd)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/core_compress_test.in b/tests/core_compress_test.in
index 9d216ebcf..52708fd83 100644
--- a/tests/core_compress_test.in
+++ b/tests/core_compress_test.in
@@ -27,10 +27,12 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
esac
-if [ "$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=xz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
-if [ "$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --grub-mkimage-extra=--compress=none)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
index b197f8cdc..c368c59ec 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -41,7 +41,12 @@ echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device ich9-usb-ehci1 -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then
+v=$(echo "nativedisk; source '(usb0)/$outfile';" |
+ "${grubshell}" --qemu-opts="-device ich9-usb-ehci1
+ -drive id=my_usb_disk,file=$imgfile,if=none
+ -device usb-storage,drive=my_usb_disk" |
+ tail -n 1)
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in
index 2d7dfc889..32281c75f 100644
--- a/tests/fddboot_test.in
+++ b/tests/fddboot_test.in
@@ -46,6 +46,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/gzcompress_test.in b/tests/gzcompress_test.in
index 42c8fe7c4..d7a594bb2 100644
--- a/tests/gzcompress_test.in
+++ b/tests/gzcompress_test.in
@@ -24,6 +24,7 @@ if ! which gzip >/dev/null 2>&1; then
exit 77
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=gz)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=gz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/hddboot_test.in b/tests/hddboot_test.in
index 6d70847a5..ded2cde7b 100644
--- a/tests/hddboot_test.in
+++ b/tests/hddboot_test.in
@@ -31,7 +31,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-if [ "$(echo hello | "${grubshell}" --boot=hd)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --boot=hd)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/lzocompress_test.in b/tests/lzocompress_test.in
index 4e5f7e078..42e270df0 100644
--- a/tests/lzocompress_test.in
+++ b/tests/lzocompress_test.in
@@ -24,6 +24,7 @@ if ! which lzop >/dev/null 2>&1; then
exit 77
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=lzo)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/netboot_test.in b/tests/netboot_test.in
index 9f71e3d88..b274f3e2d 100644
--- a/tests/netboot_test.in
+++ b/tests/netboot_test.in
@@ -40,6 +40,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-if [ "$(echo hello | "${grubshell}" --boot=net)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --boot=net)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
index 8693f8c47..45949fb4c 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -41,7 +41,12 @@ echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device pci-ohci -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then
+v=$(echo "nativedisk; source '(usb0)/$outfile';" |
+ "${grubshell}" --qemu-opts="-device pci-ohci
+ -drive id=my_usb_disk,file=$imgfile,if=none
+ -device usb-storage,drive=my_usb_disk" |
+ tail -n 1)
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
diff --git a/tests/pata_test.in b/tests/pata_test.in
index 4b18fdef3..38dff74a8 100644
--- a/tests/pata_test.in
+++ b/tests/pata_test.in
@@ -45,7 +45,8 @@ echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")" != "Hello World" ]; then
+v=$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index f0eec5032..5a3b94c65 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -41,7 +41,12 @@ echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
-if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device ich9-usb-uhci1 -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then
+v=$(echo "nativedisk; source '(usb0)/$outfile';" |
+ "${grubshell}" --qemu-opts="-device ich9-usb-uhci1
+ -drive id=my_usb_disk,file=$imgfile,if=none
+ -device usb-storage,drive=my_usb_disk" |
+ tail -n 1)
+if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
diff --git a/tests/xzcompress_test.in b/tests/xzcompress_test.in
index 03bfb5e95..cfc6ccba6 100644
--- a/tests/xzcompress_test.in
+++ b/tests/xzcompress_test.in
@@ -24,6 +24,7 @@ if ! which xz >/dev/null 2>&1; then
exit 77
fi
-if [ "$(echo hello | "${grubshell}" --mkrescue-arg=--compress=xz)" != "Hello World" ]; then
+v=$(echo hello | "${grubshell}" --mkrescue-arg=--compress=xz)
+if [ "$v" != "Hello World" ]; then
exit 1
fi
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 5/9] tests: Do not occlude grub-shell return code
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (3 preceding siblings ...)
2021-10-13 0:39 ` [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command Glenn Washburn
@ 2021-10-13 0:39 ` Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 6/9] tests: Make setup errors in grub-fs-tester hard errors Glenn Washburn
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:39 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
The script grub-shell does the bulk of the testing. If it returns an error
code, that means that the test failed and the test should immediately exit
with that error code. When grub-shell is used as a non-terminating command
in a pipeline, eg. when data needs to be extracted from its output, its
error code will be occluded by the last command in the pipeline. Refactor
tests so that the shell will error with the exit code of grub-shell by
breaking up pipelines such that grub-shell is always the last command in the
pipeline that it is used in.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/ahci_test.in | 4 ++--
tests/ehci_test.in | 4 ++--
tests/grub_cmd_date.in | 3 ++-
tests/grub_script_expansion.in | 3 ++-
tests/ohci_test.in | 4 ++--
tests/partmap_test.in | 4 ++--
tests/uhci_test.in | 4 ++--
7 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index 56760326a..7853bb8b6 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(ahci0)/$outfile';" |
"${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none
-device ahci,id=ahci
- -device ide-hd,drive=disk,bus=ahci.0" |
- tail -n 1)
+ -device ide-hd,drive=disk,bus=ahci.0")
+v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
index c368c59ec..426bfa7db 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device ich9-usb-ehci1
-drive id=my_usb_disk,file=$imgfile,if=none
- -device usb-storage,drive=my_usb_disk" |
- tail -n 1)
+ -device usb-storage,drive=my_usb_disk")
+v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in
index f7c9ca004..f9156691e 100644
--- a/tests/grub_cmd_date.in
+++ b/tests/grub_cmd_date.in
@@ -9,7 +9,8 @@ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ];
fi
pdt="$(date -u +%s)"
-dt=`echo date | @builddir@/grub-shell | sed 's, [A-Z][a-z]*$,,'`
+dt=`echo date | @builddir@/grub-shell`
+dt=`echo "$dt" | sed 's, [A-Z][a-z]*$,,'`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"
diff --git a/tests/grub_script_expansion.in b/tests/grub_script_expansion.in
index 9d0dcdd29..98d5a9068 100644
--- a/tests/grub_script_expansion.in
+++ b/tests/grub_script_expansion.in
@@ -17,7 +17,8 @@ set -e
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
-disks=`echo ls | @builddir@/grub-shell| grep -av '^Network protocols:$'| grep -av '^tftp http $'`
+disks=`echo ls | @builddir@/grub-shell`
+disks=`echo "$disks"| grep -av '^Network protocols:$'| grep -av '^tftp http $'`
other=`echo insmod regexp\; echo \* | @builddir@/grub-shell`
for d in $disks; do
if echo "$d" |grep ',' >/dev/null; then
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
index 45949fb4c..2b96539b8 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device pci-ohci
-drive id=my_usb_disk,file=$imgfile,if=none
- -device usb-storage,drive=my_usb_disk" |
- tail -n 1)
+ -device usb-storage,drive=my_usb_disk")
+v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
index 7353dc70e..5f18ab51c 100644
--- a/tests/partmap_test.in
+++ b/tests/partmap_test.in
@@ -58,8 +58,8 @@ list_parts () {
shift
echo ls | "${grubshell}" --disk="${imgfile}" \
- --modules=$mod | tr -d "\n\r" > "${outfile}"
- cat "${outfile}"
+ --modules=$mod > "${outfile}"
+ cat "${outfile}" | tr -d "\n\r"
echo
}
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index 5a3b94c65..9a9492a43 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device ich9-usb-uhci1
-drive id=my_usb_disk,file=$imgfile,if=none
- -device usb-storage,drive=my_usb_disk" |
- tail -n 1)
+ -device usb-storage,drive=my_usb_disk")
+v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 6/9] tests: Make setup errors in grub-fs-tester hard errors
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (4 preceding siblings ...)
2021-10-13 0:39 ` [PATCH v4 5/9] tests: Do not occlude grub-shell return code Glenn Washburn
@ 2021-10-13 0:40 ` Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 7/9] tests: A failure of mktemp should cause the test script to exit with code 99 Glenn Washburn
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:40 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
When a test program fails because it failed to setup the test properly, this
does not indicate a failure in what is attempting to be tested because the
test is never run. So exit with a hard error exit status to note this
difference. This will allow easier detection of tests that are not actually
being run and those that are really failing.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/util/grub-fs-tester.in | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index cba94233d..9a05a2d26 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -6,7 +6,8 @@ fs="$1"
GRUBFSTEST="@builddir@/grub-fstest"
-tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` ||
+{ echo "Failed to make temporary directory"; exit 99; }
# xorriso -as mkisofs options to ignore locale when processing file names and
# FSLABEL. This is especially needed for the conversion to Joliet UCS-2.
@@ -277,7 +278,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
done
if test "$CFILESRC" = "" ; then
echo "Couldn't find compressible file" >&2
- exit 1
+ exit 99
fi
case x"$fs" in
# FS LIMITATION: 8.3 names
@@ -621,7 +622,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
mkdir -p "$MNTPOINTRO"
for i in $(range 0 $((NDEVICES-1)) 1); do
dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 seek=$((DISKSIZE-1)) &> /dev/null
- LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img")
+ LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img") || exit 99
LODEVICES="$LODEVICES $LODEVICE"
if test "$i" = 0; then
MOUNTDEVICE="$LODEVICE"
@@ -825,7 +826,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
"mkfs.xfs" -m crc=1 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${MOUNTDEVICE}" ;;
*)
echo "Add appropriate mkfs command here"
- exit 1
+ exit 99
;;
esac
BASEFILE="1.img"
@@ -931,7 +932,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
for i in $(range 0 $((NDEVICES-1)) 1); do
rm "$FSIMAGEP${i}.img"
done
- exit 1;
+ exit 99;
fi
;;
esac
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 7/9] tests: A failure of mktemp should cause the test script to exit with code 99
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (5 preceding siblings ...)
2021-10-13 0:40 ` [PATCH v4 6/9] tests: Make setup errors in grub-fs-tester hard errors Glenn Washburn
@ 2021-10-13 0:40 ` Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 8/9] tests: Exit with skipped exit code when test not performed Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 9/9] tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell Glenn Washburn
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:40 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
A test exiting with code 99 means that there was an error in the test itself
and not a failure in the thing being tested (also known as a hard error).
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/ahci_test.in | 4 ++--
tests/ehci_test.in | 4 ++--
tests/gettext_strings_test.in | 2 +-
tests/grub_cmd_test.in | 6 +++---
tests/grub_script_blockarg.in | 2 +-
tests/ohci_test.in | 4 ++--
tests/partmap_test.in | 4 ++--
tests/pata_test.in | 4 ++--
tests/syslinux_test.in | 2 +-
tests/test_sha512sum.in | 6 +++---
tests/uhci_test.in | 4 ++--
11 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index 7853bb8b6..3f7645ad8 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -34,8 +34,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
index 426bfa7db..df408d77a 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -34,8 +34,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
diff --git a/tests/gettext_strings_test.in b/tests/gettext_strings_test.in
index 813999ebe..1c37fe41b 100644
--- a/tests/gettext_strings_test.in
+++ b/tests/gettext_strings_test.in
@@ -2,7 +2,7 @@
cd '@srcdir@'
-tdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
+tdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" || exit 99
xgettext -f po/POTFILES.in -L C -o "$tdir/"skip.pot -x po/grub.pot --keyword=grub_util_info --keyword=grub_dprintf:1,2 --keyword=grub_register_command --keyword=grub_register_extcmd --keyword=grub_efiemu_resolve_symbol --keyword=grub_efiemu_register_symbol --keyword=grub_dl_load --keyword=grub_crypto_lookup_md_by_name --keyword=grub_crypto_lookup_cipher_by_name --keyword=grub_efiemu_resolve_symbol --keyword=alias --keyword=grub_ieee1275_get_property:2 --keyword=grub_ieee1275_find_device --keyword=grub_ieee1275_get_integer_property:2 --keyword=INIT_IEEE1275_COMMON:2 --keyword=grub_boot_time --keyword=grub_env_get --keyword=grub_env_set --keyword=grub_register_variable_hook --keyword=grub_fatal --keyword=__asm__ --keyword=volatile --keyword=__volatile__ --keyword=grub_error:2 --from-code=iso-8859-1
xgettext -f po/POTFILES.in -L C -o "$tdir/"skip2.pot -x po/grub.pot --keyword=volatile:2 --keyword=__volatile__:2 --keyword=grub_dprintf:2 --from-code=iso-8859-1
diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in
index dac6f7d6a..043c3a634 100644
--- a/tests/grub_cmd_test.in
+++ b/tests/grub_cmd_test.in
@@ -2,8 +2,8 @@
set -e
# create a randome file
-empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
cat >$non_empty <<EOF
hello world!
EOF
@@ -21,7 +21,7 @@ else
fi
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
@builddir@/grub-shell --files=$grub_empty=$empty --files=$grub_non_empty=$non_empty>$outfile <<EOF
if ! test -f $grub_empty; then
echo FAIL1
diff --git a/tests/grub_script_blockarg.in b/tests/grub_script_blockarg.in
index 134a43b05..a91c7ca82 100644
--- a/tests/grub_script_blockarg.in
+++ b/tests/grub_script_blockarg.in
@@ -28,7 +28,7 @@ cmd='test_blockarg { true }'
v=`echo "$cmd" | @builddir@/grub-shell`
error_if_not "$v" '{ true }'
-tmp=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+tmp=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 99
cmd='test_blockarg { test_blockarg { true } }'
echo "$cmd" | @builddir@/grub-shell >$tmp
error_if_not "`head -n1 $tmp|tail -n1`" '{ test_blockarg { true } }'
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
index 2b96539b8..c72618656 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -34,8 +34,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
index 5f18ab51c..7906db43d 100644
--- a/tests/partmap_test.in
+++ b/tests/partmap_test.in
@@ -101,8 +101,8 @@ if ! which parted >/dev/null 2>&1; then
exit 77
fi
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
#
# MSDOS partition types
diff --git a/tests/pata_test.in b/tests/pata_test.in
index 38dff74a8..a69719bf5 100644
--- a/tests/pata_test.in
+++ b/tests/pata_test.in
@@ -38,8 +38,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
;;
esac
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in
index 4ea86390e..44d3cdf7a 100644
--- a/tests/syslinux_test.in
+++ b/tests/syslinux_test.in
@@ -2,7 +2,7 @@
set -e
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
"@builddir@/grub-syslinux2cfg" -r "@abs_top_srcdir@/tests/syslinux/ubuntu10.04" "@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile"
diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in
index d97b7ae2c..b2bd89609 100644
--- a/tests/test_sha512sum.in
+++ b/tests/test_sha512sum.in
@@ -2,7 +2,7 @@
set -e
# create a randome file
-file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
cat >$file <<EOF
hello world!
EOF
@@ -16,12 +16,12 @@ else
fi
-outfile1="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+outfile1="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
@builddir@/grub-shell --files=/boot/grub/file=$file >$outfile1 <<EOF
sha512sum $grub_file
EOF
-outfile2="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+outfile2="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
sha512sum $file >$outfile2
SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ `
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index 9a9492a43..7b8892c63 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -34,8 +34,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
-outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
echo "hello" > "$outfile"
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 8/9] tests: Exit with skipped exit code when test not performed
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (6 preceding siblings ...)
2021-10-13 0:40 ` [PATCH v4 7/9] tests: A failure of mktemp should cause the test script to exit with code 99 Glenn Washburn
@ 2021-10-13 0:40 ` Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 9/9] tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell Glenn Washburn
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:40 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
These tests were not performed and therefore did not pass, nor fail. This
fixes misleading test exit code where, for instance, the pseries_test will
pass on i386-pc, which is not a pseries architecture.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/ahci_test.in | 8 ++++----
tests/cdboot_test.in | 8 ++++----
tests/core_compress_test.in | 2 +-
tests/ehci_test.in | 8 ++++----
tests/fddboot_test.in | 16 ++++++++--------
tests/grub_cmd_date.in | 2 +-
tests/grub_cmd_set_date.in | 6 +++---
tests/grub_cmd_sleep.in | 2 +-
tests/hddboot_test.in | 6 +++---
tests/netboot_test.in | 12 ++++++------
tests/ohci_test.in | 8 ++++----
tests/partmap_test.in | 8 ++++----
tests/pata_test.in | 6 +++---
tests/pseries_test.in | 2 +-
tests/uhci_test.in | 8 ++++----
15 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index 3f7645ad8..6d2e61d4e 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -22,16 +22,16 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
- exit 0;;
+ exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
- exit 0;;
+ exit 77;;
# PLATFORM: no AHCI on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
- exit 0;;
+ exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
diff --git a/tests/cdboot_test.in b/tests/cdboot_test.in
index bf9549a6b..f00cdec58 100644
--- a/tests/cdboot_test.in
+++ b/tests/cdboot_test.in
@@ -22,16 +22,16 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
- exit 0;;
+ exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
- exit 0;;
+ exit 77;;
# FIXME: OFW fails to open CD-ROM
i386-ieee1275)
- exit 0;;
+ exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=cd)
diff --git a/tests/core_compress_test.in b/tests/core_compress_test.in
index 52708fd83..24a811418 100644
--- a/tests/core_compress_test.in
+++ b/tests/core_compress_test.in
@@ -22,7 +22,7 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: Only mips currently supports configurable core compression
*-emu | i386-* | x86_64-* | sparc64-* | ia64-*)
- exit 0
+ exit 77
;;
esac
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
index df408d77a..df671b4b6 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -22,16 +22,16 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
- exit 0;;
+ exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
- exit 0;;
+ exit 77;;
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
- exit 0;;
+ exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in
index 32281c75f..6ef49efcb 100644
--- a/tests/fddboot_test.in
+++ b/tests/fddboot_test.in
@@ -22,28 +22,28 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
- exit 0;;
+ exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
- exit 0;;
+ exit 77;;
# FIXME: We don't support EFI floppy boot in grub-mkrescue
*-efi)
- exit 0;;
+ exit 77;;
# FIXME: no floppy support
i386-multiboot)
- exit 0;;
+ exit 77;;
# FIXME: QEMU firmware crashes when trying to boot from floppy
sparc64-ieee1275)
- exit 0;;
+ exit 77;;
# FIXME: QEMU doesn't emulate SCSI floppies
mipsel-arc | mips-arc)
- exit 0;;
+ exit 77;;
# PLATFORM: powerpc doesn't boot from floppy except OldWorld Macs which we don't support anyway
powerpc-ieee1275)
- exit 0;;
+ exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")
diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in
index f9156691e..409cb684a 100644
--- a/tests/grub_cmd_date.in
+++ b/tests/grub_cmd_date.in
@@ -5,7 +5,7 @@ set -e
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
- exit 0
+ exit 77
fi
pdt="$(date -u +%s)"
diff --git a/tests/grub_cmd_set_date.in b/tests/grub_cmd_set_date.in
index aac120a6c..17673cd8a 100644
--- a/tests/grub_cmd_set_date.in
+++ b/tests/grub_cmd_set_date.in
@@ -6,15 +6,15 @@ set -e
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
sparc64-ieee1275)
- exit 0;;
+ exit 77;;
# PLATFORM: ARC doesn't provide any way to set time
*-arc)
- exit 0;;
+ exit 77;;
# PLATFORM: EMU doesn't provide any way to set time
# Even if it did we'd need some kind of sandbox to avoid
# modifying real system time.
*-emu)
- exit 0;;
+ exit 77;;
esac
out=$(cat <<EOF | @builddir@/grub-shell
diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in
index 8797f6632..1a57fb388 100644
--- a/tests/grub_cmd_sleep.in
+++ b/tests/grub_cmd_sleep.in
@@ -5,7 +5,7 @@ set -e
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
- exit 0
+ exit 77
fi
# Compare RTC with interval timer.
diff --git a/tests/hddboot_test.in b/tests/hddboot_test.in
index ded2cde7b..764e0da1c 100644
--- a/tests/hddboot_test.in
+++ b/tests/hddboot_test.in
@@ -22,13 +22,13 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
- exit 0;;
+ exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
- exit 0;;
+ exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=hd)
diff --git a/tests/netboot_test.in b/tests/netboot_test.in
index b274f3e2d..510c9c34b 100644
--- a/tests/netboot_test.in
+++ b/tests/netboot_test.in
@@ -22,22 +22,22 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
- exit 0;;
+ exit 77;;
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
- exit 0;;
+ exit 77;;
# FIXME: no rtl8139 support
i386-multiboot)
- exit 0;;
+ exit 77;;
# FIXME: We don't fully support netboot on ARC
*-arc)
- exit 0;;
+ exit 77;;
# FIXME: Many QEMU firmware have no netboot capability
*-efi | i386-ieee1275 | powerpc-ieee1275 | sparc64-ieee1275)
- exit 0;;
+ exit 77;;
esac
v=$(echo hello | "${grubshell}" --boot=net)
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
index c72618656..741ad881f 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -22,16 +22,16 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
- exit 0;;
+ exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
- exit 0;;
+ exit 77;;
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
- exit 0;;
+ exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
index 7906db43d..e72af9ce4 100644
--- a/tests/partmap_test.in
+++ b/tests/partmap_test.in
@@ -70,21 +70,21 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
powerpc-ieee1275)
disk=ieee1275//pci@80000000/mac-io@4/ata-3@20000/disk@0
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
- exit 0
+ exit 77
;;
sparc64-ieee1275)
disk=ieee1275//pci@1fe\,0/pci-ata@5/ide0@500/disk@0
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
- exit 0
+ exit 77
;;
i386-ieee1275)
disk=ieee1275/d
# FIXME: QEMU firmware has bugs which prevent it from accessing hard disk w/o recognised label.
- exit 0
+ exit 77
;;
mips-arc)
# FIXME: ARC firmware has bugs which prevent it from accessing hard disk w/o dvh disklabel.
- exit 0 ;;
+ exit 77 ;;
mipsel-arc)
disk=arc/scsi0/disk0/rdisk0
;;
diff --git a/tests/pata_test.in b/tests/pata_test.in
index a69719bf5..4fee0b0fb 100644
--- a/tests/pata_test.in
+++ b/tests/pata_test.in
@@ -25,13 +25,13 @@ indisk=ata0
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
- exit 0;;
+ exit 77;;
# PLATFORM: no ATA on ARC platforms (they use SCSI)
*-arc)
- exit 0;;
+ exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
- exit 0;;
+ exit 77;;
i386-ieee1275)
disk=hdb
indisk=ata1
diff --git a/tests/pseries_test.in b/tests/pseries_test.in
index 655eb4f3a..9b4090cf5 100644
--- a/tests/pseries_test.in
+++ b/tests/pseries_test.in
@@ -20,7 +20,7 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" != powerpc-ieee1275 ]; then
- exit 0
+ exit 77
fi
if [ "$(echo hello | "${grubshell}" --pseries --timeout=180 --boot=cd)" != "Hello World" ]; then
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index 7b8892c63..5aa5eb726 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -22,16 +22,16 @@ grubshell=@builddir@/grub-shell
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
- exit 0;;
+ exit 77;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
- exit 0;;
+ exit 77;;
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
- exit 0;;
+ exit 77;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
- exit 0;;
+ exit 77;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 9/9] tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
` (7 preceding siblings ...)
2021-10-13 0:40 ` [PATCH v4 8/9] tests: Exit with skipped exit code when test not performed Glenn Washburn
@ 2021-10-13 0:40 ` Glenn Washburn
8 siblings, 0 replies; 11+ messages in thread
From: Glenn Washburn @ 2021-10-13 0:40 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
This bring this test in line with the rest of the test scripts.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/f2fs_test.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/f2fs_test.in b/tests/f2fs_test.in
index 1ea77c826..8c415db61 100644
--- a/tests/f2fs_test.in
+++ b/tests/f2fs_test.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@BUILD_SHEBANG@
set -e
--
2.27.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command
2021-10-13 0:39 ` [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command Glenn Washburn
@ 2021-10-14 11:27 ` Daniel Kiper
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Kiper @ 2021-10-14 11:27 UTC (permalink / raw)
To: Glenn Washburn; +Cc: grub-devel
On Tue, Oct 12, 2021 at 07:39:58PM -0500, Glenn Washburn wrote:
> When using the output of a subshell as input, its error code is ignored in
> the context of "set -e". Many test scripts use grub-shell in a subshell with
> output used as an argument to the test command to test for expected output.
> Refactor these tests so that the subshell output goes to a shell variable,
> so that if the subshell errors the script will immediately exit with an
> error code.
>
> Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-10-14 11:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 0:39 [PATCH v4 0/9] Various fixes/improvements for tests Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 1/9] tests: Fix partmap_test for arm*-efi, disk numbering has changed Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 2/9] tests: When checking squashfs fstime, use superblock last modified time Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 3/9] tests: Add set -e to missing tests Glenn Washburn
2021-10-13 0:39 ` [PATCH v4 4/9] tests: Do not occlude subshell error codes when used as input to the test command Glenn Washburn
2021-10-14 11:27 ` Daniel Kiper
2021-10-13 0:39 ` [PATCH v4 5/9] tests: Do not occlude grub-shell return code Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 6/9] tests: Make setup errors in grub-fs-tester hard errors Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 7/9] tests: A failure of mktemp should cause the test script to exit with code 99 Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 8/9] tests: Exit with skipped exit code when test not performed Glenn Washburn
2021-10-13 0:40 ` [PATCH v4 9/9] tests: Use @BUILD_SHEBANG@ autoconf var instead of literal shell Glenn Washburn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.