From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48EDBC7619A for ; Thu, 30 Mar 2023 20:02:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B0BD985F6B; Thu, 30 Mar 2023 22:02:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="hCVzxZtz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E439A85E44; Thu, 30 Mar 2023 22:02:30 +0200 (CEST) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 159FF86162 for ; Thu, 30 Mar 2023 21:50:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francis.laniel@amarulasolutions.com Received: by mail-wm1-x336.google.com with SMTP id m8so712643wmq.5 for ; Thu, 30 Mar 2023 12:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680205831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OmA8NjiOW3hh2srdF9PHLWXpt44tfpDzSNyBDkPbdVg=; b=hCVzxZtzkDXI7iGJHJNgQ6elsAiDmg7HcF72lac5++46SfXy/WVVXH/MYyBjVMaIiV rDrXkChie9+r6B7kf6b0ujo9wy4PRg5LUtDqUDZkbaXeX4Q3ghRcBBKMZgxXGkfrznKT JxD8jfDxoo5nx5Bk4DZWaX1XbTKLqytgfnIKI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680205831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OmA8NjiOW3hh2srdF9PHLWXpt44tfpDzSNyBDkPbdVg=; b=GQkF7TxzqssoctMqvQvPuQm2cl1m7qjjt/DqTYwrD7aDvEdi4f1zOCgNWeTehkpugB AGh6kx+2+uGwFukNB6hqpFvLQeOyVbCCblMK8S7m0+ww2jDI/cb+Kuzrf09lZC2pF57c 2wNQnXcCNl8NVg64PNqjGjFH3s/pwSfoEzQ1aCkoijzuxf+2UmxhCx7xitn3e2ZsJpQZ c4cgm86AGHI4xfZQZfGoneq3zBRt9fLq0mMgUkjBmO2YsrhhN+yFTcyQttZ58rP/tpn0 RPgXjl4VHNjwyh3KnBwRlH5h8ayCpxF7OIp6YxhIuSsrJHmiGqJAKdFVR/r085Xh/NKU ugiQ== X-Gm-Message-State: AO0yUKVVQUHRwoXBB2hgOHnacr6RXjFT/pJqFQXXdDwbQA2glAdPFT5W 0PLhoxrne7gBu7fXmsQRDqUcbfb85XuD+2l46e14iw== X-Google-Smtp-Source: AK7set+VV4xGkOf5M4ET0v+EGmfUf+gXZTCbe6fVOWbp6tHtZZs+mxVaN0DEuWdonPhrYnTft0FkRg== X-Received: by 2002:a7b:c851:0:b0:3ed:c468:ab11 with SMTP id c17-20020a7bc851000000b003edc468ab11mr18379896wml.28.1680205831715; Thu, 30 Mar 2023 12:50:31 -0700 (PDT) Received: from pwmachine.numericable.fr ([78.30.11.60]) by smtp.gmail.com with ESMTPSA id l24-20020a1c7918000000b003e203681b26sm203762wme.29.2023.03.30.12.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 12:50:31 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: Michael Nazzareno Trimarchi , Tom Rini , Simon Glass , Harald Seiler , Francis Laniel , "Albert ARIBAUD (3ADEV)" , Tony Dinh , Sergei Antonov , Ilias Apalodimas , Heinrich Schuchardt , Masahisa Kojima , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Stefan Roese , John Keeping , Neil Armstrong , Roger Knecht , Linus Walleij , Alexey Romanov , Patrick Delaunay , Fabrice Gasnier , Patrice Chotard , Hector Palacios , Marek Vasut , Rasmus Villemoes , AKASHI Takahiro , Rui Miguel Silva , Andrew Scull Subject: [RFC PATCH v7 21/23] test: hush: Fix loop tests for hush 2021 Date: Thu, 30 Mar 2023 20:47:09 +0100 Message-Id: <20230330194716.23623-22-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330194716.23623-1-francis.laniel@amarulasolutions.com> References: <20230330194716.23623-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Modifies return code got from while loop as hush 2021 always returns 0 from while loop. Signed-off-by: Francis Laniel --- test/hush/loop.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/test/hush/loop.c b/test/hush/loop.c index ca777e38fe..add5402a32 100644 --- a/test/hush/loop.c +++ b/test/hush/loop.c @@ -9,6 +9,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; static int hush_test_for(struct unit_test_state *uts) { @@ -21,7 +24,12 @@ static int hush_test_for(struct unit_test_state *uts) ut_assert_nextline("quux"); ut_assert_console_end(); - puts("Beware: this test set local variable loop_i and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("loop_i=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable loop_i and it cannot be unset!"); + } return 0; } @@ -31,12 +39,30 @@ static int hush_test_while(struct unit_test_state *uts) { console_record_reset_enable(); - /* Exit status is that of test, so 1 since test is false to quit the loop. */ - ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * Hush 2021 always returns 0 from while loop... + * You can see code snippet near this line to have a better + * understanding: + * debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n"); + */ + ut_assertok(run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + /* + * Exit status is that of test, so 1 since test is false to quit + * the loop. + */ + ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; loop_foo=quux; done", 0)); + } ut_assert_nextline("bar"); ut_assert_console_end(); - puts("Beware: this test set local variable loop_foo and it cannot be unset!"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* Reset local variable. */ + ut_assertok(run_command("loop_foo=", 0)); + } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + puts("Beware: this test set local variable loop_foo and it cannot be unset!"); + } return 0; } -- 2.34.1