1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tst-a1.py 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | Analyzer Experiment 1.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2020 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 82968 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | import os.path
|
---|
34 | import sys
|
---|
35 |
|
---|
36 | # Only the main script needs to modify the path.
|
---|
37 | try: __file__
|
---|
38 | except: __file__ = sys.argv[0];
|
---|
39 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)));
|
---|
40 | sys.path.append(g_ksValidationKitDir);
|
---|
41 |
|
---|
42 | # Validation Kit imports.
|
---|
43 | from testanalysis import reader ## @todo fix testanalysis/__init__.py.
|
---|
44 | from testanalysis import reporting
|
---|
45 | from testanalysis import diff
|
---|
46 |
|
---|
47 |
|
---|
48 | def usage():
|
---|
49 | """ Display usage """
|
---|
50 | print 'usage: %s [options] <testresults.xml> [baseline.xml]' % (sys.argv[0]);
|
---|
51 | print ''
|
---|
52 | print 'options:'
|
---|
53 | print ' --filter <test-sub-string>'
|
---|
54 | return 1;
|
---|
55 |
|
---|
56 | def main(asArgs):
|
---|
57 | """ C styl main(). """
|
---|
58 | # Parse arguments
|
---|
59 | sTestFile = None;
|
---|
60 | sBaseFile = None;
|
---|
61 | asFilters = [];
|
---|
62 | iArg = 1;
|
---|
63 | while iArg < len(asArgs):
|
---|
64 | if asArgs[iArg] == '--filter':
|
---|
65 | iArg += 1;
|
---|
66 | asFilters.append(asArgs[iArg]);
|
---|
67 | elif asArgs[iArg].startswith('--help'):
|
---|
68 | return usage();
|
---|
69 | elif asArgs[iArg].startswith('--'):
|
---|
70 | print 'syntax error: unknown option "%s"' % (asArgs[iArg]);
|
---|
71 | return usage();
|
---|
72 | elif sTestFile is None:
|
---|
73 | sTestFile = asArgs[iArg];
|
---|
74 | elif sBaseFile is None:
|
---|
75 | sBaseFile = asArgs[iArg];
|
---|
76 | else:
|
---|
77 | print 'syntax error: too many file names: %s' % (asArgs[iArg])
|
---|
78 | return usage();
|
---|
79 | iArg += 1;
|
---|
80 |
|
---|
81 | # Down to business
|
---|
82 | oTestTree = reader.parseTestResult(sTestFile);
|
---|
83 | if oTestTree is None:
|
---|
84 | return 1;
|
---|
85 | oTestTree = oTestTree.filterTests(asFilters)
|
---|
86 |
|
---|
87 | if sBaseFile is not None:
|
---|
88 | oBaseline = reader.parseTestResult(sBaseFile);
|
---|
89 | if oBaseline is None:
|
---|
90 | return 1;
|
---|
91 | oTestTree = diff.baselineDiff(oTestTree, oBaseline);
|
---|
92 | if oTestTree is None:
|
---|
93 | return 1;
|
---|
94 |
|
---|
95 | reporting.produceTextReport(oTestTree);
|
---|
96 | return 0;
|
---|
97 |
|
---|
98 | if __name__ == '__main__':
|
---|
99 | sys.exit(main(sys.argv));
|
---|
100 |
|
---|