diff mbox series

[v2,2/2] test: hush_if_test: Add hush variable test

Message ID 20230403135001.14573-2-stefan.herbrechtsmeier-oss@weidmueller.com
State Accepted
Commit 2ac800a66f996da045d61ee5cff1f6694e893949
Delegated to: Tom Rini
Headers show
Series [v2,1/2] common: cli_hush: Restore clear local variable support | expand

Commit Message

Stefan Herbrechtsmeier April 3, 2023, 1:50 p.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add a test for the hush shell variable assignment and clear.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

(no changes since v1)

 test/py/tests/test_hush_if_test.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

--
2.30.2

Comments

Simon Glass April 5, 2023, 6:38 p.m. UTC | #1
On Tue, 4 Apr 2023 at 01:50, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> Add a test for the hush shell variable assignment and clear.
>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
>
> (no changes since v1)
>
>  test/py/tests/test_hush_if_test.py | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini May 4, 2023, 3:52 p.m. UTC | #2
On Mon, Apr 03, 2023 at 03:50:01PM +0200, Stefan Herbrechtsmeier wrote:

> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Add a test for the hush shell variable assignment and clear.
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/test/py/tests/test_hush_if_test.py b/test/py/tests/test_hush_if_test.py
index 37c1608bb2..3b4b6fcaf4 100644
--- a/test/py/tests/test_hush_if_test.py
+++ b/test/py/tests/test_hush_if_test.py
@@ -182,3 +182,16 @@  def test_hush_if_test_host_file_exists(u_boot_console):

     expr = 'test -e hostfs - ' + test_file
     exec_hush_if(u_boot_console, expr, False)
+
+def test_hush_var(u_boot_console):
+    """Test the set and unset of variables"""
+    u_boot_console.run_command('ut_var_nonexistent=')
+    u_boot_console.run_command('ut_var_exists=1')
+    u_boot_console.run_command('ut_var_unset=1')
+    exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True)
+    exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False)
+    exec_hush_if(u_boot_console, 'test -z "$ut_var_unset"', False)
+    exec_hush_if(u_boot_console, 'ut_var_unset=', True)
+    exec_hush_if(u_boot_console, 'test -z "$ut_var_unset"', True)
+    u_boot_console.run_command('ut_var_exists=')
+    u_boot_console.run_command('ut_var_unset=')