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 5BE0AC433F5 for ; Fri, 31 Dec 2021 16:17:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 969518348F; Fri, 31 Dec 2021 17:15:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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="AEfiU5Ep"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E6F283782; Fri, 31 Dec 2021 17:15:36 +0100 (CET) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 4B5AA83740 for ; Fri, 31 Dec 2021 17:14:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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-x433.google.com with SMTP id k18so19943874wrg.11 for ; Fri, 31 Dec 2021 08:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YF8IkGBtIg+/Ew6DWhF/AjU4EKn6a02QuAeN/EqLBFw=; b=AEfiU5EpwqAbBzURU2gLBv2XGd4QMrdKvm564oKpaprIHJ6JrUJ+ZJe1AtJMm7eTeR pHKP6KQetVoaxtY6pttQ3m0GY9CW5Rjvm8ocQUbVVcFQ/HNqMwc/yS8JmFkGnPCvp7Mb qAR39j7jqgYAaumIKgmcKTaQGxokOSVKPuPfw= 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=YF8IkGBtIg+/Ew6DWhF/AjU4EKn6a02QuAeN/EqLBFw=; b=10xtv9VODgEtn2IW6MHjnuMzCMTx0cwrpC3alrxPtvPN5rrIuPK8tY1TW+RGJe4VMq g2QANTZfC6RGVN7U97NmnKM8gpULawJ3MkAnJpLigTt03McOxoqb23TknU9e2SNgbR7k 0K4wabkhdeD8lwUG/6pfP875ad1Kw8TeuLpZBC4vIesTFIEdVOMRoNcUd/SQyfzfok8t GrFct4G5WDTVmJZTzQO/sMcMcqohPVaECcDJSod6uYmzHuJzq6fgFrIIdfZipdsRarcg GTxWvhJJBJ2i9pkJj9yF0xvgLK2XL+TW96+JmReb2+qSPLsQ1sh/K1FpSLj3q+ezNgqw b3EQ== X-Gm-Message-State: AOAM530ckwa4a4Hy+GXq3ofdEc+isMJvfLZYDXbD/fIMzvo2f1Qpf+kk NRwCoc9Y6rPXP/ImzTfnI7vmlbKmltoGRA== X-Google-Smtp-Source: ABdhPJy+0hmZ9ST0fNUDD/OohqfkRAO+cDgpCHI9BqPXGJXjZWujnEMmrOxUAe397+XBJUn7Y9f84A== X-Received: by 2002:a05:6000:2a6:: with SMTP id l6mr29621931wry.76.1640967257910; Fri, 31 Dec 2021 08:14:17 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:eef7:8bf8:8ee0:cb1a]) by smtp.gmail.com with ESMTPSA id f6sm31855522wmq.6.2021.12.31.08.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:17 -0800 (PST) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Francis Laniel Subject: [RFC PATCH v1 21/21] test: hush: Fix loop tests for hush 2021. Date: Fri, 31 Dec 2021 17:13:27 +0100 Message-Id: <20211231161327.24918-22-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211231161327.24918-1-francis.laniel@amarulasolutions.com> References: <20211231161327.24918-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.38 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.2 at phobos.denx.de X-Virus-Status: Clean This commit 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/hush/loop.c b/test/hush/loop.c index 519c78ef7e..56aae719dc 100644 --- a/test/hush/loop.c +++ b/test/hush/loop.c @@ -20,7 +20,12 @@ static int hush_test_for(struct unit_test_state *uts) ut_assert_nextline("quux"); ut_assert_console_end(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* Reset local variable. */ + ut_assertok(run_command("loop_i=", 0)); +#else /* HUSH_OLD_PARSER */ puts("Beware: this test set local variable loop_i and it cannot be unset!"); +#endif /* HUSH_OLD_PARSER */ return 0; } @@ -30,12 +35,27 @@ static int hush_test_while(struct unit_test_state *uts) { console_record_reset_enable(); +#if CONFIG_IS_ENABLED(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 /* 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)); +#endif /* HUSH_OLD_PARSER */ ut_assert_nextline("bar"); ut_assert_console_end(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* Reset local variable. */ + ut_assertok(run_command("loop_foo=", 0)); +#else /* HUSH_OLD_PARSER */ puts("Beware: this test set local variable loop_foo and it cannot be unset!"); +#endif /* HUSH_OLD_PARSER */ return 0; } -- 2.25.1