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 5533AC4332F for ; Tue, 1 Nov 2022 19:24:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EFE7C8506A; Tue, 1 Nov 2022 20:22:46 +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="qdzl2xt9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97FAF85002; Tue, 1 Nov 2022 20:22:05 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 E8A10850A7 for ; Tue, 1 Nov 2022 20:21:41 +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-wm1-x32b.google.com with SMTP id p16so3857624wmc.3 for ; Tue, 01 Nov 2022 12:21:41 -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=vW0dTQzTTvLD8TpREfjxgkAier3QBBRzYQJ6vJVHUmM=; b=qdzl2xt9vvRWK33pOswR9aix1h2hk6scPx3ZR7X9DdXSQVgdoBrNi8X7o95KGTxZLo EFGiKKrvH5vYvfCcBmAguB0KWHLPlwEthOa8qv/z6zGJzX/dnt9RNzwhZJLf7Fx9WnmU nF+WzrzKZVsDvijkqau8ky6HfbkBKPtVP8zwM= 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=vW0dTQzTTvLD8TpREfjxgkAier3QBBRzYQJ6vJVHUmM=; b=QuaXAiHRMVi4sd6QhTlAesWx7h58lNzeD3XfZoa1SEt5VVDO/VgvYSYEAKJvExA+Nx F5owxzUMDBMtUjVQI5cA62zNrdIR+j1tyF5B9iXhhKTKeWOMJLk/kryX2uAkNcwAaVdV x4mFiR1XsaSWq01fdkUGh2PaqlTYBZImxgKbg5xse72izuC2U8iMiOUXSfEPwdJJq/q8 rFtoOh5Kiuj72Dj5JOsHrjL97HepBMog34+G0CzvUR3oC829CIbpD+DKVjFXI2OP8X4v UzMUd/zI1bDMMP0QWYDMXM1hv+3woNeXd4l0ywC3oorVxLD3HpJQncFlwRmb44iMLunH u02Q== X-Gm-Message-State: ACrzQf2+4FauUkD3z0aAkCykObAaAtbVqAdPrl47BsxmiX+SnFcnf7t/ T0RbmdcutvGl6VCuXVj8Ng6Jr6OrVEwXZQ== X-Google-Smtp-Source: AMsMyM57eQgsxSzXdXOu5vNR0dYVFmAXL8equcOM+X6BTBctO3kly6T4koH/7L1+Qoe3SVrbhHpIGg== X-Received: by 2002:a7b:ce89:0:b0:3cf:72d9:1033 with SMTP id q9-20020a7bce89000000b003cf72d91033mr7348232wmj.17.1667330492287; Tue, 01 Nov 2022 12:21:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 12:21:32 -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 20/24] test: hush: Fix if tests for hush 2021 Date: Tue, 1 Nov 2022 20:20:25 +0100 Message-Id: <20221101192029.10231-21-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 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"); -- 2.25.1