From f8fb03bef466efbe8d8cc045ce077a382113bf28 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Fri, 24 Mar 2023 23:17:20 +0300 Subject: [PATCH] test_engine: add test_cmdline_ok() and test_cmdline_fail() --- kconfig_hardened_check/test_engine.py | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/kconfig_hardened_check/test_engine.py b/kconfig_hardened_check/test_engine.py index 12241d1..baabd96 100644 --- a/kconfig_hardened_check/test_engine.py +++ b/kconfig_hardened_check/test_engine.py @@ -110,3 +110,41 @@ class TestEngine(unittest.TestCase): result, [["CONFIG_NAME_2", "kconfig", "expected_2", "decision_2", "reason_2", "FAIL: \"UNexpected_2\""]] ) + + def test_cmdline_ok(self): + # 1. prepare the checklist + config_checklist = [] + config_checklist += [CmdlineCheck('reason_3', 'decision_3', 'name_3', 'expected_3')] + + # 2. prepare the parsed cmdline options + parsed_cmdline_options = OrderedDict() + parsed_cmdline_options['name_3'] = 'expected_3' + + # 3. run the engine + result = [] + self.run_engine(config_checklist, None, parsed_cmdline_options, None, result) + + # 4. check that the results are correct + self.assertEqual( + result, + [["name_3", "cmdline", "expected_3", "decision_3", "reason_3", "OK"]] + ) + + def test_cmdline_fail(self): + # 1. prepare the checklist + config_checklist = [] + config_checklist += [CmdlineCheck('reason_4', 'decision_4', 'name_4', 'expected_4')] + + # 2. prepare the parsed cmdline options + parsed_cmdline_options = OrderedDict() + parsed_cmdline_options['name_4'] = 'UNexpected_4' + + # 3. run the engine + result = [] + self.run_engine(config_checklist, None, parsed_cmdline_options, None, result) + + # 4. check that the results are correct + self.assertEqual( + result, + [["name_4", "cmdline", "expected_4", "decision_4", "reason_4", "FAIL: \"UNexpected_4\""]] + ) -- 2.31.1