1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSelfTest3.py 98651 2023-02-20 13:10:54Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | Test Manager / Suite Self Test #3 - Bad XML input and other Failures.
|
---|
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 common import utils;
|
---|
55 | from testdriver import reporter;
|
---|
56 | from testdriver.base import TestDriverBase;
|
---|
57 |
|
---|
58 |
|
---|
59 | class tdSelfTest3(TestDriverBase):
|
---|
60 | """
|
---|
61 | Test Manager / Suite Self Test #3 - Bad XML input and other Failures.
|
---|
62 | """
|
---|
63 |
|
---|
64 | def __init__(self):
|
---|
65 | TestDriverBase.__init__(self);
|
---|
66 |
|
---|
67 |
|
---|
68 | def actionExecute(self):
|
---|
69 |
|
---|
70 | # Testing PushHint/PopHint.
|
---|
71 | reporter.testStart('Negative XML #1');
|
---|
72 | oSubXmlFile = reporter.FileWrapperTestPipe();
|
---|
73 | oSubXmlFile.write('<Test timestamp="%s" name="foobar3">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),));
|
---|
74 | oSubXmlFile.write('<Test timestamp="%s" name="sub3">' % (utils.getIsoTimestamp(),));
|
---|
75 | oSubXmlFile.write('<Test timestamp="%s" name="subsub1">' % (utils.getIsoTimestamp(),));
|
---|
76 | oSubXmlFile.close();
|
---|
77 | reporter.testDone();
|
---|
78 |
|
---|
79 | # Missing end, like we had with IRPT at one time.
|
---|
80 | reporter.testStart('Negative XML #2 (IPRT)');
|
---|
81 | oSubXmlFile = reporter.FileWrapperTestPipe();
|
---|
82 | oSubXmlFile.write("""
|
---|
83 | <?xml version="1.0" encoding="UTF-8" ?>
|
---|
84 | <Test timestamp="2013-05-29T08:59:05.930602000Z" name="tstRTGetOpt">
|
---|
85 | <Test timestamp="2013-05-29T08:59:05.930656000Z" name="Basics">
|
---|
86 | <Passed timestamp="2013-05-29T08:59:05.930756000Z"/>
|
---|
87 | </Test>
|
---|
88 | <Test timestamp="2013-05-29T08:59:05.930995000Z" name="RTGetOpt - IPv4">
|
---|
89 | <Passed timestamp="2013-05-29T08:59:05.931036000Z"/>
|
---|
90 | </Test>
|
---|
91 | <Test timestamp="2013-05-29T08:59:05.931161000Z" name="RTGetOpt - MAC Address">
|
---|
92 | <Passed timestamp="2013-05-29T08:59:05.931194000Z"/>
|
---|
93 | </Test>
|
---|
94 | <Test timestamp="2013-05-29T08:59:05.931313000Z" name="RTGetOpt - Option w/ Index">
|
---|
95 | <Passed timestamp="2013-05-29T08:59:05.931357000Z"/>
|
---|
96 | </Test>
|
---|
97 | <Test timestamp="2013-05-29T08:59:05.931475000Z" name="RTGetOptFetchValue">
|
---|
98 | <Passed timestamp="2013-05-29T08:59:05.931516000Z"/>
|
---|
99 | </Test>
|
---|
100 | <Test timestamp="2013-05-29T08:59:05.931640000Z" name="RTGetOpt - bool on/off">
|
---|
101 | <Passed timestamp="2013-05-29T08:59:05.931687000Z"/>
|
---|
102 | </Test>
|
---|
103 | <Test timestamp="2013-05-29T08:59:05.931807000Z" name="Standard options">
|
---|
104 | <Passed timestamp="2013-05-29T08:59:05.931843000Z"/>
|
---|
105 | </Test>
|
---|
106 | <Test timestamp="2013-05-29T08:59:05.931963000Z" name="Options first">
|
---|
107 | <Passed timestamp="2013-05-29T08:59:05.932035000Z"/>
|
---|
108 | </Test>
|
---|
109 | """);
|
---|
110 | oSubXmlFile.close();
|
---|
111 | oSubXmlFile = None;
|
---|
112 | reporter.testDone();
|
---|
113 |
|
---|
114 | # The use of testFailure.
|
---|
115 | reporter.testStart('Using testFailure()');
|
---|
116 | reporter.testValue('value-name3', 12345678, 'times');
|
---|
117 | reporter.testFailure('failure detail message');
|
---|
118 | reporter.testDone();
|
---|
119 |
|
---|
120 | return True;
|
---|
121 |
|
---|
122 |
|
---|
123 | if __name__ == '__main__':
|
---|
124 | sys.exit(tdSelfTest3().main(sys.argv));
|
---|
125 |
|
---|