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 09D2EC433F5 for ; Fri, 31 Dec 2021 16:16:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8227283693; Fri, 31 Dec 2021 17:15:21 +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="FSVyuiYN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 479C38345C; Fri, 31 Dec 2021 17:14:59 +0100 (CET) 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 64A7A83542 for ; Fri, 31 Dec 2021 17:14:14 +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 s1so56680777wra.6 for ; Fri, 31 Dec 2021 08:14:14 -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=E2iSA0x95hSDXoSpUbb1EuJgVvYfvhViWsm7tHLGopg=; b=FSVyuiYNuAbO92QNjynUwS9rSqKSI6pt4CktJKAij3VUHAC3QlGkLbBdy4upaJS9N6 jkaUx5fKeS280rSJzGPO49kVhzlGxMhsYUNvTGMCXNQMXxhwg2oqgajSoJZcNw787U4j /cgdOxkl7sKyP6hXc4qEhAO7wQDBO1YR/84eI= 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=E2iSA0x95hSDXoSpUbb1EuJgVvYfvhViWsm7tHLGopg=; b=FVKuq0DsEw97xug0bVQ0yQatqosUojxtBIo/Ef8KjAIlidwSGI5EARhE0okhDvzEvf zS45DjT2t+o7En2/Hwilj5h3Dbyx+vpJnJp3yipuhEoeJ9fNIRa3L+SswOmUXoNSmZCx 2hbakinA6aafPqr2y0Lo37sKOx7Lkgxm2W2X5xjKfYhoMXOta62DW5IyLSKY1cGHe4a+ m3gZ7M7/BAr0Obc6kOKMcmY6JMLDJ6Vry1MjNOqs7VOdsa1QKQp01Sm6X1KwYU6CM5Ea JLliwJKnOkLodqPA24rG88dDsvxfOKGi6hZtGjqVxVqynV3GT2zN0musapCX9U8wJAHG 0N3Q== X-Gm-Message-State: AOAM530YWgiknDzedxueVrJl8XY6UCVENIDfGWHdaXsBZNlRyctHaZ3z poqtl9sFnIc085XfjsLxj3gToyP0KaMUjw== X-Google-Smtp-Source: ABdhPJwzxGQnIH6OeiOGPajB5IdD70YglKl0UM53DZmfm/vwOiqbJRfWO9npAt/JQN7w7rJXDOEBbg== X-Received: by 2002:adf:82d2:: with SMTP id 76mr29684400wrc.329.1640967254011; Fri, 31 Dec 2021 08:14:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 08:14:13 -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 16/21] test: hush: Fix variable expansion tests for hush 2021. Date: Fri, 31 Dec 2021 17:13:22 +0100 Message-Id: <20211231161327.24918-17-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 Content-Transfer-Encoding: 8bit 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 expected result for hush 2021. Indeed, there were bugs in actual U-Boot hush which were fixed in upstream Busybox. As hush 2021 is based on upstream Busybox, these bugs no longer exist. Signed-off-by: Francis Laniel --- test/hush/dollar.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/hush/dollar.c b/test/hush/dollar.c index 9313d145d6..df2ad043f4 100644 --- a/test/hush/dollar.c +++ b/test/hush/dollar.c @@ -73,13 +73,27 @@ static int hush_test_simple_dollar(struct unit_test_state *uts) ut_asserteq(1, run_command("dollar_foo='bar quux", 0)); /* Next line contains error message. */ ut_assert_skipline(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* + * For some strange reasons, the console is not empty after running + * above command. + * So, we reset it to not have side effects for other tests. + */ + console_record_reset_enable(); +#else /* HUSH_OLD_PARSER */ ut_assert_console_end(); +#endif /* HUSH_OLD_PARSER */ ut_asserteq(1, run_command(R"(dollar_foo=bar quux")", 0)); /* Two next lines contain error message. */ ut_assert_skipline(); ut_assert_skipline(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* See above comments. */ + console_record_reset_enable(); +#else /* HUSH_OLD_PARSER */ ut_assert_console_end(); +#endif /* HUSH_OLD_PARSER */ ut_assertok(run_command(R"(dollar_foo='bar "quux')", 0)); @@ -93,17 +107,35 @@ static int hush_test_simple_dollar(struct unit_test_state *uts) */ console_record_reset_enable(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* + * Old parser returns an error because it waits for closing '\'', but + * this behavior is wrong as the '\'' is surrounded by '"', so no need + * to wait for a closing one. + */ + ut_assertok(run_command(R"(dollar_foo="bar 'quux")", 0)); + + ut_assertok(run_command("echo $dollar_foo", 0)); + ut_assert_nextline("bar 'quux"); + ut_assert_console_end(); +#else /* HUSH_OLD_PARSER */ ut_asserteq(1, run_command(R"(dollar_foo="bar 'quux")", 0)); /* Next line contains error message. */ ut_assert_skipline(); ut_assert_console_end(); +#endif /* HUSH_OLD_PARSER */ ut_assertok(run_command("dollar_foo='bar quux'", 0)); ut_assertok(run_command("echo $dollar_foo", 0)); ut_assert_nextline("bar quux"); ut_assert_console_end(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* Reset local variable. */ + ut_assertok(run_command("dollar_foo=", 0)); +#else /* HUSH_OLD_PARSER */ puts("Beware: this test set local variable dollar_foo and it cannot be unset!"); +#endif /* HUSH_OLD_PARSER */ return 0; } @@ -131,7 +163,12 @@ static int hush_test_env_dollar(struct unit_test_state *uts) /* Clean up setting the variable. */ env_set("env_foo", NULL); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* Reset local variable. */ + ut_assertok(run_command("env_foo=", 0)); +#else /* HUSH_OLD_PARSER */ puts("Beware: this test set local variable env_foo and it cannot be unset!"); +#endif /* HUSH_OLD_PARSER */ return 0; } @@ -168,7 +205,15 @@ static int hush_test_command_dollar(struct unit_test_state *uts) ut_assertok(run_command(R"(dollar_bar='echo bar\n')", 0)); ut_assertok(run_command("$dollar_bar", 0)); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* + * This difference seems to come from a bug solved in Busybox hush. + * Behavior of hush 2021 is coherent with bash and other shells. + */ + ut_assert_nextline(R"(bar\n)"); +#else /* HUSH_OLD_PARSER */ ut_assert_nextline("barn"); +#endif /* HUSH_OLD_PARSER */ ut_assert_console_end(); ut_assertok(run_command("dollar_bar='echo $bar'", 0)); @@ -184,7 +229,13 @@ static int hush_test_command_dollar(struct unit_test_state *uts) ut_assert_nextline("quux"); ut_assert_console_end(); +#if CONFIG_IS_ENABLED(HUSH_2021_PARSER) + /* Reset local variables. */ + ut_assertok(run_command("dollar_bar=", 0)); + ut_assertok(run_command("dollar_quux=", 0)); +#else /* HUSH_OLD_PARSER */ puts("Beware: this test sets local variable dollar_bar and dollar_quux and they cannot be unset!"); +#endif /* HUSH_OLD_PARSER */ return 0; } -- 2.25.1