tests: Do not occlude grub-shell return code

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, e.g. 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>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Glenn Washburn 2021-10-12 19:39:59 -05:00 committed by Daniel Kiper
parent 9bbcfb71ce
commit e024558d46
7 changed files with 14 additions and 12 deletions

View File

@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(ahci0)/$outfile';" | v=$(echo "nativedisk; source '(ahci0)/$outfile';" |
"${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none "${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none
-device ahci,id=ahci -device ahci,id=ahci
-device ide-hd,drive=disk,bus=ahci.0" | -device ide-hd,drive=disk,bus=ahci.0")
tail -n 1) v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then if [ "$v" != "Hello World" ]; then
rm "$imgfile" rm "$imgfile"
rm "$outfile" rm "$outfile"

View File

@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" | v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device ich9-usb-ehci1 "${grubshell}" --qemu-opts="-device ich9-usb-ehci1
-drive id=my_usb_disk,file=$imgfile,if=none -drive id=my_usb_disk,file=$imgfile,if=none
-device usb-storage,drive=my_usb_disk" | -device usb-storage,drive=my_usb_disk")
tail -n 1) v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then if [ "$v" != "Hello World" ]; then
rm "$imgfile" rm "$imgfile"
rm "$outfile" rm "$outfile"

View File

@ -9,7 +9,8 @@ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ];
fi fi
pdt="$(date -u +%s)" 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)" dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)" ndt="$(date -u +%s)"

View File

@ -17,7 +17,8 @@ set -e
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>. # 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` other=`echo insmod regexp\; echo \* | @builddir@/grub-shell`
for d in $disks; do for d in $disks; do
if echo "$d" |grep ',' >/dev/null; then if echo "$d" |grep ',' >/dev/null; then

View File

@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" | v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device pci-ohci "${grubshell}" --qemu-opts="-device pci-ohci
-drive id=my_usb_disk,file=$imgfile,if=none -drive id=my_usb_disk,file=$imgfile,if=none
-device usb-storage,drive=my_usb_disk" | -device usb-storage,drive=my_usb_disk")
tail -n 1) v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then if [ "$v" != "Hello World" ]; then
rm "$imgfile" rm "$imgfile"
rm "$outfile" rm "$outfile"

View File

@ -58,8 +58,8 @@ list_parts () {
shift shift
echo ls | "${grubshell}" --disk="${imgfile}" \ echo ls | "${grubshell}" --disk="${imgfile}" \
--modules=$mod | tr -d "\n\r" > "${outfile}" --modules=$mod > "${outfile}"
cat "${outfile}" cat "${outfile}" | tr -d "\n\r"
echo echo
} }

View File

@ -44,8 +44,8 @@ tar cf "$imgfile" "$outfile"
v=$(echo "nativedisk; source '(usb0)/$outfile';" | v=$(echo "nativedisk; source '(usb0)/$outfile';" |
"${grubshell}" --qemu-opts="-device ich9-usb-uhci1 "${grubshell}" --qemu-opts="-device ich9-usb-uhci1
-drive id=my_usb_disk,file=$imgfile,if=none -drive id=my_usb_disk,file=$imgfile,if=none
-device usb-storage,drive=my_usb_disk" | -device usb-storage,drive=my_usb_disk")
tail -n 1) v=$(echo "$v" | tail -n 1)
if [ "$v" != "Hello World" ]; then if [ "$v" != "Hello World" ]; then
rm "$imgfile" rm "$imgfile"
rm "$outfile" rm "$outfile"