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 2F8E8C4332F for ; Tue, 1 Nov 2022 19:23:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 12E068509B; Tue, 1 Nov 2022 20:22:39 +0100 (CET) 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="QOmCek79"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89D25850A1; Tue, 1 Nov 2022 20:22:07 +0100 (CET) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 668A68505E for ; Tue, 1 Nov 2022 20:21:35 +0100 (CET) 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-wr1-x430.google.com with SMTP id v1so21478604wrt.11 for ; Tue, 01 Nov 2022 12:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; 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=PFE4teAvEHnOBvtizQcpOAeOIN+jBuEe+EfNrAyD31E=; b=QOmCek79RSOQEIAHZ8ueDEW39BZccRE7OOyuX+dN6kjn4NlT0fiLURzDSaIiOVau90 fJNbIuC6REeFBKyPPBp++NBFz8qO+WqLksJ656WYsHNuMqjIy6+uzJ8Dv44W5EGU8rBF gAoRiQ++7NZ3ZUbj0HIA/ATfzGlGa3jV7RrDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PFE4teAvEHnOBvtizQcpOAeOIN+jBuEe+EfNrAyD31E=; b=QrQVjaaHLIhX5Q74gyuYc6uI4t+Kfsm3dybXj0leoo9EiK5Bk3duWoVXNgTxdn/4vG 8y+ycMM/WWZ5QYDsm++/k6bizCZ5wptpLoLL4qbifHDXuww7PDvQcIo3sOO8r46ZGWYA WSQoudledF46F0FovRZrXC5pS8iCeL5jgMqX3x8uHpzJ1IEwS5qMBExUCJwCM9xvqkCs F8XsVIGUYIrYlF6OwJCmN0AczcSW2/lnwRYRSZC2SgwT/l5OsW9PALJ4D8iaKfAZBf30 AE1AbDN7QdKpm4TJcuIhFMJN5Jmez6sn3mWKNpw0ZKamKGZoCZ6pghQXiM3a3QHVoXp8 +UCw== X-Gm-Message-State: ACrzQf0IeX3VqlZuvmr5MDjMFyNDlxa+dQH5hz89rAia2WR+d/AWKlxW 4t25btffDYHixv2mPYoxFn3R3luIZZQ78Q== X-Google-Smtp-Source: AMsMyM5zpdNCot2os+pMZ35rVvf0mZaH8QLz+yro3e/TBcajDAjHsio25+xVqljGr4R4OlTkj6CSpw== X-Received: by 2002:a5d:6589:0:b0:236:52af:3b70 with SMTP id q9-20020a5d6589000000b0023652af3b70mr12110430wru.349.1667330495233; Tue, 01 Nov 2022 12:21:35 -0700 (PDT) Received: from pwmachine.numericable.fr (85-170-25-210.rev.numericable.fr. [85.170.25.210]) by smtp.gmail.com with ESMTPSA id h17-20020a5d6e11000000b002356c051b9csm10755732wrz.66.2022.11.01.12.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 12:21:34 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: Michael Nazzareno Trimarchi , Tom Rini , Aleksandar Gerasimovski , Holger Brunck , Francis Laniel Subject: [RFC PATCH v5 22/24] test: hush: Fix loop tests for hush 2021 Date: Tue, 1 Nov 2022 20:20:27 +0100 Message-Id: <20221101192029.10231-23-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221101192029.10231-1-francis.laniel@amarulasolutions.com> References: <20221101192029.10231-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.6 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.25.1