From patchwork Thu Jun 16 22:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 1644645 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=HY4rUX6I; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LPHGg2znWz9sFk for ; Fri, 17 Jun 2022 08:41:47 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B4C3844C5; Fri, 17 Jun 2022 00:41:24 +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="HY4rUX6I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB60F84470; Fri, 17 Jun 2022 00:41:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 3829684481 for ; Fri, 17 Jun 2022 00:33: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-x334.google.com with SMTP id n185so1446319wmn.4 for ; Thu, 16 Jun 2022 15:33:52 -0700 (PDT) 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=vW0dTQzTTvLD8TpREfjxgkAier3QBBRzYQJ6vJVHUmM=; b=HY4rUX6IICW9BPfIiQHXPK5/PtJkhAF7W/wCM2Cfu9P3s1feKuGM1plPZjy0hyy87O f2vH7uhtB8r4W2sTTBrpYN50tWgVCE3RNq9QYpzI+/n3v/Pl8nxFA4GMO3XbW9yWTr8q mqoP5g7oCErn/j/ug0/4sw5/QbrwZml00cLIs= 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=vW0dTQzTTvLD8TpREfjxgkAier3QBBRzYQJ6vJVHUmM=; b=ViuSqQTcCt6jqU/bHZG7cMt2zwKQmUJuXtsQpKh1W3fdBL+YaVTTSYsDrbVbL6HyK4 wcTbiHQyGTzyuSt2n66AEZqdzIBedOcydbHidMwX2nLC5tLrDGMJ0Q+GjkslSkN+voN9 jNBK11P0t6Pts1aJpd9z9vN6zWVx1qDDCExImH7MmSEcILK5TtkydqKm885h/K6eHARa /BxrII4UHq54XumTy2/VeP0qLQQsMF56hsgkwzId6bYZAxEWo/NbN37QUgShwoesvNcL adQ7Pm6wDrXWFMlvzRlGuzkvSwywuHSgte02156y5F/yFMR8BcgC1avfWSvRuQIW/Ix+ 7V2w== X-Gm-Message-State: AOAM533NvMP3oPPgXCkg+NanNkzJ6iXOe9yNvsTteLC8HOtPvnEX8Sg9 /T4F+BGCLESSfa39jQvOcMMARsi2T48lrA== X-Google-Smtp-Source: ABdhPJx+OjaffbWeDYbIbGFpkYIEPigcdtdlyQhj/PxW5YuWwN5ZF8WDdjtgWFBE4PnmSbtkjbLOvA== X-Received: by 2002:a05:600c:1c9a:b0:39c:7db4:90c3 with SMTP id k26-20020a05600c1c9a00b0039c7db490c3mr17475502wms.161.1655418798840; Thu, 16 Jun 2022 15:33:18 -0700 (PDT) Received: from pwmachine.home (17.pool80-103-97.dynamic.orange.es. [80.103.97.17]) by smtp.gmail.com with ESMTPSA id n4-20020a05600c4f8400b003971fc23185sm7912044wmq.20.2022.06.16.15.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 15:33:18 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Tom Rini , Francis Laniel Subject: [RFC PATCH v4 21/28] test: hush: Fix if tests for hush 2021 Date: Fri, 17 Jun 2022 00:31:51 +0200 Message-Id: <20220616223158.9225-22-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220616223158.9225-1-francis.laniel@amarulasolutions.com> References: <20220616223158.9225-1-francis.laniel@amarulasolutions.com> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean Modifies the command run for hush 2021 when using string comparison operator. Indeed, '<' and '>' must be escaped to be used as these operators. Signed-off-by: Francis Laniel --- test/hush/if.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/hush/if.c b/test/hush/if.c index a57d88850f..f4aebc58b3 100644 --- a/test/hush/if.c +++ b/test/hush/if.c @@ -9,6 +9,7 @@ #include #include #include +#include /* * All tests will execute the following: @@ -35,10 +36,15 @@ static int hush_test_if_base(struct unit_test_state *uts) } HUSH_TEST(hush_test_if_base, 0); +DECLARE_GLOBAL_DATA_PTR; + static int hush_test_if_basic_operators(struct unit_test_state *uts) { char if_formatted[128]; + if (gd->flags & GD_FLG_HUSH_2021_PARSER) + console_record_reset_enable(); + sprintf(if_formatted, if_format, "test aaa = aaa"); ut_assertok(run_command(if_formatted, 0)); @@ -52,15 +58,54 @@ static int hush_test_if_basic_operators(struct unit_test_state *uts) ut_asserteq(1, run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test aaa < bbb"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + /* + * We need to escape < and > to use as them as string comparison + * operator. + * Otherwise, they are interpreted as redirection operators + * which is not supported in U-Boot. + */ + ut_asserteq(1, run_command(if_formatted, 0)); + /* Next lines contains error message (which is on two lines). */ + ut_assert_skipline(); + ut_assert_skipline(); + ut_assert_console_end(); + + sprintf(if_formatted, if_format, "test aaa \\< bbb"); + } ut_assertok(run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test bbb < aaa"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + ut_asserteq(1, run_command(if_formatted, 0)); + ut_assert_skipline(); + ut_assert_skipline(); + ut_assert_console_end(); + + sprintf(if_formatted, if_format, "test bbb \\< aaa"); + } ut_asserteq(1, run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test bbb > aaa"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + ut_asserteq(1, run_command(if_formatted, 0)); + ut_assert_skipline(); + ut_assert_skipline(); + ut_assert_console_end(); + + sprintf(if_formatted, if_format, "test bbb \\> aaa"); + } ut_assertok(run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test aaa > bbb"); + if (gd->flags & GD_FLG_HUSH_2021_PARSER) { + ut_asserteq(1, run_command(if_formatted, 0)); + ut_assert_skipline(); + ut_assert_skipline(); + ut_assert_console_end(); + + sprintf(if_formatted, if_format, "test aaa \\> bbb"); + } ut_asserteq(1, run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test 123 -eq 123");