Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # test results tool - tool for manipulating OEQA test result json files |
| 4 | # (merge results, summarise results, regression analysis, generate manual test results file) |
| 5 | # |
| 6 | # To look for help information. |
| 7 | # $ resulttool |
| 8 | # |
| 9 | # To store test results from oeqa automated tests, execute the below |
| 10 | # $ resulttool store <source_dir> <git_branch> |
| 11 | # |
| 12 | # To merge test results, execute the below |
| 13 | # $ resulttool merge <base_result_file> <target_result_file> |
| 14 | # |
| 15 | # To report test report, execute the below |
| 16 | # $ resulttool report <source_dir> |
| 17 | # |
| 18 | # To perform regression file analysis, execute the below |
| 19 | # $ resulttool regression-file <base_result_file> <target_result_file> |
| 20 | # |
| 21 | # To execute manual test cases, execute the below |
| 22 | # $ resulttool manualexecution <manualjsonfile> |
| 23 | # |
| 24 | # By default testresults.json for manualexecution store in <build>/tmp/log/manual/ |
| 25 | # |
| 26 | # Copyright (c) 2019, Intel Corporation. |
| 27 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 28 | # SPDX-License-Identifier: GPL-2.0-only |
Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 29 | # |
| 30 | |
| 31 | import os |
| 32 | import sys |
| 33 | import argparse |
| 34 | import logging |
| 35 | script_path = os.path.dirname(os.path.realpath(__file__)) |
| 36 | lib_path = script_path + '/lib' |
| 37 | sys.path = sys.path + [lib_path] |
| 38 | import argparse_oe |
| 39 | import scriptutils |
| 40 | import resulttool.merge |
| 41 | import resulttool.store |
| 42 | import resulttool.regression |
| 43 | import resulttool.report |
| 44 | import resulttool.manualexecution |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 45 | import resulttool.log |
Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 46 | logger = scriptutils.logger_create('resulttool') |
| 47 | |
Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 48 | def main(): |
| 49 | parser = argparse_oe.ArgumentParser(description="OEQA test result manipulation tool.", |
| 50 | epilog="Use %(prog)s <subcommand> --help to get help on a specific command") |
| 51 | parser.add_argument('-d', '--debug', help='enable debug output', action='store_true') |
| 52 | parser.add_argument('-q', '--quiet', help='print only errors', action='store_true') |
| 53 | subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') |
| 54 | subparsers.required = True |
| 55 | subparsers.add_subparser_group('manualexecution', 'manual testcases', 300) |
| 56 | resulttool.manualexecution.register_commands(subparsers) |
| 57 | subparsers.add_subparser_group('setup', 'setup', 200) |
| 58 | resulttool.merge.register_commands(subparsers) |
| 59 | resulttool.store.register_commands(subparsers) |
| 60 | subparsers.add_subparser_group('analysis', 'analysis', 100) |
| 61 | resulttool.regression.register_commands(subparsers) |
| 62 | resulttool.report.register_commands(subparsers) |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 63 | resulttool.log.register_commands(subparsers) |
Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 64 | |
| 65 | args = parser.parse_args() |
| 66 | if args.debug: |
| 67 | logger.setLevel(logging.DEBUG) |
| 68 | elif args.quiet: |
| 69 | logger.setLevel(logging.ERROR) |
| 70 | |
Brad Bishop | 40320b1 | 2019-03-26 16:08:25 -0400 | [diff] [blame] | 71 | try: |
| 72 | ret = args.func(args, logger) |
| 73 | except argparse_oe.ArgumentUsageError as ae: |
| 74 | parser.error_subcommand(ae.message, ae.subcommand) |
| 75 | return ret |
| 76 | |
| 77 | if __name__ == "__main__": |
| 78 | sys.exit(main()) |