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 C04D5C433EF for ; Sun, 6 Feb 2022 18:38:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8DC9783C1B; Sun, 6 Feb 2022 19:37:54 +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="IMQ9igVn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B559383BD0; Sun, 6 Feb 2022 19:37:50 +0100 (CET) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 0A61A83BD4 for ; Sun, 6 Feb 2022 19:37:41 +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-x335.google.com with SMTP id k6-20020a05600c1c8600b003524656034cso7197537wms.2 for ; Sun, 06 Feb 2022 10:37:41 -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=i24sYER8/dnRy2ho1ocYvJPh2jwfsRgNIMgYlCOTyac=; b=IMQ9igVnA1SOZSAvWW3f1HX0z3HvU2UJSZ48BWHGNp4q+MjPHlBQww/FL4/qwsikBG tUR0J7B6FrZIrFSfawbj9hvzE590sxu219cCke0R3mKa10i4pJW/LF2ZGcXa+Yx8j2xe eQw0TikdoGDRTrawEQBQV00LQCJZUooif5INg= 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=i24sYER8/dnRy2ho1ocYvJPh2jwfsRgNIMgYlCOTyac=; b=vn4dJkCiiTz/R4x+tca8xsGkMWLD8I8YVwpnUfkg+fUoA8Ih3J9TPYlZpCrDhvwcsd zZn7I9BxVYVReEh4UBXe4Pa3JMcpUDrGUPiQZ0Yqgx4YSnnftc0YAZuBE2FKqUoZpOz3 wwEtEsiV/s9ti+l0hTz6OECKuPD9aw4V7Iyoz/5/MfQgZRcF/28UOijqqbpSq4pvwPHT vUcIdr0XG9taXbEtCNhijnuca4zNcgE8ubU5CgE4Xjol0FH6NfIgd2nyiFt5c9pbL05p J5AL582+hZzh2xaTHZQjwJfghyHdt42FJmP9cM2jyMXsMIoWiBzlILvSCmf1UBSL0x+N 4eTQ== X-Gm-Message-State: AOAM533wytAtm/YNfXBvfvyB8YEdFDR+HDC6qYE42oE/gM8o0Z22bgZF ep9MvVlCPOJyV5WJox2gFxhril4KeODzMQ== X-Google-Smtp-Source: ABdhPJxWke9DuPJzw4wLAcjBxhNMV8/YZ2g94LJNV013fRqMBdryR59aN/Cbek/iebp+Fmvxd8DN+g== X-Received: by 2002:a05:600c:154d:: with SMTP id f13mr11109669wmg.70.1644172660675; Sun, 06 Feb 2022 10:37:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 10:37:40 -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 05/21] test: hush: Test hush commands list Date: Sun, 6 Feb 2022 19:37:01 +0100 Message-Id: <20220206183717.57446-6-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 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