From patchwork Fri Dec 31 16:13:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francis Laniel X-Patchwork-Id: 1574402 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=bzti8gbC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JQVfH0r9Gz9s0r for ; Sat, 1 Jan 2022 03:17:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 42F60830EC; Fri, 31 Dec 2021 17:15:46 +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="bzti8gbC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3666983681; Fri, 31 Dec 2021 17:15:23 +0100 (CET) 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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (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 BD285836CB for ; Fri, 31 Dec 2021 17:14:16 +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-x429.google.com with SMTP id q16so56713312wrg.7 for ; Fri, 31 Dec 2021 08:14:16 -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=ERBwBHM9xUWTBw19mZbU7irviCEYFj6EXiJbViFRpuI=; b=bzti8gbCMWUQ9IoEfiqnXgtOs8iJaFN1XAa6Ao5ZT/xKQcJsEiCO9B8kEmkzYP4SDD 5SnlM+fHmzI1jWRKHNsgaXj6LMn1nR6aAxsGnFbYrdCHs53d1ILG7w145HeEWNc13QrC hKu79fLk10Cl4o8TXdMtmt+1k0yioPLvfYynU= 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=ERBwBHM9xUWTBw19mZbU7irviCEYFj6EXiJbViFRpuI=; b=XiT8Jz9ydIMn8W+OUwf2nG2oxZge2bSXWtbLRyMTprR1MXygj0ISwxzaMcv7oDF/mx CJmhf8UNF4SknkDiv6ck2Cx9ZP4gk6GHhloBEXIt1O5FpmFw/sDQUNyEueBJJOAY887r 5Ym94fCGPR/HomxDqD0MfOzuKyRYyOZS64NDEE2E1njIZ9c8pSTv91EPmHHTpekQYg+6 OSxmvLprtSBLK1pcclnSWkkKhhYCjGsKRbICP1qwHn9pn35Yst9iFQGHnyLfwN4fyz+d 5wEo2PXjm2WOIXHorAQovrOGUzcG7SlWDlH0pvpMoVBnDiry1Hsm4w7W0vTxk8abMpoO 9Dgg== X-Gm-Message-State: AOAM531eXm1XWkLOs5gUj7sXEnA0cxI0XmaLBabsRuPgU8I8Zbeujp5o LMF79azS0r55GC0sxDH3eBSWcCTQXbvgDQ== X-Google-Smtp-Source: ABdhPJySJi9YxIfzJCNDXSo2KBOHFwFMQ2wPwsspif5WLLTTCWMAn0rXH+Gy+v4wPbKH9YlrZKEq4w== X-Received: by 2002:a5d:4646:: with SMTP id j6mr29101848wrs.485.1640967256463; Fri, 31 Dec 2021 08:14:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:16 -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 19/21] test: hush: Fix if tests for hush 2021. Date: Fri, 31 Dec 2021 17:13:25 +0100 Message-Id: <20211231161327.24918-20-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 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 the command run for hush 2021 when using string comparison operator. Indeed, '<' and '>' must be escaped to be used as string comparison operator. 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");