1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSelfTest4.py 98651 2023-02-20 13:10:54Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | Test Manager / Suite Self Test #4 - Testing result overflow handling.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
12 |
|
---|
13 | This file is part of VirtualBox base platform packages, as
|
---|
14 | available from https://www.virtualbox.org.
|
---|
15 |
|
---|
16 | This program is free software; you can redistribute it and/or
|
---|
17 | modify it under the terms of the GNU General Public License
|
---|
18 | as published by the Free Software Foundation, in version 3 of the
|
---|
19 | License.
|
---|
20 |
|
---|
21 | This program is distributed in the hope that it will be useful, but
|
---|
22 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
24 | General Public License for more details.
|
---|
25 |
|
---|
26 | You should have received a copy of the GNU General Public License
|
---|
27 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
28 |
|
---|
29 | The contents of this file may alternatively be used under the terms
|
---|
30 | of the Common Development and Distribution License Version 1.0
|
---|
31 | (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
32 | in the VirtualBox distribution, in which case the provisions of the
|
---|
33 | CDDL are applicable instead of those of the GPL.
|
---|
34 |
|
---|
35 | You may elect to license modified versions of this file under the
|
---|
36 | terms and conditions of either the GPL or the CDDL or both.
|
---|
37 |
|
---|
38 | SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
39 | """
|
---|
40 | __version__ = "$Revision: 98651 $"
|
---|
41 |
|
---|
42 |
|
---|
43 | # Standard Python imports.
|
---|
44 | import os;
|
---|
45 | import sys;
|
---|
46 |
|
---|
47 | # Only the main script needs to modify the path.
|
---|
48 | try: __file__ # pylint: disable=used-before-assignment
|
---|
49 | except: __file__ = sys.argv[0];
|
---|
50 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
51 | sys.path.append(g_ksValidationKitDir);
|
---|
52 |
|
---|
53 | # Validation Kit imports.
|
---|
54 | from testdriver import reporter;
|
---|
55 | from testdriver.base import TestDriverBase, InvalidOption;
|
---|
56 |
|
---|
57 |
|
---|
58 | class tdSelfTest4(TestDriverBase):
|
---|
59 | """
|
---|
60 | Test Manager / Suite Self Test #4 - Testing result overflow handling.
|
---|
61 | """
|
---|
62 |
|
---|
63 | ## Valid tests.
|
---|
64 | kasValidTests = [ 'immediate-sub-tests', 'total-sub-tests', 'immediate-values', 'total-values', 'immediate-messages'];
|
---|
65 |
|
---|
66 | def __init__(self):
|
---|
67 | TestDriverBase.__init__(self);
|
---|
68 | self.sOptWhich = 'immediate-sub-tests';
|
---|
69 |
|
---|
70 | def parseOption(self, asArgs, iArg):
|
---|
71 | if asArgs[iArg] == '--test':
|
---|
72 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
73 | if asArgs[iArg] not in self.kasValidTests:
|
---|
74 | raise InvalidOption('Invalid test name "%s". Must be one of: %s'
|
---|
75 | % (asArgs[iArg], ', '.join(self.kasValidTests),));
|
---|
76 | self.sOptWhich = asArgs[iArg];
|
---|
77 | else:
|
---|
78 | return TestDriverBase.parseOption(self, asArgs, iArg);
|
---|
79 | return iArg + 1;
|
---|
80 |
|
---|
81 | def actionExecute(self):
|
---|
82 | # Too many immediate sub-tests.
|
---|
83 | if self.sOptWhich == 'immediate-sub-tests':
|
---|
84 | reporter.testStart('Too many immediate sub-tests (negative)');
|
---|
85 | for i in range(1024):
|
---|
86 | reporter.testStart('subsub%d' % i);
|
---|
87 | reporter.testDone();
|
---|
88 | # Too many sub-tests in total.
|
---|
89 | elif self.sOptWhich == 'total-sub-tests':
|
---|
90 | reporter.testStart('Too many sub-tests (negative)');
|
---|
91 | # 32 * 256 = 2^(5+8) = 2^13 = 8192.
|
---|
92 | for i in range(32):
|
---|
93 | reporter.testStart('subsub%d' % i);
|
---|
94 | for j in range(256):
|
---|
95 | reporter.testStart('subsubsub%d' % j);
|
---|
96 | reporter.testDone();
|
---|
97 | reporter.testDone();
|
---|
98 | # Too many immediate values.
|
---|
99 | elif self.sOptWhich == 'immediate-values':
|
---|
100 | reporter.testStart('Too many immediate values (negative)');
|
---|
101 | for i in range(512):
|
---|
102 | reporter.testValue('value%d' % i, i, 'times');
|
---|
103 | # Too many values in total.
|
---|
104 | elif self.sOptWhich == 'total-values':
|
---|
105 | reporter.testStart('Too many sub-tests (negative)');
|
---|
106 | for i in range(256):
|
---|
107 | reporter.testStart('subsub%d' % i);
|
---|
108 | for j in range(64):
|
---|
109 | reporter.testValue('value%d' % j, i * 10000 + j, 'times');
|
---|
110 | reporter.testDone();
|
---|
111 | # Too many failure reasons (only immediate since the limit is extremely low).
|
---|
112 | elif self.sOptWhich == 'immediate-messages':
|
---|
113 | reporter.testStart('Too many immediate messages (negative)');
|
---|
114 | for i in range(16):
|
---|
115 | reporter.testFailure('Detail %d' % i);
|
---|
116 | else:
|
---|
117 | reporter.testStart('Unknown test %s' % (self.sOptWhich,));
|
---|
118 | reporter.error('Invalid test selected: %s' % (self.sOptWhich,));
|
---|
119 | reporter.testDone();
|
---|
120 | return True;
|
---|
121 |
|
---|
122 |
|
---|
123 | if __name__ == '__main__':
|
---|
124 | sys.exit(tdSelfTest4().main(sys.argv));
|
---|
125 |
|
---|