Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n3s9p-0007s7-Sp for mharc-grub-devel@gnu.org; Sat, 01 Jan 2022 23:07:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3s9n-0007mK-UB for grub-devel@gnu.org; Sat, 01 Jan 2022 23:07:43 -0500 Received: from [2607:f8b0:4864:20::f30] (port=39844 helo=mail-qv1-xf30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n3s9m-0002CN-D4 for grub-devel@gnu.org; Sat, 01 Jan 2022 23:07:43 -0500 Received: by mail-qv1-xf30.google.com with SMTP id p12so3896556qvj.6 for ; Sat, 01 Jan 2022 20:07:42 -0800 (PST) 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=T6zrogphfmIDzIdQqdRE3fP5VoIixFIOuvuOhxpAzeQ=; b=VAvcxoFM+Ol3+5gakPCCSaTL/EycOMu12gskGaqInDqDs9NhoyQjaEX6bWJpVzyJRG p4ZWcg7LzEnux5tmExR32dHCNgJf7PGyZLohRlRi0Nz5/ySENp24ac607WiQkQxGiXpg swQ972WbEWpojKY4dMo4goM0YBmBPEWc3FW/x7pC8Qp3WghR+g49Es9LsIFm1dPinAmK xlWMhBmUfI3r+pPQhiM6Td2n3h/dpVBqOPeBMkgcG7xnYApmsMhnnv/FcfMW9VKBYSs1 FDzIzepV/kn5X/3tXR6+pTrTKCfzGTXfCCtOmK1va2oSMUhEnH872IAiHejtCazYsXRS TriA== 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=T6zrogphfmIDzIdQqdRE3fP5VoIixFIOuvuOhxpAzeQ=; b=GcFhTUrzlz4D5K9zbpoBm5Rw9LmDilReM1Gm+8Ch29W3rtW1rSDuszUMulfqYrUMBC PlsBAbx9OcA8RxK00bD89mJc4WhjHvj4iXp8JFTgnn5zrL5fUelElvep9HfxpAXAk3OA WU/QDQHYqWK84uFiVST/t8EEPGEH2klCuBGEGmSAbEBZyA2OMR7ITvG+JmHZL0beCn3k pZZiWiLTDsKXpsLuGiKt5airZZXVU+IiCj6B5PR+sddIgCrLU4HIe9Dr0/0wDDFO76Mz BlzEks7C/RGaZPtQqfAFvjO2a6yNN14dS02dyHb+ujwqxdemWgW+aZl50+XksbAD9lNu IHWA== X-Gm-Message-State: AOAM530jbDEO+cWbAFPwB/v+wctGu9hCO8xshqk+KYlnzPGmDctXyDB1 0o4PjQO8ycknlIzseir5Vj1Peg== X-Google-Smtp-Source: ABdhPJxy36V1y+7u8Sdqo5r24fwEZmysH2/dwWUSlm4U6Mbm1VoJrLA7rxsMSMffatMko82VmDNJqA== X-Received: by 2002:a05:6214:c2d:: with SMTP id a13mr37309436qvd.77.1641096461599; Sat, 01 Jan 2022 20:07:41 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id 137sm22660725qkm.69.2022.01.01.20.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jan 2022 20:07:41 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Glenn Washburn Subject: [PATCH v2 03/12] grub-shell: Only show grub-mkrescue output if it returns an error Date: Sat, 1 Jan 2022 22:07:13 -0600 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f30 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=development@efficientek.com; helo=mail-qv1-xf30.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jan 2022 04:07:44 -0000 The previous behavior ignored an error and the output from grub-mkrescue. This made it a pain to discover that grub-mkrescue was the reason that tests which rely on grub-shell were failing. Even after discovering grub-mkrescue was the culprit, there was no output to indicate why it was failing. It turns out that grub-mkrescue is a thin wrapper around xorriso. So if you do not have xorriso installed it will fail with an error message about not being able to find xorriso. This change will allow grub-mkrescue output to be written to stderr, only if grub-mkrescue fails. If grub-mkrescue succeeds, there will be no output from grub-mkrescue so as not to interfere with the functioning of tests. This change should have no effect on the running of tests or other uses of grub-shell as it only modifies the error path. Also, if grub-mkrescue fails, the script exits early. Since grub-shell needs the iso image created by grub-mkresue to boot the qemu instance, a failure here should be considered fatal. Signed-off-by: Glenn Washburn --- tests/util/grub-shell.in | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 602b16f3e..9d8c417da 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -60,6 +60,17 @@ Report bugs to . EOF } +# Exec given argv and only show its output on STDERR if it returns an +# error status. +exec_show_error () { + v=`$@ 2>&1` + ret=$? + if [ "$ret" != 0 ]; then + echo "$v" >&2 + exit $ret + fi +} + . "${builddir}/grub-core/modinfo.sh" qemuopts="${GRUB_QEMU_OPTS}" serial_port=com0 @@ -383,13 +394,15 @@ if test -z "$debug"; then fi if [ x$boot != xnet ] && [ x$boot != xemu ]; then - pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \ + pkgdatadir="@builddir@" \ + exec_show_error "@builddir@/grub-mkrescue" "--output=${isofile}" \ + "--override-directory=${builddir}/grub-core" \ --rom-directory="${rom_directory}" \ --locale-directory="@srcdir@/po" \ --themes-directory="@srcdir@/themes" \ $mkimage_extra_arg ${mkrescue_args} \ "/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \ - ${files} >/dev/null 2>&1 + ${files} || exit $? fi if [ x$boot = xhd ]; then if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then -- 2.27.0