Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lRmbM-0006xK-Cm for mharc-grub-devel@gnu.org; Wed, 31 Mar 2021 21:58:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRmbD-0006hT-Fj for grub-devel@gnu.org; Wed, 31 Mar 2021 21:58:19 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:40609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRmb0-0007Hm-Kx for grub-devel@gnu.org; Wed, 31 Mar 2021 21:58:17 -0400 Received: by mail-ot1-x335.google.com with SMTP id w31-20020a9d36220000b02901f2cbfc9743so740200otb.7 for ; Wed, 31 Mar 2021 18:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T6zrogphfmIDzIdQqdRE3fP5VoIixFIOuvuOhxpAzeQ=; b=tm3PZcWSGIvb5Puz5j5aKToMT/gvpVjDwbgAVtXAbX6wJDx7rpm1C4bdVlxDJHd016 igGBfUAXyw++/7M/hbFpjYjCGr7KQ4ztA18fwDPEzlBevHdS6Ef/j8pJr9LPf8Nefnt7 BAglabrrg3eg/d6OhOizip9VzbKYGaOKMc65eyi86I1AGz2dKoN3nRooll2r2clHXQnV IAmtdx4BzzmjW03JSACAOf92ntiwnDrniXmpncFRgrXWxcFX2N3NmFEpiGAda8QY4oPa x/87QnxLhjS4ik1FG/SuXf1ywN2x73cWyv9Dac7bf2TT3tJ21wh9bOzeZXH0DkXsvK83 GRmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T6zrogphfmIDzIdQqdRE3fP5VoIixFIOuvuOhxpAzeQ=; b=ohjB5tn8wwM71a/BXCJNnu5GNtaxtd2LxaFEfncAcDOONVWGI2bJWKisxQlP5vMOQ4 Oe6HtVEaZcpEX1oJ+H+yknpcZkAplPEQfABJ9T2nn/JMjP9uL8SmvJADIA5sUKbDBvKD nNfpiKkzMfaJfAg7JOPzPSZxDx3MReniiYfxf+ku6LeLBB4PnODb3x6w34SarxvIUmAZ GQMipN8aLILTrlw62W/xeOr4XAVaj2fxE8vU7OP2sKPSBNYmnGDWd/QepfNN02CzTEKk ccmiCGa5iEvyva8eNnMaPdYdfXnCMzO2yadAdmReewVx4zbXjWm+QlQIg+Ru8L6kEgjd NylQ== X-Gm-Message-State: AOAM530hYdF+AWYhUn08OAhkxU4CwtQuCCl12YzdY5Hxmt3bVNqzpcUl bgRY+0LobqriUymU+QUtc+F9z5mAevcIoQ== X-Google-Smtp-Source: ABdhPJwWRuVOGNCtEQJdy6T5fKkIEWRoi9eCqJy+dbbpClkMIP8U96xm5gPY/mNIYWcV8mu4LnUhQQ== X-Received: by 2002:a9d:354:: with SMTP id 78mr4954737otv.123.1617242284842; Wed, 31 Mar 2021 18:58:04 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ab16:db00:1cb0:2038:b70a:65b5]) by smtp.gmail.com with ESMTPSA id z25sm902960otj.68.2021.03.31.18.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 18:58:04 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH 03/12] grub-shell: Only show grub-mkrescue output if it returns an error Date: Wed, 31 Mar 2021 20:57:42 -0500 Message-Id: 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::335; envelope-from=development@efficientek.com; helo=mail-ot1-x335.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=unavailable 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, 01 Apr 2021 01:58:19 -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