Improve the OR result calculation
authorAlexander Popov <alex.popov@linux.com>
Tue, 24 Jul 2018 22:36:25 +0000 (01:36 +0300)
committerAlexander Popov <alex.popov@linux.com>
Tue, 24 Jul 2018 22:36:25 +0000 (01:36 +0300)
1. don't duplicate opts[0].name in the successful output;
2. fix the bug with printing None state, just reuse the OptCheck.result.

kconfig-hardened-check.py

index 8d1ecdf4fbeeb09caedea11f48ee08dc82161dad..e8b846cd142540727490c0ffe1dfc23140b7ba81 100755 (executable)
@@ -83,12 +83,15 @@ class OR:
         return self.opts[0].reason
 
     def check(self):
-        for opt in self.opts:
+        for i, opt in enumerate(self.opts):
             result, msg = opt.check()
             if result:
-                self.result = 'OK (CONFIG_{} {})'.format(opt.name, opt.state)
-                return result, self.result
-        self.result = 'FAIL: "{}"'.format(self.opts[0].state)
+                if i == 0:
+                    self.result = opt.result
+                else:
+                    self.result = 'CONFIG_{}: {} ("{}")'.format(opt.name, opt.result, opt.expected)
+                return True, self.result
+        self.result = self.opts[0].result
         return False, self.result