X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=kconfig_hardened_check%2Ftest_engine.py;h=baabd96d86bde2a902a6cc62b6ba8a697a49ffad;hb=f8fb03bef466efbe8d8cc045ce077a382113bf28;hp=12241d16944524967e9d12621baedcebbb5a3e5e;hpb=81c2b24974b3f4c3807e2d2dd5b08deb90044314;p=kconfig-hardened-check.git 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\""]] + )