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 C8531C433EF for ; Sun, 6 Feb 2022 18:41:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B20A283BDB; Sun, 6 Feb 2022 19:38:50 +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="C4EI01c1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E12F083BD7; Sun, 6 Feb 2022 19:38:46 +0100 (CET) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 8755783C22 for ; Sun, 6 Feb 2022 19:37:55 +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-wm1-x32f.google.com with SMTP id r7so8412309wmq.5 for ; Sun, 06 Feb 2022 10:37:55 -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=sP3ETFSN6gh6EqUIXXzUHY7m/CYJzfrajtE6eFugTBc=; b=C4EI01c1V9cVjWNzVj5/DzUJrVytiBCx6kUGdXOkttGjwrQWfWwK8jyTJchxQbAQn7 Tb1FMsTkcTVKKJqVKA+s3KeX3zAM8HAQyYe+2gn7OzEnqxqAxA0wsk4YEmHCoFODIja4 z+iXcvSxzgmLeBMmZgyEnanSwDzdGMU8fzO0U= 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=sP3ETFSN6gh6EqUIXXzUHY7m/CYJzfrajtE6eFugTBc=; b=4Wc/J45G+KnN3MHMJFh3mFTRR3pQMtS2r3uKHYt37aNsiccb+0Y272RcZFAtDCP7sh 5tJneuwIiHOsjYrVKxbXL1e8D7SEZIYZ+FY6vgoyIlcGh4TbD9n5uJu/7cQ1tYgldvaj pqu1VakF4uKn6jr/o1ld2b0dssDQeIkz5KjMtg8TVQy4bfqCQ6wSw4otSmkaKOHjreYD XdT0SzW98WFKV5N161Nfy1VZBNSIlO11ED7OmB3vQY8DlYdp/KTk3qEv/qhBfUV42Jcj W2ePLK1pt+yO+80vjATGBYb4+6G2YdNhn4LQjWWO0C2/oEFqIQXTPwImj09a5ULjhgaX yBDQ== X-Gm-Message-State: AOAM530eblR8A7y8wo5XePxF1rolngWk4qSudI/kGcXSt/0/O+DpLKEw o3HDl9re/SAkp42ghY6jHs8uhLfpoEEdNQ== X-Google-Smtp-Source: ABdhPJy8psYDZeHA28fRzcG+3g+hem7fUFq5AGqo4eHnKfy2h6/C21yjwIF2VbBFSyrATgmpf6tpBw== X-Received: by 2002:a05:600c:b59:: with SMTP id k25mr6898343wmr.170.1644172675156; Sun, 06 Feb 2022 10:37:55 -0800 (PST) Received: from pwmachine.home ([2a01:cb14:983:1f00:e5b3:218b:cb92:2549]) by smtp.gmail.com with ESMTPSA id ay29sm7095011wmb.38.2022.02.06.10.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:54 -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 v2 19/21] test: hush: Fix if tests for hush 2021 Date: Sun, 6 Feb 2022 19:37:15 +0100 Message-Id: <20220206183717.57446-20-francis.laniel@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220206183717.57446-1-francis.laniel@amarulasolutions.com> References: <20220206183717.57446-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.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 Reviewed-by: Simon Glass --- test/hush/if.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/hush/if.c b/test/hush/if.c index a57d88850f..b2f1f247f5 100644 --- a/test/hush/if.c +++ b/test/hush/if.c @@ -39,6 +39,10 @@ static int hush_test_if_basic_operators(struct unit_test_state *uts) { char if_formatted[128]; +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + console_record_reset_enable(); +#endif /* HUSH_2021_PARSER */ + sprintf(if_formatted, if_format, "test aaa = aaa"); ut_assertok(run_command(if_formatted, 0)); @@ -52,15 +56,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 CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* + * We need to escape < and > to use as them as string comparison + * operator. + * Otherwise, they are interprated 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, R"(test aaa \< bbb)"); +#endif /* HUSH_2021_PARSER */ ut_assertok(run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test bbb < aaa"); +#if CONFIG_IS_ENABLED(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, R"(test bbb \< aaa)"); +#endif /* HUSH_2021_PARSER */ ut_asserteq(1, run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test bbb > aaa"); +#if CONFIG_IS_ENABLED(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, R"(test bbb \> aaa)"); +#endif /* HUSH_2021_PARSER */ ut_assertok(run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test aaa > bbb"); +#if CONFIG_IS_ENABLED(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, R"(test aaa \> bbb)"); +#endif /* HUSH_2021_PARSER */ ut_asserteq(1, run_command(if_formatted, 0)); sprintf(if_formatted, if_format, "test 123 -eq 123"); -- 2.25.1