summaryrefslogtreecommitdiff
path: root/bin/analyze-kconfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/analyze-kconfig.py')
-rwxr-xr-xbin/analyze-kconfig.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index ff220b0..444ea2c 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -24,6 +24,16 @@ def main():
formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__
)
parser.add_argument(
+ "--failing-symbols",
+ action="store_true",
+ help="Show Kconfig symbols related to build failures. Must be used with an experiment result directory.",
+ )
+ parser.add_argument(
+ "--nop-symbols",
+ action="store_true",
+ help="Show Kconfig symbols which are only present in a single configuration. Must be used with an experiment result directory.",
+ )
+ parser.add_argument(
"--export-tree",
type=str,
help="Export decision tree model to file",
@@ -76,6 +86,11 @@ def main():
if os.path.isdir(args.model):
data = KConfigAttributes(args.kconfig_path, args.model)
+ if args.failing_symbols:
+ show_failing_symbols(data)
+ if args.nop_symbols:
+ show_nop_symbols(data)
+
if args.sample_size:
shuffled_data_indices = np.random.permutation(np.arange(len(data.data)))
sample_indices = shuffled_data_indices[: args.sample_size]
@@ -161,5 +176,40 @@ def main():
)
+def show_failing_symbols(data):
+ for symbol in data.symbol_names:
+ failed_true = len(
+ list(filter(lambda config: config[symbol] == True, data.failures))
+ )
+ failed_false = len(
+ list(filter(lambda config: config[symbol] == False, data.failures))
+ )
+ success_true = len(
+ list(filter(lambda config: config[0][symbol] == True, data.data))
+ )
+ success_false = len(
+ list(filter(lambda config: config[0][symbol] == False, data.data))
+ )
+ if success_false == 0 and failed_false > 0:
+ print(f"Setting {symbol} to n reliably causes the build to fail")
+ if success_true == 0 and failed_true > 0:
+ print(f"Setting {symbol} to y reliably causes the build to fail")
+
+
+def show_nop_symbols(data):
+ for symbol in data.symbol_names:
+ true_count = len(
+ list(filter(lambda config: config[symbol] == True, data.failures))
+ ) + len(list(filter(lambda config: config[0][symbol] == True, data.data)))
+ false_count = len(
+ list(filter(lambda config: config[symbol] == False, data.failures))
+ ) + len(list(filter(lambda config: config[0][symbol] == False, data.data)))
+ if false_count == 0:
+ print(f"Symbol {symbol} is never n")
+ if true_count == 0:
+ print(f"Symbol {symbol} is never y")
+ pass
+
+
if __name__ == "__main__":
main()