[PATCH 2/2] test: fit: Add test to check environment extraction from FIT conf node

lukas.funke-oss at weidmueller.com lukas.funke-oss at weidmueller.com
Tue Jul 2 08:48:34 CEST 2024


From: Lukas Funke <lukas.funke at weidmueller.com>

Add test which adds environment variables to the FIT configuration node
and checks whether they are exported to the runtime environment.

Signed-off-by: Lukas Funke <lukas.funke at weidmueller.com>
---

 configs/sandbox_defconfig |  1 +
 test/py/tests/test_fit.py | 45 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 93b52f2de5c..7431c8a910e 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -142,6 +142,7 @@ CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="host"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_ENV_IMPORT_FDT=y
+CONFIG_ENV_IMPORT_FIT_CONF=y
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index 8f9c4b26411..2a3aba74502 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -74,6 +74,8 @@ base_its = '''
                         fdt = "fdt-1";
                         %(ramdisk_config)s
                         %(loadables_config)s
+                        %(env_var0)s
+                        %(env_var1)s
                 };
         };
 };
@@ -308,6 +310,13 @@ def test_fit(u_boot_console):
 
             'loadables_config' : '',
             'compression' : 'none',
+
+            'env_var0': '',
+            'env_var0_name': 'foo',
+            'env_var0_value': 'somevalue',
+            'env_var1': '',
+            'env_var1_name': 'bar',
+            'env_var1_value': 'anothervalue',
         }
 
         # Make a basic FIT and a script to load it
@@ -396,6 +405,42 @@ def test_fit(u_boot_console):
             check_not_equal(ramdisk, ramdisk_out, 'Ramdisk got decompressed?')
             check_equal(ramdisk + '.gz', ramdisk_out, 'Ramdist not loaded')
 
+        # Now a kernel, FDT and environment variables
+        with cons.log.section('Kernel + FDT load + env'):
+            params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr']
+            params['env_var0'] = ('env,%s = "%s";' %
+                                 (params['env_var0_name'],
+                                  params['env_var0_value']))
+            params['env_var1'] = ('env,%s = "%s";' %
+                                 (params['env_var1_name'],
+                                  params['env_var1_value']))
+            fit = fit_util.make_fit(cons, mkimage, base_its, params)
+            cons.restart_uboot()
+
+            output = cons.run_command_list(cmd.splitlines())
+            check_equal(kernel, kernel_out, 'Kernel not loaded')
+            check_equal(control_dtb, fdt_out, 'FDT not loaded')
+            check_not_equal(ramdisk, ramdisk_out,
+                            'Ramdisk loaded but should not be')
+
+            # Check if bootargs strings substitution works
+            output = cons.run_command_list([
+                'env set bootargs \\\"\'my_boot_var=${%s}\'\\\"' % params['env_var0_name'],
+                'bootm prep',
+                'env print %s' % params['env_var0_name'],
+                'env print %s' % params['env_var1_name'],
+                'env print bootargs'])
+            assert ('%s=%s' %
+                    (params['env_var0_name'],
+                     params['env_var0_value'])) \
+                in output, "Environment not loaded from configuration"
+            assert ('%s=%s' %
+                    (params['env_var1_name'],
+                     params['env_var1_value'])) \
+                in output, "Environment not loaded from configuration"
+            assert 'bootargs="my_boot_var=%s"' % params['env_var0_value'] \
+                in output, "Bootargs strings not substituted"
+
 
     cons = u_boot_console
     # We need to use our own device tree file. Remember to restore it
-- 
2.30.2



More information about the U-Boot mailing list