Show git information in the functional test
[kconfig-hardened-check.git] / kconfig_hardened_check / __init__.py
index 7b4993faea3a7f246498c2b0792d8fc28cf2e630..3e4db1c96989a70385becacc6805702e9cbd55a8 100644 (file)
@@ -168,8 +168,8 @@ def parse_kconfig_file(mode, parsed_options, fname):
                 option, value = line[2:].split(' ', 1)
                 assert(value == 'is not set'), \
                        f'unexpected value of disabled Kconfig option "{line}"'
-            elif line != '' and not line.startswith('#') and mode != 'json':
-                print(f'[!] WARNING: strange line in Kconfig file: "{line}"')
+            elif line != '' and not line.startswith('#'):
+                sys.exit(f'[!] ERROR: unexpected line in Kconfig file: "{line}"')
 
             if option in parsed_options:
                 sys.exit(f'[!] ERROR: Kconfig option "{line}" is found multiple times')
@@ -201,11 +201,11 @@ def parse_cmdline_file(mode, parsed_options, fname):
 
 def parse_sysctl_file(mode, parsed_options, fname):
     with open(fname, 'r', encoding='utf-8') as f:
-        sysctl_pattern = re.compile("[a-zA-Z0-9\._-]+ =.*$")
+        sysctl_pattern = re.compile("[a-zA-Z0-9/\._-]+ =.*$")
         for line in f.readlines():
             line = line.strip()
             if not sysctl_pattern.match(line):
-                sys.exit(f'[!] ERROR: unexpected line in sysctl file: {line}')
+                sys.exit(f'[!] ERROR: unexpected line in sysctl file: "{line}"')
             option, value = line.split('=', 1)
             option = option.strip()
             value = value.strip()
@@ -348,6 +348,8 @@ def main():
 
     if args.print:
         assert(args.config is None and args.cmdline is None and args.sysctl is None), 'unexpected args'
+        if args.generate:
+            sys.exit('[!] ERROR: --print and --generate can\'t be used together')
         if mode and mode not in ('verbose', 'json'):
             sys.exit(f'[!] ERROR: wrong mode "{mode}" for --print')
         arch = args.print
@@ -360,7 +362,7 @@ def main():
         sys.exit(0)
 
     if args.generate:
-        assert(args.config is None and args.cmdline is None and args.sysctl 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