From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mYa5i-0000kw-99 for mharc-grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYa5f-0000er-WD for grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:08 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:43937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYa5e-0003UP-11 for grub-devel@gnu.org; Thu, 07 Oct 2021 16:34:07 -0400 Received: by mail-qt1-x82b.google.com with SMTP id r17so2219855qtx.10 for ; Thu, 07 Oct 2021 13:34:05 -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=LX6LK9LJh900O2np1/fCIHz/oszyn00Bh9VAgtrrU4E=; b=YRZChyc8HHY/s1NkZcSUUPa5VUWq38r7vf39dLHSnPcA6B7DB46S5Op1iLts04d+az sODIn/IVMZvbUDfYMB93RbUyvRUBWvipHVW2rmib8t8MTEOs1vo41j2r81jlP+PHSM3E YaNXT0lQ+LqlPWnCiudXWkjpUW71ZXjfkb9oYLSAf/QaFTmWy1Vi2NrgyuSeayDNz8EE GqQdfFBmZh87IcPCmlmXamEoxvR+5Fu9jjybCwGVo7bnXF+L5lz2SuuKp2C658KFcxu8 PVqUot3qk8qWea24H7zcA7q9d/80GlPZfVNUgQeeUmIwdZmb7kID+YTTiW3tpRsuCNtq qEjQ== 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=LX6LK9LJh900O2np1/fCIHz/oszyn00Bh9VAgtrrU4E=; b=yKGI0dhto8UPN2oWwWZfNiFGbS2BJr7DD0r2m6A3eoaUt/s7FwxzSC475+WibyTwG/ bmDEkafTQtaos72FDzhdVZan0YqzmPinkr9w59Pzv+wY+QcxRijeStsTkg3fh380A7IW UH/12xP7PCIoe9xZf68YnKVBBKhDJCLLicrb9pk41JHHi6VJ+VKFp7Lmcj0bYsjoCkkK +gQYk27wXNOsHcRagrKBKYD6Mk0Ds+PwBEvGnJ5XvqKrwmaAu3qEeXdRomNiO8ZPj0K9 DUGAxIXerns38ElDjCbOd4JnL9s1r+KFlPcOdNrukuAuuIz3C6fW9c7utzw3//GIUhoD a6Qg== X-Gm-Message-State: AOAM533ffQPXDr0P5LBThup9E2fluDzxlmPE47IDkYLCcYbVRenS7iUw CQYf3sVNDlsS/ltNQl7ABeeKbweNMmoOxQ== X-Google-Smtp-Source: ABdhPJzleXypyPM6dMg+JuAf85s35wYwYU0YlCrf6Gt4PpBykw+LcM5n+d48Dz0LBt8yztffoo8/gQ== X-Received: by 2002:ac8:614b:: with SMTP id d11mr7403913qtm.396.1633638844906; Thu, 07 Oct 2021 13:34:04 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id p187sm374106qkd.101.2021.10.07.13.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 13:34:04 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v3 3/4] tests: Do not occlude grub-shell return code Date: Thu, 7 Oct 2021 15:33:26 -0500 Message-Id: <20211007203327.159098-4-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::82b; envelope-from=development@efficientek.com; helo=mail-qt1-x82b.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:08 -0000 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 --- 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 . -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