Prevent populating the checklist with empty data
authorAlexander Popov <alex.popov@linux.com>
Fri, 24 Mar 2023 20:17:39 +0000 (23:17 +0300)
committerAlexander Popov <alex.popov@linux.com>
Fri, 24 Mar 2023 20:17:39 +0000 (23:17 +0300)
kconfig_hardened_check/engine.py
kconfig_hardened_check/test_engine.py

index 63087400bb57b21dd160b78ab243c921b9ee930c..8a4ccb8519dbe76323d1feb3dc527201f9ac6127 100644 (file)
@@ -254,6 +254,8 @@ def populate_simple_opt_with_data(opt, data, data_type):
            f'invalid opt type "{opt.type}"'
     assert(data_type in SIMPLE_OPTION_TYPES), \
            f'invalid data type "{data_type}"'
+    assert(data), \
+           f'empty data'
 
     if data_type != opt.type:
         return
index baabd96d86bde2a902a6cc62b6ba8a697a49ffad..710e99a71b52bb5d7c90705514b784a5535ae652 100644 (file)
@@ -53,9 +53,12 @@ class TestEngine(unittest.TestCase):
                    parsed_kconfig_options, parsed_cmdline_options, kernel_version,
                    result):
         # populate the checklist with data
-        populate_with_data(checklist, parsed_kconfig_options, 'kconfig')
-        populate_with_data(checklist, parsed_cmdline_options, 'cmdline')
-        populate_with_data(checklist, kernel_version, 'version')
+        if parsed_kconfig_options:
+            populate_with_data(checklist, parsed_kconfig_options, 'kconfig')
+        if parsed_cmdline_options:
+            populate_with_data(checklist, parsed_cmdline_options, 'cmdline')
+        if kernel_version:
+            populate_with_data(checklist, kernel_version, 'version')
 
         # now everything is ready, perform the checks
         perform_checks(checklist)