4 This tool helps me to check Linux kernel options against
5 my security hardening preferences for X86_64, ARM64, X86_32, and ARM.
6 Let the computers do their job!
8 Author: Alexander Popov <alex.popov@linux.com>
10 This module performs unit-testing of the kconfig-hardened-check engine.
14 from collections import OrderedDict
16 from .engine import KconfigCheck, CmdlineCheck, populate_with_data, perform_checks
18 class TestEngine(unittest.TestCase):
20 # add checks to the checklist
22 config_checklist += [KconfigCheck('reason_1', 'decision_1', 'KCONFIG_NAME', 'expected_1')]
23 config_checklist += [CmdlineCheck('reason_2', 'decision_2', 'cmdline_name', 'expected_2')]
25 # populate the checklist with the parsed kconfig data
26 parsed_kconfig_options = OrderedDict()
27 parsed_kconfig_options['CONFIG_KCONFIG_NAME'] = 'UNexpected_1'
28 populate_with_data(config_checklist, parsed_kconfig_options, 'kconfig')
30 # populate the checklist with the parsed cmdline data
31 parsed_cmdline_options = OrderedDict()
32 parsed_cmdline_options['cmdline_name'] = 'expected_2'
33 populate_with_data(config_checklist, parsed_cmdline_options, 'cmdline')
35 # populate the checklist with the kernel version data
36 kernel_version = (42, 43)
37 populate_with_data(config_checklist, kernel_version, 'version')
39 # now everything is ready, perform the checks
40 perform_checks(config_checklist)
42 # print the results in json
45 for opt in config_checklist:
46 output.append(opt.json_dump(True))
47 print(json.dumps(output))
51 for opt in config_checklist:
52 opt.table_print(None, True)
56 self.assertEqual('foo'.upper(), 'FOO')
59 self.assertTrue('FOO'.isupper())