1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSmokeTest1.py 98651 2023-02-20 13:10:54Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Smoke Test #1.
|
---|
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 testdriver import reporter;
|
---|
55 | from testdriver import base;
|
---|
56 | from testdriver import vbox;
|
---|
57 | from testdriver import vboxcon;
|
---|
58 |
|
---|
59 |
|
---|
60 | class tdSmokeTest1(vbox.TestDriver):
|
---|
61 | """
|
---|
62 | VBox Smoke Test #1.
|
---|
63 | """
|
---|
64 |
|
---|
65 | def __init__(self):
|
---|
66 | vbox.TestDriver.__init__(self);
|
---|
67 | self.asRsrcs = None;
|
---|
68 | self.oTestVmSet = self.oTestVmManager.getSmokeVmSet();
|
---|
69 | self.sNicAttachmentDef = 'mixed';
|
---|
70 | self.sNicAttachment = self.sNicAttachmentDef;
|
---|
71 | self.fQuick = False;
|
---|
72 |
|
---|
73 | #
|
---|
74 | # Overridden methods.
|
---|
75 | #
|
---|
76 | def showUsage(self):
|
---|
77 | rc = vbox.TestDriver.showUsage(self);
|
---|
78 | reporter.log('');
|
---|
79 | reporter.log('Smoke Test #1 options:');
|
---|
80 | reporter.log(' --nic-attachment <bridged|nat|mixed>');
|
---|
81 | reporter.log(' Default: %s' % (self.sNicAttachmentDef));
|
---|
82 | reporter.log(' --quick');
|
---|
83 | reporter.log(' Very selective testing.')
|
---|
84 | return rc;
|
---|
85 |
|
---|
86 | def parseOption(self, asArgs, iArg):
|
---|
87 | if asArgs[iArg] == '--nic-attachment':
|
---|
88 | iArg += 1;
|
---|
89 | if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-attachment" takes an argument');
|
---|
90 | self.sNicAttachment = asArgs[iArg];
|
---|
91 | if self.sNicAttachment not in ('bridged', 'nat', 'mixed'):
|
---|
92 | raise base.InvalidOption('The "--nic-attachment" value "%s" is not supported. Valid values are: bridged, nat' \
|
---|
93 | % (self.sNicAttachment));
|
---|
94 | elif asArgs[iArg] == '--quick':
|
---|
95 | # Disable all but a few VMs and configurations.
|
---|
96 | for oTestVm in self.oTestVmSet.aoTestVms:
|
---|
97 | if oTestVm.sVmName == 'tst-win2k3ent': # 32-bit paging
|
---|
98 | oTestVm.asVirtModesSup = [ 'hwvirt' ];
|
---|
99 | oTestVm.acCpusSup = range(1, 2);
|
---|
100 | elif oTestVm.sVmName == 'tst-rhel5': # 32-bit paging
|
---|
101 | oTestVm.asVirtModesSup = [ 'raw' ];
|
---|
102 | oTestVm.acCpusSup = range(1, 2);
|
---|
103 | elif oTestVm.sVmName == 'tst-win2k8': # 64-bit
|
---|
104 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
105 | oTestVm.acCpusSup = range(1, 2);
|
---|
106 | elif oTestVm.sVmName == 'tst-sol10-64': # SMP, 64-bit
|
---|
107 | oTestVm.asVirtModesSup = [ 'hwvirt' ];
|
---|
108 | oTestVm.acCpusSup = range(2, 3);
|
---|
109 | elif oTestVm.sVmName == 'tst-sol10': # SMP, 32-bit
|
---|
110 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
111 | oTestVm.acCpusSup = range(2, 3);
|
---|
112 | elif oTestVm.sVmName == 'tst-nsthwvirt-ubuntu-64': # Nested hw.virt, 64-bit
|
---|
113 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
114 | oTestVm.acCpusSup = range(1, 2);
|
---|
115 | else:
|
---|
116 | oTestVm.fSkip = True;
|
---|
117 | else:
|
---|
118 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
119 | return iArg + 1;
|
---|
120 |
|
---|
121 | def actionVerify(self):
|
---|
122 | if self.sVBoxValidationKitIso is None or not os.path.isfile(self.sVBoxValidationKitIso):
|
---|
123 | reporter.error('Cannot find the VBoxValidationKit.iso! (%s)'
|
---|
124 | 'Please unzip a Validation Kit build in the current directory or in some parent one.'
|
---|
125 | % (self.sVBoxValidationKitIso,) );
|
---|
126 | return False;
|
---|
127 | return vbox.TestDriver.actionVerify(self);
|
---|
128 |
|
---|
129 | def actionConfig(self):
|
---|
130 | # Make sure vboxapi has been imported so we can use the constants.
|
---|
131 | if not self.importVBoxApi():
|
---|
132 | return False;
|
---|
133 |
|
---|
134 | # Do the configuring.
|
---|
135 | if self.sNicAttachment == 'nat': eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
|
---|
136 | elif self.sNicAttachment == 'bridged': eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
|
---|
137 | else: eNic0AttachType = None;
|
---|
138 | assert self.sVBoxValidationKitIso is not None;
|
---|
139 | return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, sDvdImage = self.sVBoxValidationKitIso);
|
---|
140 |
|
---|
141 | def actionExecute(self):
|
---|
142 | """
|
---|
143 | Execute the testcase.
|
---|
144 | """
|
---|
145 | return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
|
---|
146 |
|
---|
147 |
|
---|
148 | #
|
---|
149 | # Test execution helpers.
|
---|
150 | #
|
---|
151 |
|
---|
152 | def testOneVmConfig(self, oVM, oTestVm):
|
---|
153 | """
|
---|
154 | Runs the specified VM thru test #1.
|
---|
155 | """
|
---|
156 |
|
---|
157 | # Simple test.
|
---|
158 | self.logVmInfo(oVM);
|
---|
159 | # Try waiting for a bit longer (15 minutes) until the CD is available to avoid running into timeouts.
|
---|
160 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True, cMsCdWait = 15 * 60 * 1000);
|
---|
161 | if oSession is not None:
|
---|
162 | self.addTask(oTxsSession);
|
---|
163 |
|
---|
164 | ## @todo do some quick tests: save, restore, execute some test program, shut down the guest.
|
---|
165 |
|
---|
166 | # cleanup.
|
---|
167 | self.removeTask(oTxsSession);
|
---|
168 | self.terminateVmBySession(oSession)
|
---|
169 | return True;
|
---|
170 | return None;
|
---|
171 |
|
---|
172 | if __name__ == '__main__':
|
---|
173 | sys.exit(tdSmokeTest1().main(sys.argv));
|
---|