1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdSmokeTest1.py 95780 2022-07-21 15:41:55Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Smoke Test #1.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2022 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 95780 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import os;
|
---|
35 | import sys;
|
---|
36 |
|
---|
37 | # Only the main script needs to modify the path.
|
---|
38 | try: __file__
|
---|
39 | except: __file__ = sys.argv[0];
|
---|
40 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
41 | sys.path.append(g_ksValidationKitDir);
|
---|
42 |
|
---|
43 | # Validation Kit imports.
|
---|
44 | from testdriver import reporter;
|
---|
45 | from testdriver import base;
|
---|
46 | from testdriver import vbox;
|
---|
47 | from testdriver import vboxcon;
|
---|
48 |
|
---|
49 |
|
---|
50 | class tdSmokeTest1(vbox.TestDriver):
|
---|
51 | """
|
---|
52 | VBox Smoke Test #1.
|
---|
53 | """
|
---|
54 |
|
---|
55 | def __init__(self):
|
---|
56 | vbox.TestDriver.__init__(self);
|
---|
57 | self.asRsrcs = None;
|
---|
58 | self.oTestVmSet = self.oTestVmManager.getSmokeVmSet();
|
---|
59 | self.sNicAttachmentDef = 'mixed';
|
---|
60 | self.sNicAttachment = self.sNicAttachmentDef;
|
---|
61 | self.fQuick = False;
|
---|
62 |
|
---|
63 | #
|
---|
64 | # Overridden methods.
|
---|
65 | #
|
---|
66 | def showUsage(self):
|
---|
67 | rc = vbox.TestDriver.showUsage(self);
|
---|
68 | reporter.log('');
|
---|
69 | reporter.log('Smoke Test #1 options:');
|
---|
70 | reporter.log(' --nic-attachment <bridged|nat|mixed>');
|
---|
71 | reporter.log(' Default: %s' % (self.sNicAttachmentDef));
|
---|
72 | reporter.log(' --quick');
|
---|
73 | reporter.log(' Very selective testing.')
|
---|
74 | return rc;
|
---|
75 |
|
---|
76 | def parseOption(self, asArgs, iArg):
|
---|
77 | if asArgs[iArg] == '--nic-attachment':
|
---|
78 | iArg += 1;
|
---|
79 | if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-attachment" takes an argument');
|
---|
80 | self.sNicAttachment = asArgs[iArg];
|
---|
81 | if self.sNicAttachment not in ('bridged', 'nat', 'mixed'):
|
---|
82 | raise base.InvalidOption('The "--nic-attachment" value "%s" is not supported. Valid values are: bridged, nat' \
|
---|
83 | % (self.sNicAttachment));
|
---|
84 | elif asArgs[iArg] == '--quick':
|
---|
85 | # Disable all but a few VMs and configurations.
|
---|
86 | for oTestVm in self.oTestVmSet.aoTestVms:
|
---|
87 | if oTestVm.sVmName == 'tst-win2k3ent': # 32-bit paging
|
---|
88 | oTestVm.asVirtModesSup = [ 'hwvirt' ];
|
---|
89 | oTestVm.acCpusSup = range(1, 2);
|
---|
90 | elif oTestVm.sVmName == 'tst-rhel5': # 32-bit paging
|
---|
91 | oTestVm.asVirtModesSup = [ 'raw' ];
|
---|
92 | oTestVm.acCpusSup = range(1, 2);
|
---|
93 | elif oTestVm.sVmName == 'tst-win2k8': # 64-bit
|
---|
94 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
95 | oTestVm.acCpusSup = range(1, 2);
|
---|
96 | elif oTestVm.sVmName == 'tst-sol10-64': # SMP, 64-bit
|
---|
97 | oTestVm.asVirtModesSup = [ 'hwvirt' ];
|
---|
98 | oTestVm.acCpusSup = range(2, 3);
|
---|
99 | elif oTestVm.sVmName == 'tst-sol10': # SMP, 32-bit
|
---|
100 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
101 | oTestVm.acCpusSup = range(2, 3);
|
---|
102 | elif oTestVm.sVmName == 'tst-nsthwvirt-ubuntu-64': # Nested hw.virt, 64-bit
|
---|
103 | oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
|
---|
104 | oTestVm.acCpusSup = range(1, 2);
|
---|
105 | else:
|
---|
106 | oTestVm.fSkip = True;
|
---|
107 | else:
|
---|
108 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
109 | return iArg + 1;
|
---|
110 |
|
---|
111 | def actionVerify(self):
|
---|
112 | if self.sVBoxValidationKitIso is None or not os.path.isfile(self.sVBoxValidationKitIso):
|
---|
113 | reporter.error('Cannot find the VBoxValidationKit.iso! (%s)'
|
---|
114 | 'Please unzip a Validation Kit build in the current directory or in some parent one.'
|
---|
115 | % (self.sVBoxValidationKitIso,) );
|
---|
116 | return False;
|
---|
117 | return vbox.TestDriver.actionVerify(self);
|
---|
118 |
|
---|
119 | def actionConfig(self):
|
---|
120 | # Make sure vboxapi has been imported so we can use the constants.
|
---|
121 | if not self.importVBoxApi():
|
---|
122 | return False;
|
---|
123 |
|
---|
124 | # Do the configuring.
|
---|
125 | if self.sNicAttachment == 'nat': eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
|
---|
126 | elif self.sNicAttachment == 'bridged': eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
|
---|
127 | else: eNic0AttachType = None;
|
---|
128 | assert self.sVBoxValidationKitIso is not None;
|
---|
129 | return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, sDvdImage = self.sVBoxValidationKitIso);
|
---|
130 |
|
---|
131 | def actionExecute(self):
|
---|
132 | """
|
---|
133 | Execute the testcase.
|
---|
134 | """
|
---|
135 | return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
|
---|
136 |
|
---|
137 |
|
---|
138 | #
|
---|
139 | # Test execution helpers.
|
---|
140 | #
|
---|
141 |
|
---|
142 | def testOneVmConfig(self, oVM, oTestVm):
|
---|
143 | """
|
---|
144 | Runs the specified VM thru test #1.
|
---|
145 | """
|
---|
146 |
|
---|
147 | # Simple test.
|
---|
148 | self.logVmInfo(oVM);
|
---|
149 | # Try waiting for a bit longer (15 minutes) until the CD is available to avoid running into timeouts.
|
---|
150 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True, cMsCdWait = 15 * 60 * 1000);
|
---|
151 | if oSession is not None:
|
---|
152 | self.addTask(oTxsSession);
|
---|
153 |
|
---|
154 | ## @todo do some quick tests: save, restore, execute some test program, shut down the guest.
|
---|
155 |
|
---|
156 | # cleanup.
|
---|
157 | self.removeTask(oTxsSession);
|
---|
158 | self.terminateVmBySession(oSession)
|
---|
159 | return True;
|
---|
160 | return None;
|
---|
161 |
|
---|
162 | if __name__ == '__main__':
|
---|
163 | sys.exit(tdSmokeTest1().main(sys.argv));
|
---|