From d7be5114a144fd70f5dee5a9a57a2eac19eeea30 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 24 Sep 2020 10:10:50 +0200 Subject: show failing and nop symbols --- bin/analyze-kconfig.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/explore-kconfig.py | 3 ++- 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'bin') 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 @@ -23,6 +23,16 @@ def main(): parser = argparse.ArgumentParser( 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, @@ -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() diff --git a/bin/explore-kconfig.py b/bin/explore-kconfig.py index 7602076..5b4bdc6 100755 --- a/bin/explore-kconfig.py +++ b/bin/explore-kconfig.py @@ -96,12 +96,13 @@ def main(): for i in range(args.random): logging.info(f"Running randconfig {i+1} of {args.random}") status = kconf.run_randconfig() - if status["success"]: + if args.with_neighbourhood and status["success"]: config_filename = status["config_path"] logging.info(f"Exploring neighbourhood of {config_filename}") kconf.run_exploration_from_file(config_filename) if args.neighbourhood: + # TODO also explore range of numeric options if os.path.isfile(args.neighbourhood): kconf.run_exploration_from_file(args.neighbourhood) elif os.path.isdir(args.neighbourhood): -- cgit v1.2.3