From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mYa5g-0000gZ-GA for mharc-grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYa5e-0000bX-Pa for grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:06 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:46925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYa5c-0003Mx-IU for grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:06 -0400 Received: by mail-qk1-x734.google.com with SMTP id b65so7277538qkc.13 for ; Thu, 07 Oct 2021 13:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MeEIjV6wbu+MMr6dk27wQfKviIUJ0Dqxa39B4m8tacg=; b=eyC0Su/GbWtx8xvRUSjIcEgBKFzdMP3waTxN+Rnxki7+luJ3mKRxxnDjVDfK0zsE7f imbEP0Gl1g8ZpY1Jz0vOPyDUxLvzML3nXCsGLgdGKzDkZ+nnFG+gTG24r6iZWHiWbWyY DCAqaiG/L0hM8fseqB1VfE6dQgDiQZIb0/zHvI3K9No8zm22Pp5DBUCHLZYjDCZOawt0 0EVWJe1bAnLz+3Nd8N2wwMoSt8nLzeSV9+8RCn6ILFnLBLTR/LN7Q7RMnjwBN3ovVN/S t/E0AeZiXQiJH422G6W6ieY7iFEBJXWHptHQw7sOk5gkOlfL91TvLvgMqDM9OYAMnLQf T6sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MeEIjV6wbu+MMr6dk27wQfKviIUJ0Dqxa39B4m8tacg=; b=iV+/ySBwmMsmHVZevt4BnfTxBLvuQExj+1N6nFcbHvefqgFWIMoMlrp7MVL9SVfUM4 eEan6iRs0FxljFPCGLk+PzQnoEz/35oszvHBaDD81zZBvAZxifYhEW4OeJlq6C0S+Oht OHHHmte7KUapSul64ooeIXOOetLyZ/yYkNYTAapPAadhh5QQK+K8ITY5IZwf+/ToGBGq EiczoIl3z66Pxu+8lCj7VOg/mfj/08bz3Bz8k028Fa1n3Yd2gtjQegt8TdHehmyLl2iP 0fmPW9IuMst21s4MwfamyT/UrCnEzTGeztmNBKF13kYcWiF4AHBb2m6G6/BUIvhZm8+u XiPQ== X-Gm-Message-State: AOAM533lTvr+h/SZaHt+3kxzsi+o5u3ZStpK3tFNRpE9JX8gnX+YhlgN kzjHebvEMYlzKnPO/r1aiV90Z+Cu2uZrEg== X-Google-Smtp-Source: ABdhPJx2t8XjYMVTUubllN16at9ZFVNJUbhVIf395thHf6JJYs2Iw+YUTBWo4y+T1AZBhcg4z5Lbsg== X-Received: by 2002:ae9:d61c:: with SMTP id r28mr5214960qkk.122.1633638843442; Thu, 07 Oct 2021 13:34:03 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id p187sm374106qkd.101.2021.10.07.13.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 13:34:03 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v3 2/4] tests: Do not occlude subshell error codes Date: Thu, 7 Oct 2021 15:33:25 -0500 Message-Id: <20211007203327.159098-3-development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211007203327.159098-1-development@efficientek.com> References: <20211007203327.159098-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=development@efficientek.com; helo=mail-qk1-x734.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2021 20:34:07 -0000 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. Signed-off-by: Glenn Washburn --- 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 9b1d85df4..1e4e3e443 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..7229f79fb 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..90dd00607 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 b20c09f0f..115e64e29 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..1bbe60ee5 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..572b2a1a5 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..abe3e0ae1 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..8f08a8046 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..6a1d95a22 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 8226e64ae..9b9a853d6 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 0dadbf5d3..0db4778d7 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 cc8b1a1fe..11689d23c 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..61acba33b 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