Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oMBet-0005rJ-I9 for mharc-grub-devel@gnu.org; Thu, 11 Aug 2022 13:07:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMBej-0005oO-0B for grub-devel@gnu.org; Thu, 11 Aug 2022 13:07:41 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:39701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oMBeg-00080Z-Sb for grub-devel@gnu.org; Thu, 11 Aug 2022 13:07:36 -0400 Received: by mail-qk1-x732.google.com with SMTP id t11so3180648qkt.6 for ; Thu, 11 Aug 2022 10:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=Ufcgq+wY3a2g4zhz+c6akjiL+Y1q+ldJN2hAOXej118=; b=WUnvgVSGYdImKeTbnxMnYFW7JFoShsHQSUnWFu6ZPfge7bGRq0YRDUi9qzT+yZOs2H b+VD2RjPKciEDEdxkbu8Zd4ir6TbORzwumG+B7HyqMcHYIwXCVeHLzYOiJMspGXLHllF GD7KZEeyPjayPZi6S7Qkowuy9gX2ALVI326vUfwE5DMq4lnviQLNwEqB6RWvarpd2RS0 XIcwafMhOefk06oEjJJcx86Mzdgk/RWTS8e0gwtP8UfuR3Ru2ovw/UjnbnoSi+7VRFuj ma39YJNvB9w/9r+tbZiXUIZ5pf6ImOxaI+9OcvBsxTQQQOXzyrW9VqGGmZZbv9YUBcM7 YjXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=Ufcgq+wY3a2g4zhz+c6akjiL+Y1q+ldJN2hAOXej118=; b=1MLbvMOA2hk7dn7bfF5cFURV+RoK1o0qPnk4GoudX/Mm02VFIfHl5+Z1+HBetEnk7o mqV93ld0tt9OWrppNK5HI2NfMMFzpKLDMg6lN2o8J7h/tqmovYanwgf/kMadml5Laf8r JYMYldi1d1RGrQEecg04NrDK3xE+lZePnyGwACfdNGIygA1stLk+uCX9nhRxhcr0E44A x/6dUKMtAt4GCqP0aJjzcL8T+d9HkavXOhM9jU2aFQtafluG/EJxqE4wOWGb5OnfAMtb 6vsrQV1VqJwqLsyGzdaBH4lTkpseMThkXyappkt+10XX/O6wvtEehuIFWjzkzSPYJ7Rq BpbA== X-Gm-Message-State: ACgBeo0k1tdnMCoySYoX7WkPuVduKTiP93G9EYkJFIuRRQecUYRIymtC 9Jx7dmwCld/+RJYdV6aCFeOsmoCp2t6WdwEb X-Google-Smtp-Source: AA6agR76XuNZlS4BqVjf51L5fbhMV3ynZbzIvSf3FvH7voNxUOsRp5y96jxEZswnTRJfWd6pqUuHbA== X-Received: by 2002:a05:620a:112b:b0:6b9:59f3:16a3 with SMTP id p11-20020a05620a112b00b006b959f316a3mr12471720qkk.215.1660237652768; Thu, 11 Aug 2022 10:07:32 -0700 (PDT) Received: from localhost.localdomain ([199.58.83.12]) by smtp.gmail.com with ESMTPSA id f6-20020a05620a280600b006b99b78751csm784596qkp.112.2022.08.11.10.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 10:07:32 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH] grub-shell: Only show grub-mkrescue output if it returns an error Date: Thu, 11 Aug 2022 12:06:43 -0500 Message-Id: <20220811170643.1985898-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=development@efficientek.com; helo=mail-qk1-x732.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: Thu, 11 Aug 2022 17:07:44 -0000 The previous behavior ignored an error and the output from grub-mkrescue. This made it difficult 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 bb7b285e9..ce431757c 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -59,6 +59,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 @@ -384,13 +395,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.34.1