From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <daniel.kiper@oracle.com>
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH v3 3/4] tests: Do not occlude grub-shell return code
Date: Thu, 7 Oct 2021 15:33:26 -0500 [thread overview]
Message-ID: <20211007203327.159098-4-development@efficientek.com> (raw)
In-Reply-To: <20211007203327.159098-1-development@efficientek.com>
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 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
next prev parent reply other threads:[~2021-10-07 20:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 20:33 [PATCH v3 0/4] Various fixes/improvements for tests Glenn Washburn
2021-10-07 20:33 ` [PATCH v3 1/4] tests: Add set -e to missing tests Glenn Washburn
2021-10-11 14:04 ` Daniel Kiper
2021-10-07 20:33 ` [PATCH v3 2/4] tests: Do not occlude subshell error codes Glenn Washburn
2021-10-11 14:20 ` Daniel Kiper
2021-10-11 18:06 ` Glenn Washburn
2021-10-12 19:40 ` Daniel Kiper
2021-10-13 0:39 ` Glenn Washburn
2021-10-07 20:33 ` Glenn Washburn [this message]
2021-10-11 14:31 ` [PATCH v3 3/4] tests: Do not occlude grub-shell return code Daniel Kiper
2021-10-07 20:33 ` [PATCH v3 4/4] tests: Exit with skipped exit code when test not performed Glenn Washburn
2021-10-11 14:34 ` Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211007203327.159098-4-development@efficientek.com \
--to=development@efficientek.com \
--cc=daniel.kiper@oracle.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.