Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nIHMv-0002V0-Ez for mharc-grub-devel@gnu.org; Thu, 10 Feb 2022 16:52:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIHMt-0002Q8-HS for grub-devel@gnu.org; Thu, 10 Feb 2022 16:52:47 -0500 Received: from [2607:f8b0:4864:20::732] (port=40507 helo=mail-qk1-x732.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIHMp-0008DP-Ts for grub-devel@gnu.org; Thu, 10 Feb 2022 16:52:45 -0500 Received: by mail-qk1-x732.google.com with SMTP id o25so6352821qkj.7 for ; Thu, 10 Feb 2022 13:52:43 -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=J0ofUkDGengPMTvt1awkS0cbVQhp6wBu4s546BvmJ7KhageQiYKFIxYZtEr+H5lgdN 2S0FRDMKitI3fUw1ufcawR1GdwJWL2xjr+PHK0NRkLNqH51krnV4le0DBz31g+1AC7ar 1FOWNEpWOn0SWdOa2vMMCjuXH3NTJ3xJABvITy2mjOv1Mrw028konBfAIxOKz8bx15Ku boOdQ08Q4RHhuA2oDy9+/FcRhP6vmYtXAp6lLrc5zgcOrjlREK1cVS5/CF97jPlteA0E ziurFj9PPd0Pus/lR9/BFisDmVgvBky2OizyvIunw4FGQeBOfQ1AucuL5TwpJFxHjuGW icgw== 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=ZOLDJVaxzBA/11J9Td80SzrItb0kEHaNEIWNyCUoWsVXqZGLzZ4Iimmouqbsotn+6E hjd3KnjniNRlBuy99vdi9M/OxegCjVipmC79mGeDb/cU2aozwLZxPq3a26O+EftHUhsK ihLpmXh6M97eJsmJcOIfdfwDcIkRHkDg53uqwl7IZOgjs5z8zdMAZnwl17WDYjDeBbDE I/5Nuh3X68bOmLhBtTWV6Kl4ASIlsOAMakXL4fRhOvl21v/JgRW0y1PdMiwzu45ho6V0 J0OwIS9RjpGVqpo7g1SXJLQsm+lGmmRSSDb5bEWjEQJXW2fcXeWzZGMd1B26t5OcIHCg hqVQ== X-Gm-Message-State: AOAM530H2riV5AuiXGqZArSEyG1JsO8D0Lhs8ej73D9XBgypGYIUg5sJ KScgCzOzmBuxleF4AeOs7gdSLLpOgsrRjA== X-Google-Smtp-Source: ABdhPJxFrE5rYMxVFSsBeroedSuAPsO9d6fl2CUOnAMdELHiFNUCncuyZBx67G/nY2XfQ/MY87FnMA== X-Received: by 2002:a05:620a:470a:: with SMTP id bs10mr4873109qkb.583.1644529963148; Thu, 10 Feb 2022 13:52:43 -0800 (PST) Received: from localhost.localdomain (garza.riseup.net. [198.252.153.109]) by smtp.gmail.com with ESMTPSA id j15sm11740363qta.83.2022.02.10.13.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 13:52:42 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Glenn Washburn Subject: [PATCH v3 03/15] grub-shell: Only show grub-mkrescue output if it returns an error Date: Thu, 10 Feb 2022 15:51:20 -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::732 (failed) 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: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: Thu, 10 Feb 2022 21:52:47 -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