test: hush_if_test: Add hush variable test
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Mon, 3 Apr 2023 13:50:01 +0000 (15:50 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 3 May 2023 22:30:46 +0000 (18:30 -0400)
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>
test/py/tests/test_hush_if_test.py

index 37c1608..3b4b6fc 100644 (file)
@@ -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=')