VirtualBox

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

Last change on this file since 76583 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdSelfTest4.py 76553 2019-01-01 01:45:53Z vboxsync $
4
5"""
6Test Manager / Suite Self Test #4 - Testing result overflow handling.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2019 Oracle Corporation
12
13This file is part of VirtualBox Open Source Edition (OSE), as
14available from http://www.virtualbox.org. This file is free software;
15you can redistribute it and/or modify it under the terms of the GNU
16General Public License (GPL) as published by the Free Software
17Foundation, in version 2 as it comes in the "COPYING" file of the
18VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
21The contents of this file may alternatively be used under the terms
22of the Common Development and Distribution License Version 1.0
23(CDDL) only, as it comes in the "COPYING.CDDL" file of the
24VirtualBox OSE distribution, in which case the provisions of the
25CDDL are applicable instead of those of the GPL.
26
27You may elect to license modified versions of this file under the
28terms and conditions of either the GPL or the CDDL or both.
29"""
30__version__ = "$Revision: 76553 $"
31
32
33# Standard Python imports.
34import os;
35import sys;
36
37# Only the main script needs to modify the path.
38try: __file__
39except: __file__ = sys.argv[0];
40g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
41sys.path.append(g_ksValidationKitDir);
42
43# Validation Kit imports.
44from testdriver import reporter;
45from testdriver.base import TestDriverBase, InvalidOption;
46
47
48class 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
113if __name__ == '__main__':
114 sys.exit(tdSelfTest4().main(sys.argv));
115
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