VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/cpu/tdCpuPae1.py@ 64468

Last change on this file since 64468 was 62484, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdCpuPae1.py 62484 2016-07-22 18:35:33Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Catch PAE not enabled.
7
8Test that switching into PAE mode when it isn't enable, check that it produces
9the right runtime error.
10"""
11
12__copyright__ = \
13"""
14Copyright (C) 2010-2016 Oracle Corporation
15
16This file is part of VirtualBox Open Source Edition (OSE), as
17available from http://www.virtualbox.org. This file is free software;
18you can redistribute it and/or modify it under the terms of the GNU
19General Public License (GPL) as published by the Free Software
20Foundation, in version 2 as it comes in the "COPYING" file of the
21VirtualBox OSE distribution. VirtualBox OSE is distributed in the
22hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
23
24The contents of this file may alternatively be used under the terms
25of the Common Development and Distribution License Version 1.0
26(CDDL) only, as it comes in the "COPYING.CDDL" file of the
27VirtualBox OSE distribution, in which case the provisions of the
28CDDL are applicable instead of those of the GPL.
29
30You may elect to license modified versions of this file under the
31terms and conditions of either the GPL or the CDDL or both.
32"""
33__version__ = "$Revision: 62484 $"
34
35
36# Standard Python imports.
37import os;
38import sys;
39
40# Only the main script needs to modify the path.
41try: __file__
42except: __file__ = sys.argv[0];
43g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
44sys.path.append(g_ksValidationKitDir);
45
46# Validation Kit imports.
47from testdriver import reporter;
48from testdriver import base;
49from testdriver import vbox;
50
51
52class tdCpuPae1ConsoleCallbacks(vbox.ConsoleEventHandlerBase):
53 """
54 For catching the PAE runtime error.
55 """
56 def __init__(self, dArgs):
57 oTstDrv = dArgs['oTstDrv'];
58 oVBoxMgr = dArgs['oVBoxMgr']; _ = oVBoxMgr;
59
60 vbox.ConsoleEventHandlerBase.__init__(self, dArgs, 'tdCpuPae1');
61 self.oTstDrv = oTstDrv;
62
63 def onRuntimeError(self, fFatal, sErrId, sMessage):
64 """ Verify the error. """
65 reporter.log('onRuntimeError: fFatal=%s sErrId="%s" sMessage="%s"' % (fFatal, sErrId, sMessage));
66 if sErrId != 'PAEmode':
67 reporter.testFailure('sErrId=%s, expected PAEmode' % (sErrId,));
68 elif fFatal is not True:
69 reporter.testFailure('fFatal=%s, expected True' % (fFatal,));
70 else:
71 self.oTstDrv.fCallbackSuccess = True;
72 self.oTstDrv.fCallbackFired = True;
73 self.oVBoxMgr.interruptWaitEvents();
74 return None;
75
76
77class tdCpuPae1(vbox.TestDriver):
78 """
79 PAE Test #1.
80 """
81
82 def __init__(self):
83 vbox.TestDriver.__init__(self);
84 self.asSkipTests = [];
85 self.asVirtModesDef = ['hwvirt', 'hwvirt-np', 'raw',]
86 self.asVirtModes = self.asVirtModesDef
87 self.acCpusDef = [1, 2,]
88 self.acCpus = self.acCpusDef;
89 self.fCallbackFired = False;
90 self.fCallbackSuccess = False;
91
92 #
93 # Overridden methods.
94 #
95 def showUsage(self):
96 rc = vbox.TestDriver.showUsage(self);
97 reporter.log('');
98 reporter.log('tdCpuPae1 Options:');
99 reporter.log(' --virt-modes <m1[:m2[:]]');
100 reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
101 reporter.log(' --cpu-counts <c1[:c2[:]]');
102 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
103 reporter.log(' --quick');
104 reporter.log(' Shorthand for: --virt-modes raw --cpu-counts 1 32');
105 return rc;
106
107 def parseOption(self, asArgs, iArg):
108 if asArgs[iArg] == '--virt-modes':
109 iArg += 1;
110 if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
111 self.asVirtModes = asArgs[iArg].split(':');
112 for s in self.asVirtModes:
113 if s not in self.asVirtModesDef:
114 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
115 % (s, ' '.join(self.asVirtModesDef)));
116 elif asArgs[iArg] == '--cpu-counts':
117 iArg += 1;
118 if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
119 self.acCpus = [];
120 for s in asArgs[iArg].split(':'):
121 try: c = int(s);
122 except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
123 if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
124 self.acCpus.append(c);
125 elif asArgs[iArg] == '--quick':
126 self.asVirtModes = ['raw',];
127 self.acCpus = [1,];
128 else:
129 return vbox.TestDriver.parseOption(self, asArgs, iArg);
130 return iArg + 1;
131
132 def getResourceSet(self):
133 return [];
134
135 def actionConfig(self):
136 # Make sure vboxapi has been imported so we can use the constants.
137 if not self.importVBoxApi():
138 return False;
139
140 #
141 # Configure a VM with the PAE bootsector as floppy image.
142 #
143
144 oVM = self.createTestVM('tst-bs-pae', 2, sKind = 'Other', fVirtEx = False, fPae = False, \
145 sFloppy = os.path.join(self.sVBoxBootSectors, 'bootsector-pae.img') );
146 if oVM is None:
147 return False;
148 return True;
149
150 def actionExecute(self):
151 """
152 Execute the testcase.
153 """
154 return self.test1();
155
156
157
158 #
159 # Test execution helpers.
160 #
161
162 def test1OneCfg(self, oVM, cCpus, fHwVirt, fNestedPaging):
163 """
164 Runs the specified VM thru test #1.
165
166 Returns a success indicator on the general test execution. This is not
167 the actual test result.
168 """
169
170 # Reconfigure the VM
171 fRc = True;
172 oSession = self.openSession(oVM);
173 if oSession is not None:
174 fRc = fRc and oSession.enableVirtEx(fHwVirt);
175 fRc = fRc and oSession.enableNestedPaging(fNestedPaging);
176 fRc = fRc and oSession.setCpuCount(cCpus);
177 fRc = fRc and oSession.setupBootLogo(True, 2500); # Race avoidance fudge.
178 fRc = fRc and oSession.saveSettings();
179 fRc = oSession.close() and fRc and True; # pychecker hack.
180 oSession = None;
181 else:
182 fRc = False;
183
184 # Zap the state (used by the callback).
185 self.fCallbackFired = False;
186 self.fCallbackSuccess = False;
187
188 # Start up.
189 if fRc is True:
190 self.logVmInfo(oVM);
191 oSession = self.startVm(oVM)
192 if oSession is not None:
193 # Set up a callback for catching the runtime error. !Races the guest bootup!
194 oConsoleCallbacks = oSession.registerDerivedEventHandler(tdCpuPae1ConsoleCallbacks, {'oTstDrv':self,})
195
196 fRc = False;
197 if oConsoleCallbacks is not None:
198 self.addTask(oSession);
199
200 # Wait for 30 seconds for something to finish.
201 tsStart = base.timestampMilli();
202 while base.timestampMilli() - tsStart < 30000:
203 oTask = self.waitForTasks(1000);
204 if oTask is not None:
205 break;
206 if self.fCallbackFired:
207 break;
208 if not self.fCallbackFired:
209 reporter.testFailure('the callback did not fire');
210 fRc = self.fCallbackSuccess;
211
212 # cleanup.
213 oConsoleCallbacks.unregister();
214 self.terminateVmBySession(oSession) #, fRc);
215 else:
216 fRc = False;
217 return fRc;
218
219
220 def test1(self):
221 """
222 Executes test #1 - Negative API testing.
223
224 ASSUMES that the VMs are
225 """
226 reporter.testStart('Test 1');
227 oVM = self.getVmByName('tst-bs-pae');
228
229 for cCpus in self.acCpus:
230 if cCpus == 1: reporter.testStart('1 cpu');
231 else: reporter.testStart('%u cpus' % (cCpus));
232
233 for sVirtMode in self.asVirtModes:
234 if sVirtMode == 'raw' and cCpus > 1:
235 continue;
236
237 hsVirtModeDesc = {};
238 hsVirtModeDesc['raw'] = 'Raw-mode';
239 hsVirtModeDesc['hwvirt'] = 'HwVirt';
240 hsVirtModeDesc['hwvirt-np'] = 'NestedPaging';
241 reporter.testStart(hsVirtModeDesc[sVirtMode]);
242
243 fHwVirt = sVirtMode != 'raw';
244 fNestedPaging = sVirtMode == 'hwvirt-np';
245 self.test1OneCfg(oVM, cCpus, fHwVirt, fNestedPaging);
246
247 reporter.testDone();
248 reporter.testDone();
249
250 return reporter.testDone()[1] == 0;
251
252
253
254if __name__ == '__main__':
255 sys.exit(tdCpuPae1().main(sys.argv));
256
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