1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSelfTest2.py 98651 2023-02-20 13:10:54Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | Test Manager / Suite Self Test #2 - Everything should succeed.
|
---|
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 tdSelfTest2(TestDriverBase):
|
---|
60 | """
|
---|
61 | Test Manager / Suite Self Test #2 - Everything should succeed.
|
---|
62 | """
|
---|
63 |
|
---|
64 | def __init__(self):
|
---|
65 | TestDriverBase.__init__(self);
|
---|
66 |
|
---|
67 |
|
---|
68 | def actionExecute(self):
|
---|
69 | reporter.testStart('reporter.testXXXX API');
|
---|
70 | reporter.testValue('value-name1', 123456789, 'ms');
|
---|
71 |
|
---|
72 | reporter.testStart('subtest');
|
---|
73 | reporter.testValue('value-name2', 11223344, 'times');
|
---|
74 | reporter.testDone();
|
---|
75 |
|
---|
76 | reporter.testStart('subtest2');
|
---|
77 | reporter.testValue('value-name3', 39, 'sec');
|
---|
78 | reporter.testValue('value-name4', 42, 'ns');
|
---|
79 | reporter.testDone();
|
---|
80 |
|
---|
81 | reporter.testStart('subtest3');
|
---|
82 | reporter.testDone(fSkipped = True);
|
---|
83 |
|
---|
84 | # No spaces in XML.
|
---|
85 | reporter.testStart('subtest4');
|
---|
86 | oSubXmlFile = reporter.FileWrapperTestPipe();
|
---|
87 | oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>');
|
---|
88 | oSubXmlFile.write('<Test timestamp="%s" name="foobar1">' % (utils.getIsoTimestamp(),));
|
---|
89 | oSubXmlFile.write('<Test timestamp="%s" name="sub1">' % (utils.getIsoTimestamp(),));
|
---|
90 | oSubXmlFile.write('<Passed timestamp="%s"/>' % (utils.getIsoTimestamp(),));
|
---|
91 | oSubXmlFile.write('</Test>');
|
---|
92 | oSubXmlFile.write('<End timestamp="%s" errors="0"/>' % (utils.getIsoTimestamp(),));
|
---|
93 | oSubXmlFile.write('</Test>');
|
---|
94 | oSubXmlFile.close();
|
---|
95 | oSubXmlFile = None;
|
---|
96 | reporter.testDone();
|
---|
97 |
|
---|
98 | # Spaces + funny line endings.
|
---|
99 | reporter.testStart('subtest5');
|
---|
100 | oSubXmlFile = reporter.FileWrapperTestPipe();
|
---|
101 | oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>\r\n');
|
---|
102 | oSubXmlFile.write('<Test timestamp="%s" name="foobar2">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),));
|
---|
103 | oSubXmlFile.write('<Test timestamp="%s" name="sub2">' % (utils.getIsoTimestamp(),));
|
---|
104 | oSubXmlFile.write(' <Passed timestamp="%s"/>\n' % (utils.getIsoTimestamp(),));
|
---|
105 | oSubXmlFile.write(' </Test>\n');
|
---|
106 | oSubXmlFile.write(' <End timestamp="%s" errors="0"/>\r' % (utils.getIsoTimestamp(),));
|
---|
107 | oSubXmlFile.write('</Test>');
|
---|
108 | oSubXmlFile.close();
|
---|
109 | reporter.testDone();
|
---|
110 |
|
---|
111 | # A few long log times for WUI log testing.
|
---|
112 | reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \
|
---|
113 | 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \
|
---|
114 | 'asdlkfj aljkasdflkj alkjdsf lakjsdf');
|
---|
115 | reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \
|
---|
116 | 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \
|
---|
117 | 'asdlkfj aljkasdflkj alkjdsf lakjsdf');
|
---|
118 | reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \
|
---|
119 | 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \
|
---|
120 | 'asdlkfj aljkasdflkj alkjdsf lakjsdf');
|
---|
121 |
|
---|
122 | # Upload a file.
|
---|
123 | reporter.addLogFile(__file__, sKind = 'log/release/vm');
|
---|
124 |
|
---|
125 | reporter.testDone();
|
---|
126 | return True;
|
---|
127 |
|
---|
128 |
|
---|
129 | if __name__ == '__main__':
|
---|
130 | sys.exit(tdSelfTest2().main(sys.argv));
|
---|
131 |
|
---|