blob: 5a89e1c9be930f8101765b281082020ed2e9863c [file] [log] [blame]
Brad Bishop40320b12019-03-26 16:08:25 -04001#!/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#
28# This program is free software; you can redistribute it and/or modify it
29# under the terms and conditions of the GNU General Public License,
30# version 2, as published by the Free Software Foundation.
31#
32# This program is distributed in the hope it will be useful, but WITHOUT
33# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
35# more details.
36#
37
38import os
39import sys
40import argparse
41import logging
42script_path = os.path.dirname(os.path.realpath(__file__))
43lib_path = script_path + '/lib'
44sys.path = sys.path + [lib_path]
45import argparse_oe
46import scriptutils
47import resulttool.merge
48import resulttool.store
49import resulttool.regression
50import resulttool.report
51import resulttool.manualexecution
52logger = scriptutils.logger_create('resulttool')
53
54def _validate_user_input_arguments(args):
55 if hasattr(args, "source_dir"):
56 if not os.path.isdir(args.source_dir):
57 logger.error('source_dir argument need to be a directory : %s' % args.source_dir)
58 return False
59 return True
60
61def main():
62 parser = argparse_oe.ArgumentParser(description="OEQA test result manipulation tool.",
63 epilog="Use %(prog)s <subcommand> --help to get help on a specific command")
64 parser.add_argument('-d', '--debug', help='enable debug output', action='store_true')
65 parser.add_argument('-q', '--quiet', help='print only errors', action='store_true')
66 subparsers = parser.add_subparsers(dest="subparser_name", title='subcommands', metavar='<subcommand>')
67 subparsers.required = True
68 subparsers.add_subparser_group('manualexecution', 'manual testcases', 300)
69 resulttool.manualexecution.register_commands(subparsers)
70 subparsers.add_subparser_group('setup', 'setup', 200)
71 resulttool.merge.register_commands(subparsers)
72 resulttool.store.register_commands(subparsers)
73 subparsers.add_subparser_group('analysis', 'analysis', 100)
74 resulttool.regression.register_commands(subparsers)
75 resulttool.report.register_commands(subparsers)
76
77 args = parser.parse_args()
78 if args.debug:
79 logger.setLevel(logging.DEBUG)
80 elif args.quiet:
81 logger.setLevel(logging.ERROR)
82
83 if not _validate_user_input_arguments(args):
84 return -1
85
86 try:
87 ret = args.func(args, logger)
88 except argparse_oe.ArgumentUsageError as ae:
89 parser.error_subcommand(ae.message, ae.subcommand)
90 return ret
91
92if __name__ == "__main__":
93 sys.exit(main())