From a110fbc7a8e2000e0b634aaad0627b71bc0bbdc4 Mon Sep 17 00:00:00 2001 From: krishjainx Date: Sun, 17 Mar 2024 03:20:27 -0400 Subject: [PATCH] fix issues --- kernel_hardening_checker/engine.py | 4 +- kernel_hardening_checker/test_engine.py | 108 ++++++++++++------------ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/kernel_hardening_checker/engine.py b/kernel_hardening_checker/engine.py index b78b101..1d75251 100644 --- a/kernel_hardening_checker/engine.py +++ b/kernel_hardening_checker/engine.py @@ -226,9 +226,9 @@ class ComplexOptCheck: def json_dump(self, with_results): dump = self.opts[0].json_dump(False) if with_results: - # Add 'result_text' and 'result' keys to the dictionary + # Add 'check_result_text' and 'check_result' keys to the dictionary dump["check_result_text"] = self.result - dump["check_result"] = "FAIL" not in self.result + dump["check_result"] = self.result.startswith('OK') return dump diff --git a/kernel_hardening_checker/test_engine.py b/kernel_hardening_checker/test_engine.py index f37848a..9cd3458 100644 --- a/kernel_hardening_checker/test_engine.py +++ b/kernel_hardening_checker/test_engine.py @@ -138,15 +138,15 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'CONFIG_NAME_2', 'type': 'kconfig', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, - {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, - {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, - {'option_name': 'CONFIG_NAME_6', 'type': 'kconfig', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, - {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, "really_not_off"', 'check_result': True}, - {'option_name': 'CONFIG_NAME_8', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, - {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_10', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] + {'option_name': 'CONFIG_NAME_2', 'type': 'kconfig', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, + {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, + {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, + {'option_name': 'CONFIG_NAME_6', 'type': 'kconfig', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, + {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, "really_not_off"', 'check_result': True}, + {'option_name': 'CONFIG_NAME_8', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, + {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_10', 'type': 'kconfig', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] ) def test_simple_cmdline(self): @@ -181,15 +181,15 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'name_1', 'type': 'cmdline', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, - {'option_name': 'name_3', 'type': 'cmdline', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, - {'option_name': 'name_4', 'type': 'cmdline', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, - {'option_name': 'name_5', 'type': 'cmdline', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, - {'option_name': 'name_6', 'type': 'cmdline', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, - {'option_name': 'name_7', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, ""', 'check_result': True}, - {'option_name': 'name_8', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, - {'option_name': 'name_9', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, - {'option_name': 'name_10', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] + {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, + {'option_name': 'name_3', 'type': 'cmdline', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, + {'option_name': 'name_4', 'type': 'cmdline', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, + {'option_name': 'name_5', 'type': 'cmdline', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, + {'option_name': 'name_6', 'type': 'cmdline', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, + {'option_name': 'name_7', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, ""', 'check_result': True}, + {'option_name': 'name_8', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, + {'option_name': 'name_9', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, + {'option_name': 'name_10', 'type': 'cmdline', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] ) def test_simple_sysctl(self): @@ -224,15 +224,15 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'name_1', 'type': 'sysctl', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_2', 'type': 'sysctl', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, - {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, - {'option_name': 'name_4', 'type': 'sysctl', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, - {'option_name': 'name_5', 'type': 'sysctl', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, - {'option_name': 'name_6', 'type': 'sysctl', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, - {'option_name': 'name_7', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, ""', 'check_result': True}, - {'option_name': 'name_8', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, - {'option_name': 'name_9', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, - {'option_name': 'name_10', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] + {'option_name': 'name_2', 'type': 'sysctl', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "UNexpected_2"', 'check_result': False}, + {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: is not found', 'check_result': False}, + {'option_name': 'name_4', 'type': 'sysctl', 'desired_val': 'is not set', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'OK: is not found', 'check_result': True}, + {'option_name': 'name_5', 'type': 'sysctl', 'desired_val': 'is present', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: is present', 'check_result': True}, + {'option_name': 'name_6', 'type': 'sysctl', 'desired_val': 'is present', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: is not present', 'check_result': False}, + {'option_name': 'name_7', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: is not off, ""', 'check_result': True}, + {'option_name': 'name_8', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_8', 'reason': 'reason_8', 'check_result_text': 'FAIL: is off', 'check_result': False}, + {'option_name': 'name_9', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: is off, "0"', 'check_result': False}, + {'option_name': 'name_10', 'type': 'sysctl', 'desired_val': 'is not off', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: is off, not found', 'check_result': False}] ) def test_complex_or(self): @@ -271,11 +271,11 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK: CONFIG_NAME_4 is "expected_4"', 'check_result': True}, - {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'FAIL: "UNexpected_5"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: CONFIG_NAME_8 is not found', 'check_result': True}, - {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'expected_9', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'OK: CONFIG_NAME_10 is present', 'check_result': True}, - {'option_name': 'CONFIG_NAME_11', 'type': 'kconfig', 'desired_val': 'expected_11', 'decision': 'decision_11', 'reason': 'reason_11', 'check_result_text': 'OK: CONFIG_NAME_12 is not off', 'check_result': True}] + {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK: CONFIG_NAME_4 is "expected_4"', 'check_result': True}, + {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'FAIL: "UNexpected_5"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: CONFIG_NAME_8 is not found', 'check_result': True}, + {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'expected_9', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'OK: CONFIG_NAME_10 is present', 'check_result': True}, + {'option_name': 'CONFIG_NAME_11', 'type': 'kconfig', 'desired_val': 'expected_11', 'decision': 'decision_11', 'reason': 'reason_11', 'check_result_text': 'OK: CONFIG_NAME_12 is not off', 'check_result': True}] ) def test_complex_and(self): @@ -316,11 +316,11 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: CONFIG_NAME_4 is not "expected_4"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'FAIL: "UNexpected_5"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'FAIL: CONFIG_NAME_8 is not present', 'check_result': False}, - {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'expected_9', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: CONFIG_NAME_10 is off', 'check_result': False}, - {'option_name': 'CONFIG_NAME_11', 'type': 'kconfig', 'desired_val': 'expected_11', 'decision': 'decision_11', 'reason': 'reason_11', 'check_result_text': 'FAIL: CONFIG_NAME_12 is off, not found', 'check_result': False}] + {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: CONFIG_NAME_4 is not "expected_4"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'FAIL: "UNexpected_5"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'FAIL: CONFIG_NAME_8 is not present', 'check_result': False}, + {'option_name': 'CONFIG_NAME_9', 'type': 'kconfig', 'desired_val': 'expected_9', 'decision': 'decision_9', 'reason': 'reason_9', 'check_result_text': 'FAIL: CONFIG_NAME_10 is off', 'check_result': False}, + {'option_name': 'CONFIG_NAME_11', 'type': 'kconfig', 'desired_val': 'expected_11', 'decision': 'decision_11', 'reason': 'reason_11', 'check_result_text': 'FAIL: CONFIG_NAME_12 is off, not found', 'check_result': False}] ) def test_complex_nested(self): @@ -363,9 +363,9 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: CONFIG_NAME_5 is not "expected_5"', 'check_result': False}, - {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: CONFIG_NAME_8 is "expected_8"', 'check_result': True}, - {'option_name': 'CONFIG_NAME_10', 'type': 'kconfig', 'desired_val': 'expected_10', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: "UNexpected_10"', 'check_result': False}] + {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: CONFIG_NAME_5 is not "expected_5"', 'check_result': False}, + {'option_name': 'CONFIG_NAME_7', 'type': 'kconfig', 'desired_val': 'expected_7', 'decision': 'decision_7', 'reason': 'reason_7', 'check_result_text': 'OK: CONFIG_NAME_8 is "expected_8"', 'check_result': True}, + {'option_name': 'CONFIG_NAME_10', 'type': 'kconfig', 'desired_val': 'expected_10', 'decision': 'decision_10', 'reason': 'reason_10', 'check_result_text': 'FAIL: "UNexpected_10"', 'check_result': False}] ) def test_version(self): @@ -402,11 +402,11 @@ class TestEngine(unittest.TestCase): self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK: version >= (41, 101, 0)', 'check_result': True}, - {'option_name': 'CONFIG_NAME_2', 'type': 'kconfig', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: version < (43, 1, 0)', 'check_result': False}, - {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK: version >= (42, 42, 101)', 'check_result': True}, - {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: version < (42, 44, 1)', 'check_result': False}, - {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: version >= (42, 43, 44)', 'check_result': True}, - {'option_name': 'CONFIG_NAME_6', 'type': 'kconfig', 'desired_val': 'expected_6', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: version < (42, 43, 45)', 'check_result': False}] + {'option_name': 'CONFIG_NAME_2', 'type': 'kconfig', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: version < (43, 1, 0)', 'check_result': False}, + {'option_name': 'CONFIG_NAME_3', 'type': 'kconfig', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK: version >= (42, 42, 101)', 'check_result': True}, + {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: version < (42, 44, 1)', 'check_result': False}, + {'option_name': 'CONFIG_NAME_5', 'type': 'kconfig', 'desired_val': 'expected_5', 'decision': 'decision_5', 'reason': 'reason_5', 'check_result_text': 'OK: version >= (42, 43, 44)', 'check_result': True}, + {'option_name': 'CONFIG_NAME_6', 'type': 'kconfig', 'desired_val': 'expected_6', 'decision': 'decision_6', 'reason': 'reason_6', 'check_result_text': 'FAIL: version < (42, 43, 45)', 'check_result': False}] ) def test_stdout(self): @@ -441,7 +441,7 @@ class TestEngine(unittest.TestCase): self.assertEqual( json_result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK: name_2 is "expected_2"', 'check_result': True}, - {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: name_5 is not "expected_5"', 'check_result': False}] + {'option_name': 'CONFIG_NAME_4', 'type': 'kconfig', 'desired_val': 'expected_4', 'decision': 'decision_4', 'reason': 'reason_4', 'check_result_text': 'FAIL: name_5 is not "expected_5"', 'check_result': False}] ) stdout_result = [] @@ -502,8 +502,8 @@ name_6 |sysctl | expected_6 |decision_6| re self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'FAIL: "expected_1_new"', 'check_result': False}, - {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "expected_2_new"', 'check_result': False}, - {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] + {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "expected_2_new"', 'check_result': False}, + {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] ) # 7. override expected value and perform the checks again @@ -516,8 +516,8 @@ name_6 |sysctl | expected_6 |decision_6| re self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1_new', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "expected_2_new"', 'check_result': False}, - {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] + {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'FAIL: "expected_2_new"', 'check_result': False}, + {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] ) # 9. override expected value and perform the checks again @@ -530,8 +530,8 @@ name_6 |sysctl | expected_6 |decision_6| re self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1_new', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2_new', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] + {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2_new', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'OK', 'check_result': True}, + {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'FAIL: "expected_3_new"', 'check_result': False}] ) # 11. override expected value and perform the checks again @@ -544,6 +544,6 @@ name_6 |sysctl | expected_6 |decision_6| re self.assertEqual( result, [{'option_name': 'CONFIG_NAME_1', 'type': 'kconfig', 'desired_val': 'expected_1_new', 'decision': 'decision_1', 'reason': 'reason_1', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2_new', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'OK', 'check_result': True}, - {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3_new', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK', 'check_result': True}] + {'option_name': 'name_2', 'type': 'cmdline', 'desired_val': 'expected_2_new', 'decision': 'decision_2', 'reason': 'reason_2', 'check_result_text': 'OK', 'check_result': True}, + {'option_name': 'name_3', 'type': 'sysctl', 'desired_val': 'expected_3_new', 'decision': 'decision_3', 'reason': 'reason_3', 'check_result_text': 'OK', 'check_result': True}] ) -- 2.31.1