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 1BE17C77B60 for ; Thu, 30 Mar 2023 19:56:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A07386149; Thu, 30 Mar 2023 21:54:42 +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="Srzp2i1f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1547B861AB; Thu, 30 Mar 2023 21:53:35 +0200 (CEST) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 7713F86119 for ; Thu, 30 Mar 2023 21:49:52 +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-x32a.google.com with SMTP id v6-20020a05600c470600b003f034269c96so2299262wmo.4 for ; Thu, 30 Mar 2023 12:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680205792; 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=AMZXjzy8kq5eue22Ud0DMob2IFrHvWDiPKVMiyVU1gk=; b=Srzp2i1fmy1iv58V1BUdyz3ODsz/cGB4F+Orzsu9aqWq0bbSIyzOensAQ5GitDkYlN oU8aGma4QCVODYHK6NzxD+HS++vIGWR4ilQOo8cwRn6XnAHAs/zPpt7kqgOUN/M4aiKi Qm6yPi0FXPgAKu6yh6ln9uL6Nr/u8xAeN6EzE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680205792; 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=AMZXjzy8kq5eue22Ud0DMob2IFrHvWDiPKVMiyVU1gk=; b=JzO1jqE5fyn4o61ZBeenND14c0S/YNw6nCsPFBzr+zBcs3JvmGcJUQaHs9/uN8fuEE 8g9bG3B/8t5QcEaTSH4ov7MEqs100y0Wj1e5sZMKUot4LlyeMi5ySthi+1kVXo8dhBJa JrXFK2xL6DJs+6YX7OwPvEkQ5FL86nYCm1Cz6b9t5kP5XORX1fsm9mAsXULy04eGTmas iRpnxj7amfA8igiqGxnDgMu16v+Mfno81M0OcWGKIT7qCrIGO9NQu2EKfybB3geLKfSn SLxaMqBvNUYFqEaosjiEZ9ke2/ojHDB0apm6Ipps3fh3HyQa8rL0efkv6uwc6dXluLPf mEeA== X-Gm-Message-State: AAQBX9eGUbSU92lnav8ypf0K9RU8VC5o7znPy5q1Idvvi4Ti12xr4Loh X43P2+O1/cR87dej07Qv/LP0Hz81yWA4lZMGB7Arpw== X-Google-Smtp-Source: AKy350Zr/OMAPhzc/XBpvwyOzi9jY02hXNLAIWF7luka5G06AxRKlxaaQGyXBCD7afKH27Ub1jVjZQ== X-Received: by 2002:a1c:7309:0:b0:3ef:5e4c:b015 with SMTP id d9-20020a1c7309000000b003ef5e4cb015mr16596977wmb.12.1680205791846; Thu, 30 Mar 2023 12:49:51 -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.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 12:49:51 -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 , Roger Knecht , Neil Armstrong , Sughosh Ganu , Linus Walleij , Alexey Romanov , Patrick Delaunay , Patrice Chotard , Fabrice Gasnier , Hector Palacios , Marek Vasut , Rasmus Villemoes , AKASHI Takahiro , Rui Miguel Silva , Andrew Scull Subject: [RFC PATCH v7 16/23] test: hush: Fix instructions list tests for hush 2021 Date: Thu, 30 Mar 2023 20:47:04 +0100 Message-Id: <20230330194716.23623-17-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 the expected result for hush 2021. Indeed, there were bugs in actual U-Boot hush which were fixed in upstream Busybox. As hush 2021 is based on upstream Busybox, these bugs no longer exist. Signed-off-by: Francis Laniel --- test/hush/list.c | 69 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/test/hush/list.c b/test/hush/list.c index 052cf2783c..6f8f10f15e 100644 --- a/test/hush/list.c +++ b/test/hush/list.c @@ -9,6 +9,7 @@ #include #include #include +#include static int hush_test_semicolon(struct unit_test_state *uts) { @@ -46,12 +47,43 @@ static int hush_test_or(struct unit_test_state *uts) } HUSH_TEST(hush_test_or, 0); +DECLARE_GLOBAL_DATA_PTR; + static int hush_test_and_or(struct unit_test_state *uts) { /* A && B || C truth table. */ ut_asserteq(1, run_command("false && false || false", 0)); - ut_asserteq(1, run_command("false && false || true", 0)); - ut_asserteq(1, run_command("false && true || true", 0)); + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_asserteq(1, run_command("false && false || true", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * This difference seems to come from a bug solved in Busybox + * hush. + * + * Indeed, the following expression can be seen like this: + * (false && false) || true + * So, (false && false) returns 1, the second false is not + * executed, and true is executed because of ||. + */ + ut_assertok(run_command("false && false || true", 0)); + } + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_asserteq(1, run_command("false && true || true", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * This difference seems to come from a bug solved in Busybox + * hush. + * + * Indeed, the following expression can be seen like this: + * (false && true) || true + * So, (false && true) returns 1, the true is not executed, and + * true is executed because of ||. + */ + ut_assertok(run_command("false && true || true", 0)); + } + ut_asserteq(1, run_command("false && true || false", 0)); ut_assertok(run_command("true && true || false", 0)); ut_asserteq(1, run_command("true && false || false", 0)); @@ -69,8 +101,37 @@ static int hush_test_or_and(struct unit_test_state *uts) ut_asserteq(1, run_command("false || false && true", 0)); ut_assertok(run_command("false || true && true", 0)); ut_asserteq(1, run_command("false || true && false", 0)); - ut_assertok(run_command("true || true && false", 0)); - ut_assertok(run_command("true || false && false", 0)); + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assertok(run_command("true || true && false", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * This difference seems to come from a bug solved in Busybox + * hush. + * + * Indeed, the following expression can be seen like this: + * (true || true) && false + * So, (true || true) returns 0, the second true is not + * executed, and then false is executed because of &&. + */ + ut_asserteq(1, run_command("true || true && false", 0)); + } + + if (gd->flags & GD_FLG_HUSH_OLD_PARSER) { + ut_assertok(run_command("true || false && false", 0)); + } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * This difference seems to come from a bug solved in Busybox + * hush. + * + * Indeed, the following expression can be seen like this: + * (true || false) && false + * So, (true || false) returns 0, the false is not executed, and + * then false is executed because of &&. + */ + ut_asserteq(1, run_command("true || false && false", 0)); + } + ut_assertok(run_command("true || false && true", 0)); ut_assertok(run_command("true || true && true", 0)); -- 2.34.1