1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSelfTest4.py 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | Test Manager / Suite Self Test #4 - Testing result overflow handling.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2019 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: 76553 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import os;
|
---|
35 | import sys;
|
---|
36 |
|
---|
37 | # Only the main script needs to modify the path.
|
---|
38 | try: __file__
|
---|
39 | except: __file__ = sys.argv[0];
|
---|
40 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
41 | sys.path.append(g_ksValidationKitDir);
|
---|
42 |
|
---|
43 | # Validation Kit imports.
|
---|
44 | from testdriver import reporter;
|
---|
45 | from testdriver.base import TestDriverBase, InvalidOption;
|
---|
46 |
|
---|
47 |
|
---|
48 | class tdSelfTest4(TestDriverBase):
|
---|
49 | """
|
---|
50 | Test Manager / Suite Self Test #4 - Testing result overflow handling.
|
---|
51 | """
|
---|
52 |
|
---|
53 | ## Valid tests.
|
---|
54 | kasValidTests = [ 'immediate-sub-tests', 'total-sub-tests', 'immediate-values', 'total-values', 'immediate-messages'];
|
---|
55 |
|
---|
56 | def __init__(self):
|
---|
57 | TestDriverBase.__init__(self);
|
---|
58 | self.sOptWhich = 'immediate-sub-tests';
|
---|
59 |
|
---|
60 | def parseOption(self, asArgs, iArg):
|
---|
61 | if asArgs[iArg] == '--test':
|
---|
62 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
63 | if asArgs[iArg] not in self.kasValidTests:
|
---|
64 | raise InvalidOption('Invalid test name "%s". Must be one of: %s'
|
---|
65 | % (asArgs[iArg], ', '.join(self.kasValidTests),));
|
---|
66 | self.sOptWhich = asArgs[iArg];
|
---|
67 | else:
|
---|
68 | return TestDriverBase.parseOption(self, asArgs, iArg);
|
---|
69 | return iArg + 1;
|
---|
70 |
|
---|
71 | def actionExecute(self):
|
---|
72 | # Too many immediate sub-tests.
|
---|
73 | if self.sOptWhich == 'immediate-sub-tests':
|
---|
74 | reporter.testStart('Too many immediate sub-tests (negative)');
|
---|
75 | for i in range(1024):
|
---|
76 | reporter.testStart('subsub%d' % i);
|
---|
77 | reporter.testDone();
|
---|
78 | # Too many sub-tests in total.
|
---|
79 | elif self.sOptWhich == 'total-sub-tests':
|
---|
80 | reporter.testStart('Too many sub-tests (negative)');
|
---|
81 | # 32 * 256 = 2^(5+8) = 2^13 = 8192.
|
---|
82 | for i in range(32):
|
---|
83 | reporter.testStart('subsub%d' % i);
|
---|
84 | for j in range(256):
|
---|
85 | reporter.testStart('subsubsub%d' % j);
|
---|
86 | reporter.testDone();
|
---|
87 | reporter.testDone();
|
---|
88 | # Too many immediate values.
|
---|
89 | elif self.sOptWhich == 'immediate-values':
|
---|
90 | reporter.testStart('Too many immediate values (negative)');
|
---|
91 | for i in range(512):
|
---|
92 | reporter.testValue('value%d' % i, i, 'times');
|
---|
93 | # Too many values in total.
|
---|
94 | elif self.sOptWhich == 'total-values':
|
---|
95 | reporter.testStart('Too many sub-tests (negative)');
|
---|
96 | for i in range(256):
|
---|
97 | reporter.testStart('subsub%d' % i);
|
---|
98 | for j in range(64):
|
---|
99 | reporter.testValue('value%d' % j, i * 10000 + j, 'times');
|
---|
100 | reporter.testDone();
|
---|
101 | # Too many failure reasons (only immediate since the limit is extremely low).
|
---|
102 | elif self.sOptWhich == 'immediate-messages':
|
---|
103 | reporter.testStart('Too many immediate messages (negative)');
|
---|
104 | for i in range(16):
|
---|
105 | reporter.testFailure('Detail %d' % i);
|
---|
106 | else:
|
---|
107 | reporter.testStart('Unknown test %s' % (self.sOptWhich,));
|
---|
108 | reporter.error('Invalid test selected: %s' % (self.sOptWhich,));
|
---|
109 | reporter.testDone();
|
---|
110 | return True;
|
---|
111 |
|
---|
112 |
|
---|
113 | if __name__ == '__main__':
|
---|
114 | sys.exit(tdSelfTest4().main(sys.argv));
|
---|
115 |
|
---|