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 474AAC433FE for ; Tue, 1 Nov 2022 19:22:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66EE785047; Tue, 1 Nov 2022 20:21:21 +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="fnKU7FPP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7212084E74; Tue, 1 Nov 2022 20:21:14 +0100 (CET) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 9044784F2C for ; Tue, 1 Nov 2022 20:21:11 +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-x32e.google.com with SMTP id i5-20020a1c3b05000000b003cf47dcd316so13370819wma.4 for ; Tue, 01 Nov 2022 12:21:11 -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=i24sYER8/dnRy2ho1ocYvJPh2jwfsRgNIMgYlCOTyac=; b=fnKU7FPPt3XoAv76DFYZWrmCl9jk+Duuoq/wRisEu0VV9jHwlGZ4ts1C74spDsVZYJ CaG8B/rPo04i1oqD3Oci+qCxlbFtsV2msXvFmnO10x/5VWaJxlzIdWqs7YO19K+/r/Bu vPzY6e0CENB2fdGaTTfdZCGcEzehqgPr1N3cY= 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=i24sYER8/dnRy2ho1ocYvJPh2jwfsRgNIMgYlCOTyac=; b=2J/T5N4NYXY18rBqt51HZNUY2hNPrhz6ErPsJQUkHZI+i5T21Ytjl4LKxqsg6M488G UTPb1rbo89AKx+2MJSfqpNaw7jIkLZntHX79XhAlm6d+TPdzxUnll3exD/6NX2AbhAyu NRxdR/+CgA8DKFkRSJRY3x3n0Crqa/iHrjVuOOFwLdXiN9YRb++3vlC3tm84yoj1JyFN PAJeYOh++3C3z+DaCEoicUZeUsDKVOAwIrGA4meDaVc6bPqoVhWZCYSSPFQ5x/I9HQoN BfPJiOtMI+n3TghZltGBjenagot3JrONKyIHrVOZFc6Tn2U6t6B37saje9YucJwxBdC8 nxhA== X-Gm-Message-State: ACrzQf2/Im0i/fiwN7bkhEoXbhM1sRcDWlgdrycCKWTAXe7R3dDw1lOu 9KzdCVdP2oGUgy+LvEampU1b3ftROh0vlw== X-Google-Smtp-Source: AMsMyM6iAbS7ZiSkz5D/uvxNRzSaGSMdydeamoX+d2VRD2GplqPsCwTv7t2qP8qNpD5ww1Lxwn4Bcg== X-Received: by 2002:a7b:ca4f:0:b0:3c6:ce01:bc4a with SMTP id m15-20020a7bca4f000000b003c6ce01bc4amr23555721wml.42.1667330471152; Tue, 01 Nov 2022 12:21:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 12:21:10 -0700 (PDT) From: Francis Laniel To: u-boot@lists.denx.de Cc: Michael Nazzareno Trimarchi , Tom Rini , Aleksandar Gerasimovski , Holger Brunck , Francis Laniel , Simon Glass Subject: [RFC PATCH v5 05/24] test: hush: Test hush commands list Date: Tue, 1 Nov 2022 20:20:10 +0100 Message-Id: <20221101192029.10231-6-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 Verifies behavior of commands separated by ';', '&&' and '||'. Signed-off-by: Francis Laniel Reviewed-by: Simon Glass --- test/hush/Makefile | 1 + test/hush/list.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 test/hush/list.c diff --git a/test/hush/Makefile b/test/hush/Makefile index feb4f71956..ff4fe7700b 100644 --- a/test/hush/Makefile +++ b/test/hush/Makefile @@ -6,3 +6,4 @@ obj-y += cmd_ut_hush.o obj-y += if.o obj-y += dollar.o +obj-y += list.o diff --git a/test/hush/list.c b/test/hush/list.c new file mode 100644 index 0000000000..052cf2783c --- /dev/null +++ b/test/hush/list.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2021 + * Francis Laniel, Amarula Solutions, francis.laniel@amarulasolutions.com + */ + +#include +#include +#include +#include +#include + +static int hush_test_semicolon(struct unit_test_state *uts) +{ + /* A; B = B truth table. */ + ut_asserteq(1, run_command("false; false", 0)); + ut_assertok(run_command("false; true", 0)); + ut_assertok(run_command("true; true", 0)); + ut_asserteq(1, run_command("true; false", 0)); + + return 0; +} +HUSH_TEST(hush_test_semicolon, 0); + +static int hush_test_and(struct unit_test_state *uts) +{ + /* A && B truth table. */ + ut_asserteq(1, run_command("false && false", 0)); + ut_asserteq(1, run_command("false && true", 0)); + ut_assertok(run_command("true && true", 0)); + ut_asserteq(1, run_command("true && false", 0)); + + return 0; +} +HUSH_TEST(hush_test_and, 0); + +static int hush_test_or(struct unit_test_state *uts) +{ + /* A || B truth table. */ + ut_asserteq(1, run_command("false || false", 0)); + ut_assertok(run_command("false || true", 0)); + ut_assertok(run_command("true || true", 0)); + ut_assertok(run_command("true || false", 0)); + + return 0; +} +HUSH_TEST(hush_test_or, 0); + +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)); + 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)); + ut_assertok(run_command("true && false || true", 0)); + ut_assertok(run_command("true && true || true", 0)); + + return 0; +} +HUSH_TEST(hush_test_and_or, 0); + +static int hush_test_or_and(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_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)); + ut_assertok(run_command("true || false && true", 0)); + ut_assertok(run_command("true || true && true", 0)); + + return 0; +} +HUSH_TEST(hush_test_or_and, 0); -- 2.25.1