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 <developm...@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 1e4e3e443..3f7645ad8 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 115e64e29..df408d77a 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 9b9a853d6..c72618656 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 cf82b4f98..7906db43d 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 11689d23c..7b8892c63 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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel