Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1maSK7-0006AU-Vd for mharc-grub-devel@gnu.org; Tue, 12 Oct 2021 20:40:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maSJs-0005rt-Ml for grub-devel@gnu.org; Tue, 12 Oct 2021 20:40:36 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:39611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maSJl-0000RX-RE for grub-devel@gnu.org; Tue, 12 Oct 2021 20:40:32 -0400 Received: by mail-qt1-x830.google.com with SMTP id i1so1089784qtr.6 for ; Tue, 12 Oct 2021 17:40:25 -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=G4I4vjQzaqclGGuW4OvgsJxMU59OF7LItOq/2C8p/lU=; b=CWWUtqH7Tu7tiNX5uSMFg9vDKzw7N0cwb2/R1tvJq+c/PLR4KSfzUDqkPfoWtlWrxU usqxnwOu/qOLJm6O0dpKN0TRGBcr9llkymPtoDPee3LoJ+TioYgOIwja+yQlMcKGFfw6 86SwZqQ9Zm0h6LzCzpLKIrR1gnAhDX4smVAXYbVSIrRlNAnyImgurQmtNiC1A0LW8nSV b0qBtF4kwIVH21uW/vW0RjQM36c33BXI2uFkmXmEV9ZBUBZBJVEB1QYps8h1JOXeTxCf vAgJEfLQHarLwaWl3W/6DDNnUwCcLd3aCUTRoogvZXRa5lOP8QSdoHKoGkZX1Gef4E/b f28g== 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=G4I4vjQzaqclGGuW4OvgsJxMU59OF7LItOq/2C8p/lU=; b=TDZi2tfpKut7ccSSlx6veYmSDxu48uHf3yQGwvYedW2P0go4GMWn5o3uwrOdOIDM5U Zb5st4Qnzp53q0fBdorCGmPa9CR8KEfi+V0dYT7w27QPAkM32Wt/H/+6eeb/UzXIjCZ2 nXHvCN4ru84WqhDnVJWOARygaPj8z/dslf/IbSfOmtI0PYnb3bt1sWnS2/ljONQPw4Gz Js7MEMfiZnDATx12SOkItZt0GKxN4eJzsIcNPphoOx5dbwgcePN/sNNGJPjfG4lKPWca /iFVjHDmmpwjkdbl4cCh/36yCY36b8eu5ZWLFPILrqMoB6ojGUdfv1mASoQ20oEqmpqZ y44Q== X-Gm-Message-State: AOAM5316TsCQOBtbNE3Z0ENFgwDJno8xgJg9Td3l/lwmtaz7xF02n026 WpZLHRkoAXt6yBg3+LLmRXebpy9B7+TVHw== X-Google-Smtp-Source: ABdhPJwawGR09d0pEuqX26dS9Ec7M9Ah7NHOgCqgGy8uLEf8HVXEQk7A0jMJdws+VP3hKYHMIfKKhQ== X-Received: by 2002:ac8:5c89:: with SMTP id r9mr26179855qta.370.1634085624626; Tue, 12 Oct 2021 17:40:24 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id x18sm6682367qkx.94.2021.10.12.17.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 17:40:24 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v4 5/9] tests: Do not occlude grub-shell return code Date: Tue, 12 Oct 2021 19:39:59 -0500 Message-Id: <37097a173a4ef26001c3d9c6878849df14cf3969.1634084103.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=development@efficientek.com; helo=mail-qt1-x830.google.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) 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: Wed, 13 Oct 2021 00:40:36 -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 56760326a..7853bb8b6 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 c368c59ec..426bfa7db 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 45949fb4c..2b96539b8 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 7353dc70e..5f18ab51c 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 5a3b94c65..9a9492a43 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