xref: /openbmc/openbmc/poky/scripts/resulttool (revision 393846f1)
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#
28# SPDX-License-Identifier: GPL-2.0-only
29#
30
31import os
32import sys
33import argparse
34import logging
35script_path = os.path.dirname(os.path.realpath(__file__))
36lib_path = script_path + '/lib'
37sys.path = sys.path + [lib_path]
38import argparse_oe
39import scriptutils
40import resulttool.merge
41import resulttool.store
42import resulttool.regression
43import resulttool.report
44import resulttool.manualexecution
45import resulttool.log
46logger = scriptutils.logger_create('resulttool')
47
48def 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)
63    resulttool.log.register_commands(subparsers)
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
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
77if __name__ == "__main__":
78    sys.exit(main())
79