140320b10SBrad Bishop#!/usr/bin/env python3 240320b10SBrad Bishop# 340320b10SBrad Bishop# test results tool - tool for manipulating OEQA test result json files 440320b10SBrad Bishop# (merge results, summarise results, regression analysis, generate manual test results file) 540320b10SBrad Bishop# 640320b10SBrad Bishop# To look for help information. 740320b10SBrad Bishop# $ resulttool 840320b10SBrad Bishop# 940320b10SBrad Bishop# To store test results from oeqa automated tests, execute the below 1040320b10SBrad Bishop# $ resulttool store <source_dir> <git_branch> 1140320b10SBrad Bishop# 1240320b10SBrad Bishop# To merge test results, execute the below 1340320b10SBrad Bishop# $ resulttool merge <base_result_file> <target_result_file> 1440320b10SBrad Bishop# 1540320b10SBrad Bishop# To report test report, execute the below 1640320b10SBrad Bishop# $ resulttool report <source_dir> 1740320b10SBrad Bishop# 1840320b10SBrad Bishop# To perform regression file analysis, execute the below 1940320b10SBrad Bishop# $ resulttool regression-file <base_result_file> <target_result_file> 2040320b10SBrad Bishop# 2140320b10SBrad Bishop# To execute manual test cases, execute the below 2240320b10SBrad Bishop# $ resulttool manualexecution <manualjsonfile> 2340320b10SBrad Bishop# 2440320b10SBrad Bishop# By default testresults.json for manualexecution store in <build>/tmp/log/manual/ 2540320b10SBrad Bishop# 2640320b10SBrad Bishop# Copyright (c) 2019, Intel Corporation. 2740320b10SBrad Bishop# 28*c342db35SBrad Bishop# SPDX-License-Identifier: GPL-2.0-only 2940320b10SBrad Bishop# 3040320b10SBrad Bishop 3140320b10SBrad Bishopimport os 3240320b10SBrad Bishopimport sys 3340320b10SBrad Bishopimport argparse 3440320b10SBrad Bishopimport logging 3540320b10SBrad Bishopscript_path = os.path.dirname(os.path.realpath(__file__)) 3640320b10SBrad Bishoplib_path = script_path + '/lib' 3740320b10SBrad Bishopsys.path = sys.path + [lib_path] 3840320b10SBrad Bishopimport argparse_oe 3940320b10SBrad Bishopimport scriptutils 4040320b10SBrad Bishopimport resulttool.merge 4140320b10SBrad Bishopimport resulttool.store 4240320b10SBrad Bishopimport resulttool.regression 4340320b10SBrad Bishopimport resulttool.report 4440320b10SBrad Bishopimport resulttool.manualexecution 45*c342db35SBrad Bishopimport resulttool.log 4640320b10SBrad Bishoplogger = scriptutils.logger_create('resulttool') 4740320b10SBrad Bishop 4840320b10SBrad Bishopdef main(): 4940320b10SBrad Bishop parser = argparse_oe.ArgumentParser(description="OEQA test result manipulation tool.", 5040320b10SBrad Bishop epilog="Use %(prog)s <subcommand> --help to get help on a specific command") 5140320b10SBrad Bishop parser.add_argument('-d', '--debug', help='enable debug output', action='store_true') 5240320b10SBrad Bishop parser.add_argument('-q', '--quiet', help='print only errors', action='store_true') 5340320b10SBrad Bishop subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>') 5440320b10SBrad Bishop subparsers.required = True 5540320b10SBrad Bishop subparsers.add_subparser_group('manualexecution', 'manual testcases', 300) 5640320b10SBrad Bishop resulttool.manualexecution.register_commands(subparsers) 5740320b10SBrad Bishop subparsers.add_subparser_group('setup', 'setup', 200) 5840320b10SBrad Bishop resulttool.merge.register_commands(subparsers) 5940320b10SBrad Bishop resulttool.store.register_commands(subparsers) 6040320b10SBrad Bishop subparsers.add_subparser_group('analysis', 'analysis', 100) 6140320b10SBrad Bishop resulttool.regression.register_commands(subparsers) 6240320b10SBrad Bishop resulttool.report.register_commands(subparsers) 63*c342db35SBrad Bishop resulttool.log.register_commands(subparsers) 6440320b10SBrad Bishop 6540320b10SBrad Bishop args = parser.parse_args() 6640320b10SBrad Bishop if args.debug: 6740320b10SBrad Bishop logger.setLevel(logging.DEBUG) 6840320b10SBrad Bishop elif args.quiet: 6940320b10SBrad Bishop logger.setLevel(logging.ERROR) 7040320b10SBrad Bishop 7140320b10SBrad Bishop try: 7240320b10SBrad Bishop ret = args.func(args, logger) 7340320b10SBrad Bishop except argparse_oe.ArgumentUsageError as ae: 7440320b10SBrad Bishop parser.error_subcommand(ae.message, ae.subcommand) 7540320b10SBrad Bishop return ret 7640320b10SBrad Bishop 7740320b10SBrad Bishopif __name__ == "__main__": 7840320b10SBrad Bishop sys.exit(main()) 79