diff options
Diffstat (limited to 'scripts/resulttool')
| -rwxr-xr-x | scripts/resulttool | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/scripts/resulttool b/scripts/resulttool new file mode 100755 index 0000000000..ebb5fc81c9 --- /dev/null +++ b/scripts/resulttool | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | # | ||
| 3 | # test results tool - tool for testresults.json (merge test results, regression analysis) | ||
| 4 | # | ||
| 5 | # To look for help information. | ||
| 6 | # $ resulttool | ||
| 7 | # | ||
| 8 | # To store test result from oeqa automated tests, execute the below | ||
| 9 | # $ resulttool store <source_dir> <git_branch> | ||
| 10 | # | ||
| 11 | # To merge test results, execute the below | ||
| 12 | # $ resulttool merge <base_result_file> <target_result_file> | ||
| 13 | # | ||
| 14 | # To report test report, execute the below | ||
| 15 | # $ resulttool report <source_dir> | ||
| 16 | # | ||
| 17 | # To perform regression file analysis, execute the below | ||
| 18 | # $ resulttool regression-file <base_result_file> <target_result_file> | ||
| 19 | # | ||
| 20 | # Copyright (c) 2019, Intel Corporation. | ||
| 21 | # | ||
| 22 | # This program is free software; you can redistribute it and/or modify it | ||
| 23 | # under the terms and conditions of the GNU General Public License, | ||
| 24 | # version 2, as published by the Free Software Foundation. | ||
| 25 | # | ||
| 26 | # This program is distributed in the hope it will be useful, but WITHOUT | ||
| 27 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 28 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 29 | # more details. | ||
| 30 | # | ||
| 31 | |||
| 32 | import os | ||
| 33 | import sys | ||
| 34 | import argparse | ||
| 35 | import logging | ||
| 36 | script_path = os.path.dirname(os.path.realpath(__file__)) | ||
| 37 | lib_path = script_path + '/lib' | ||
| 38 | sys.path = sys.path + [lib_path] | ||
| 39 | import argparse_oe | ||
| 40 | import scriptutils | ||
| 41 | import resulttool.merge | ||
| 42 | import resulttool.store | ||
| 43 | import resulttool.regression | ||
| 44 | import resulttool.report | ||
| 45 | logger = scriptutils.logger_create('resulttool') | ||
| 46 | |||
| 47 | def _validate_user_input_arguments(args): | ||
| 48 | if hasattr(args, "source_dir"): | ||
| 49 | if not os.path.isdir(args.source_dir): | ||
| 50 | logger.error('source_dir argument need to be a directory : %s' % args.source_dir) | ||
| 51 | return False | ||
| 52 | return True | ||
| 53 | |||
| 54 | def main(): | ||
| 55 | parser = argparse_oe.ArgumentParser(description="OpenEmbedded test results tool.", | ||
| 56 | epilog="Use %(prog)s <subcommand> --help to get help on a specific command") | ||
| 57 | parser.add_argument('-d', '--debug', help='enable debug output', action='store_true') | ||
| 58 | parser.add_argument('-q', '--quiet', help='print only errors', action='store_true') | ||
| 59 | subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') | ||
| 60 | subparsers.required = True | ||
| 61 | subparsers.add_subparser_group('setup', 'setup', 200) | ||
| 62 | resulttool.merge.register_commands(subparsers) | ||
| 63 | resulttool.store.register_commands(subparsers) | ||
| 64 | subparsers.add_subparser_group('analysis', 'analysis', 100) | ||
| 65 | resulttool.regression.register_commands(subparsers) | ||
| 66 | resulttool.report.register_commands(subparsers) | ||
| 67 | |||
| 68 | args = parser.parse_args() | ||
| 69 | if args.debug: | ||
| 70 | logger.setLevel(logging.DEBUG) | ||
| 71 | elif args.quiet: | ||
| 72 | logger.setLevel(logging.ERROR) | ||
| 73 | |||
| 74 | if not _validate_user_input_arguments(args): | ||
| 75 | return -1 | ||
| 76 | |||
| 77 | try: | ||
| 78 | ret = args.func(args, logger) | ||
| 79 | except argparse_oe.ArgumentUsageError as ae: | ||
| 80 | parser.error_subcommand(ae.message, ae.subcommand) | ||
| 81 | return ret | ||
| 82 | |||
| 83 | if __name__ == "__main__": | ||
| 84 | sys.exit(main()) | ||
