import json
from .__about__ import __version__
from .checks import add_kconfig_checks, add_cmdline_checks, normalize_cmdline_options, add_sysctl_checks
-from .engine import StrOrNone, TupleOrNone, populate_with_data, perform_checks, override_expected_value
+from .engine import StrOrNone, TupleOrNone, ChecklistObjType, print_unknown_options, populate_with_data, perform_checks, override_expected_value
def _open(file: str, *args, **kwargs) -> TextIO:
sys.exit(f'[!] ERROR: invalid GCC_VERSION and CLANG_VERSION: {gcc_version} {clang_version}')
-def print_unknown_options(checklist: List, parsed_options: OrderedDict[str, str], opt_type: str) -> None:
- known_options = []
-
- for o1 in checklist:
- if o1.opt_type != 'complex':
- known_options.append(o1.name)
- continue
- for o2 in o1.opts:
- if o2.opt_type != 'complex':
- if hasattr(o2, 'name'):
- known_options.append(o2.name)
- continue
- for o3 in o2.opts:
- assert(o3.opt_type != 'complex'), \
- f'unexpected ComplexOptCheck inside {o2.name}'
- if hasattr(o3, 'name'):
- known_options.append(o3.name)
-
- for option, value in parsed_options.items():
- if option not in known_options:
- print(f'[?] No check for {opt_type} option {option} ({value})')
-
-
-def print_checklist(mode: StrOrNone, checklist: List, with_results: bool) -> None:
+def print_checklist(mode: StrOrNone, checklist: List[ChecklistObjType], with_results: bool) -> None:
if mode == 'json':
output = []
for opt in checklist:
print('=' * sep_line_len)
# table contents
+ ok_count = 0
+ fail_count = 0
for opt in checklist:
if with_results:
- if mode == 'show_ok':
- if not opt.result.startswith('OK'):
+ assert(opt.result), f'unexpected empty result of {opt.name} check'
+ if opt.result.startswith('OK'):
+ ok_count += 1
+ if mode == 'show_fail':
continue
- if mode == 'show_fail':
- if not opt.result.startswith('FAIL'):
+ elif opt.result.startswith('FAIL'):
+ fail_count += 1
+ if mode == 'show_ok':
continue
+ else:
+ assert(False), f'unexpected result "{opt.result}" of {opt.name} check'
opt.table_print(mode, with_results)
print()
if mode == 'verbose':
# final score
if with_results:
- fail_count = len(list(filter(lambda opt: opt.result.startswith('FAIL'), checklist)))
fail_suppressed = ''
- ok_count = len(list(filter(lambda opt: opt.result.startswith('OK'), checklist)))
ok_suppressed = ''
if mode == 'show_ok':
fail_suppressed = ' (suppressed in output)'
if mode != 'json':
print(f'[+] Special report mode: {mode}')
- config_checklist = [] # type: List
+ config_checklist = [] # type: List[ChecklistObjType]
if args.config:
if args.print:
if mode and mode not in ('verbose', 'json'):
sys.exit(f'[!] ERROR: wrong mode "{mode}" for --print')
arch = args.print
- assert arch, 'unexpected empty arch from ArgumentParser'
+ assert(arch), 'unexpected empty arch from ArgumentParser'
add_kconfig_checks(config_checklist, arch)
add_cmdline_checks(config_checklist, arch)
add_sysctl_checks(config_checklist, arch)
sys.exit(0)
if args.generate:
- assert(args.config is None and args.cmdline is None and args.sysctl is None and args.print is None), 'unexpected args'
+ assert(args.config is None and
+ args.cmdline is None and
+ args.sysctl is None and
+ args.print is None), \
+ 'unexpected args'
if mode:
sys.exit(f'[!] ERROR: wrong mode "{mode}" for --generate')
arch = args.generate
- assert arch, 'unexpected empty arch from ArgumentParser'
+ assert(arch), 'unexpected empty arch from ArgumentParser'
add_kconfig_checks(config_checklist, arch)
print(f'CONFIG_{arch}=y') # the Kconfig fragment should describe the microarchitecture
for opt in config_checklist: