VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/selftests/tdSelfTest4.py@ 103914

Last change on this file since 103914 was 98651, checked in by vboxsync, 22 months ago

ValKit: pylint 2.16.2: checks for file

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdSelfTest4.py 98651 2023-02-20 13:10:54Z vboxsync $
4
5"""
6Test Manager / Suite Self Test #4 - Testing result overflow handling.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2023 Oracle and/or its affiliates.
12
13This file is part of VirtualBox base platform packages, as
14available from https://www.virtualbox.org.
15
16This program is free software; you can redistribute it and/or
17modify it under the terms of the GNU General Public License
18as published by the Free Software Foundation, in version 3 of the
19License.
20
21This program is distributed in the hope that it will be useful, but
22WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, see <https://www.gnu.org/licenses>.
28
29The contents of this file may alternatively be used under the terms
30of the Common Development and Distribution License Version 1.0
31(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
32in the VirtualBox distribution, in which case the provisions of the
33CDDL are applicable instead of those of the GPL.
34
35You may elect to license modified versions of this file under the
36terms and conditions of either the GPL or the CDDL or both.
37
38SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
39"""
40__version__ = "$Revision: 98651 $"
41
42
43# Standard Python imports.
44import os;
45import sys;
46
47# Only the main script needs to modify the path.
48try: __file__ # pylint: disable=used-before-assignment
49except: __file__ = sys.argv[0];
50g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
51sys.path.append(g_ksValidationKitDir);
52
53# Validation Kit imports.
54from testdriver import reporter;
55from testdriver.base import TestDriverBase, InvalidOption;
56
57
58class 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
123if __name__ == '__main__':
124 sys.exit(tdSelfTest4().main(sys.argv));
125
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette