VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py@ 96472

Last change on this file since 96472 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 25.3 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdUsb1.py 96407 2022-08-22 17:43:14Z vboxsync $
4
5"""
6VirtualBox Validation Kit - USB testcase and benchmark.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2014-2022 Oracle and/or its affiliates.
12
13This file is part of VirtualBox base platform packages, as
14available from https://www.virtualbox.org.
15
16This program is free software; you can redistribute it and/or
17modify it under the terms of the GNU General Public License
18as published by the Free Software Foundation, in version 3 of the
19License.
20
21This program is distributed in the hope that it will be useful, but
22WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, see <https://www.gnu.org/licenses>.
28
29The contents of this file may alternatively be used under the terms
30of the Common Development and Distribution License Version 1.0
31(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
32in the VirtualBox distribution, in which case the provisions of the
33CDDL are applicable instead of those of the GPL.
34
35You may elect to license modified versions of this file under the
36terms and conditions of either the GPL or the CDDL or both.
37
38SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
39"""
40__version__ = "$Revision: 96407 $"
41
42
43# Standard Python imports.
44import os;
45import sys;
46import socket;
47
48# Only the main script needs to modify the path.
49try: __file__
50except: __file__ = sys.argv[0];
51g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
52sys.path.append(g_ksValidationKitDir);
53
54# Validation Kit imports.
55from testdriver import reporter;
56from testdriver import base;
57from testdriver import vbox;
58from testdriver import vboxcon;
59
60# USB gadget control import
61import usbgadget;
62
63# Python 3 hacks:
64if sys.version_info[0] >= 3:
65 xrange = range; # pylint: disable=redefined-builtin,invalid-name
66
67
68class tdUsbBenchmark(vbox.TestDriver): # pylint: disable=too-many-instance-attributes
69 """
70 USB benchmark.
71 """
72
73 # The available test devices
74 #
75 # The first key is the hostname of the host the test is running on.
76 # It contains a new dictionary with the attached gadgets based on the
77 # USB speed we want to test (Low, Full, High, Super).
78 # The parameters consist of the hostname of the gadget in the network
79 # and the hardware type.
80 kdGadgetParams = {
81 'adaris': {
82 'Low': ('usbtest.de.oracle.com', None),
83 'Full': ('usbtest.de.oracle.com', None),
84 'High': ('usbtest.de.oracle.com', None),
85 'Super': ('usbtest.de.oracle.com', None)
86 },
87 };
88
89 # Mappings of USB controllers to supported USB device speeds.
90 kdUsbSpeedMappings = {
91 'OHCI': ['Low', 'Full'],
92 'EHCI': ['High'],
93 'XHCI': ['Low', 'Full', 'High', 'Super']
94 };
95
96 # Tests currently disabled because they fail, need investigation.
97 kdUsbTestsDisabled = {
98 'Low': [24],
99 'Full': [24],
100 'High': [24],
101 'Super': [24]
102 };
103
104 def __init__(self):
105 vbox.TestDriver.__init__(self);
106 self.asRsrcs = None;
107 self.asTestVMsDef = ['tst-arch'];
108 self.asTestVMs = self.asTestVMsDef;
109 self.asSkipVMs = [];
110 self.asVirtModesDef = ['hwvirt', 'hwvirt-np', 'raw'];
111 self.asVirtModes = self.asVirtModesDef;
112 self.acCpusDef = [1, 2,];
113 self.acCpus = self.acCpusDef;
114 self.asUsbCtrlsDef = ['OHCI', 'EHCI', 'XHCI'];
115 self.asUsbCtrls = self.asUsbCtrlsDef;
116 self.asUsbSpeedDef = ['Low', 'Full', 'High', 'Super'];
117 self.asUsbSpeed = self.asUsbSpeedDef;
118 self.asUsbTestsDef = ['Compliance', 'Reattach'];
119 self.asUsbTests = self.asUsbTestsDef;
120 self.cUsbReattachCyclesDef = 100;
121 self.cUsbReattachCycles = self.cUsbReattachCyclesDef;
122 self.sHostname = socket.gethostname().lower();
123 self.sGadgetHostnameDef = 'usbtest.de.oracle.com';
124 self.uGadgetPortDef = None;
125 self.sUsbCapturePathDef = self.sScratchPath;
126 self.sUsbCapturePath = self.sUsbCapturePathDef;
127 self.fUsbCapture = False;
128
129 #
130 # Overridden methods.
131 #
132 def showUsage(self):
133 rc = vbox.TestDriver.showUsage(self);
134 reporter.log('');
135 reporter.log('tdUsb1 Options:');
136 reporter.log(' --virt-modes <m1[:m2[:]]');
137 reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
138 reporter.log(' --cpu-counts <c1[:c2[:]]');
139 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
140 reporter.log(' --test-vms <vm1[:vm2[:...]]>');
141 reporter.log(' Test the specified VMs in the given order. Use this to change');
142 reporter.log(' the execution order or limit the choice of VMs');
143 reporter.log(' Default: %s (all)' % (':'.join(self.asTestVMsDef)));
144 reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
145 reporter.log(' Skip the specified VMs when testing.');
146 reporter.log(' --usb-ctrls <u1[:u2[:]]');
147 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.asUsbCtrlsDef)));
148 reporter.log(' --usb-speed <s1[:s2[:]]');
149 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.asUsbSpeedDef)));
150 reporter.log(' --usb-tests <s1[:s2[:]]');
151 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.asUsbTestsDef)));
152 reporter.log(' --usb-reattach-cycles <cycles>');
153 reporter.log(' Default: %s' % (self.cUsbReattachCyclesDef));
154 reporter.log(' --hostname: <hostname>');
155 reporter.log(' Default: %s' % (self.sHostname));
156 reporter.log(' --default-gadget-host <hostname>');
157 reporter.log(' Default: %s' % (self.sGadgetHostnameDef));
158 reporter.log(' --default-gadget-port <port>');
159 reporter.log(' Default: %s' % (6042));
160 reporter.log(' --usb-capture-path <path>');
161 reporter.log(' Default: %s' % (self.sUsbCapturePathDef));
162 reporter.log(' --usb-capture');
163 reporter.log(' Whether to capture the USB traffic for each test');
164 return rc;
165
166 def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements
167 if asArgs[iArg] == '--virt-modes':
168 iArg += 1;
169 if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
170 self.asVirtModes = asArgs[iArg].split(':');
171 for s in self.asVirtModes:
172 if s not in self.asVirtModesDef:
173 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
174 % (s, ' '.join(self.asVirtModesDef)));
175 elif asArgs[iArg] == '--cpu-counts':
176 iArg += 1;
177 if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
178 self.acCpus = [];
179 for s in asArgs[iArg].split(':'):
180 try: c = int(s);
181 except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
182 if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
183 self.acCpus.append(c);
184 elif asArgs[iArg] == '--test-vms':
185 iArg += 1;
186 if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
187 self.asTestVMs = asArgs[iArg].split(':');
188 for s in self.asTestVMs:
189 if s not in self.asTestVMsDef:
190 raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
191 % (s, ' '.join(self.asTestVMsDef)));
192 elif asArgs[iArg] == '--skip-vms':
193 iArg += 1;
194 if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
195 self.asSkipVMs = asArgs[iArg].split(':');
196 for s in self.asSkipVMs:
197 if s not in self.asTestVMsDef:
198 reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
199 elif asArgs[iArg] == '--usb-ctrls':
200 iArg += 1;
201 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-ctrls" takes a colon separated list of USB controllers');
202 self.asUsbCtrls = asArgs[iArg].split(':');
203 for s in self.asUsbCtrls:
204 if s not in self.asUsbCtrlsDef:
205 reporter.log('warning: The "--usb-ctrls" value "%s" is not a valid USB controller.' % (s));
206 elif asArgs[iArg] == '--usb-speed':
207 iArg += 1;
208 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-speed" takes a colon separated list of USB speeds');
209 self.asUsbSpeed = asArgs[iArg].split(':');
210 for s in self.asUsbSpeed:
211 if s not in self.asUsbSpeedDef:
212 reporter.log('warning: The "--usb-speed" value "%s" is not a valid USB speed.' % (s));
213 elif asArgs[iArg] == '--usb-tests':
214 iArg += 1;
215 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-tests" takes a colon separated list of USB tests');
216 self.asUsbTests = asArgs[iArg].split(':');
217 for s in self.asUsbTests:
218 if s not in self.asUsbTestsDef:
219 reporter.log('warning: The "--usb-tests" value "%s" is not a valid USB test.' % (s));
220 elif asArgs[iArg] == '--usb-reattach-cycles':
221 iArg += 1;
222 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-reattach-cycles" takes cycle count');
223 try: self.cUsbReattachCycles = int(asArgs[iArg]);
224 except: raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is not an integer' \
225 % (asArgs[iArg],));
226 if self.cUsbReattachCycles <= 0:
227 raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is zero or negative.' \
228 % (self.cUsbReattachCycles,));
229 elif asArgs[iArg] == '--hostname':
230 iArg += 1;
231 if iArg >= len(asArgs): raise base.InvalidOption('The "--hostname" takes a hostname');
232 self.sHostname = asArgs[iArg];
233 elif asArgs[iArg] == '--default-gadget-host':
234 iArg += 1;
235 if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-host" takes a hostname');
236 self.sGadgetHostnameDef = asArgs[iArg];
237 elif asArgs[iArg] == '--default-gadget-port':
238 iArg += 1;
239 if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-port" takes port number');
240 try: self.uGadgetPortDef = int(asArgs[iArg]);
241 except: raise base.InvalidOption('The "--default-gadget-port" value "%s" is not an integer' \
242 % (asArgs[iArg],));
243 if self.uGadgetPortDef <= 0:
244 raise base.InvalidOption('The "--default-gadget-port" value "%s" is zero or negative.' \
245 % (self.uGadgetPortDef,));
246 elif asArgs[iArg] == '--usb-capture-path':
247 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-capture-path" takes a path argument');
248 self.sUsbCapturePath = asArgs[iArg];
249 elif asArgs[iArg] == '--usb-capture':
250 self.fUsbCapture = True;
251 else:
252 return vbox.TestDriver.parseOption(self, asArgs, iArg);
253 return iArg + 1;
254
255 def completeOptions(self):
256 # Remove skipped VMs from the test list.
257 for sVM in self.asSkipVMs:
258 try: self.asTestVMs.remove(sVM);
259 except: pass;
260
261 return vbox.TestDriver.completeOptions(self);
262
263 def getResourceSet(self):
264 # Construct the resource list the first time it's queried.
265 if self.asRsrcs is None:
266 self.asRsrcs = [];
267
268 if 'tst-arch' in self.asTestVMs:
269 self.asRsrcs.append('4.2/usb/tst-arch.vdi');
270
271 return self.asRsrcs;
272
273 def actionConfig(self):
274
275 # Some stupid trickery to guess the location of the iso. ## fixme - testsuite unzip ++
276 sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
277 if not os.path.isfile(sVBoxValidationKit_iso):
278 sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
279 if not os.path.isfile(sVBoxValidationKit_iso):
280 sVBoxValidationKit_iso = '/mnt/ramdisk/vbox/svn/trunk/validationkit/VBoxValidationKit.iso';
281 if not os.path.isfile(sVBoxValidationKit_iso):
282 sVBoxValidationKit_iso = '/mnt/ramdisk/vbox/svn/trunk/testsuite/VBoxTestSuite.iso';
283 if not os.path.isfile(sVBoxValidationKit_iso):
284 sCur = os.getcwd();
285 for i in range(0, 10):
286 sVBoxValidationKit_iso = os.path.join(sCur, 'validationkit/VBoxValidationKit.iso');
287 if os.path.isfile(sVBoxValidationKit_iso):
288 break;
289 sVBoxValidationKit_iso = os.path.join(sCur, 'testsuite/VBoxTestSuite.iso');
290 if os.path.isfile(sVBoxValidationKit_iso):
291 break;
292 sCur = os.path.abspath(os.path.join(sCur, '..'));
293 if i is None: pass; # shut up pychecker/pylint.
294 if not os.path.isfile(sVBoxValidationKit_iso):
295 sVBoxValidationKit_iso = '/home/bird/validationkit/VBoxValidationKit.iso';
296 if not os.path.isfile(sVBoxValidationKit_iso):
297 sVBoxValidationKit_iso = '/home/bird/testsuite/VBoxTestSuite.iso';
298
299 # Make sure vboxapi has been imported so we can use the constants.
300 if not self.importVBoxApi():
301 return False;
302
303 #
304 # Configure the VMs we're going to use.
305 #
306
307 # Linux VMs
308 if 'tst-arch' in self.asTestVMs:
309 oVM = self.createTestVM('tst-arch', 1, '4.2/usb/tst-arch.vdi', sKind = 'ArchLinux_64', fIoApic = True, \
310 eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
311 sDvdImage = sVBoxValidationKit_iso);
312 if oVM is None:
313 return False;
314
315 return True;
316
317 def actionExecute(self):
318 """
319 Execute the testcase.
320 """
321 fRc = self.testUsb();
322 return fRc;
323
324 def getGadgetParams(self, sHostname, sSpeed):
325 """
326 Returns the gadget hostname and port from the
327 given hostname the test is running on and device speed we want to test.
328 """
329 kdGadgetsConfigured = self.kdGadgetParams.get(sHostname);
330 if kdGadgetsConfigured is not None:
331 return kdGadgetsConfigured.get(sSpeed);
332
333 return (self.sGadgetHostnameDef, self.uGadgetPortDef);
334
335 def getCaptureFilePath(self, sUsbCtrl, sSpeed):
336 """
337 Returns capture filename from the given data.
338 """
339
340 return '%s%s%s-%s.pcap' % (self.sUsbCapturePath, os.sep, sUsbCtrl, sSpeed);
341
342 def attachUsbDeviceToVm(self, oSession, sVendorId, sProductId, iBusId,
343 sCaptureFile = None):
344 """
345 Attaches the given USB device to the VM either via a filter
346 or directly if capturing the USB traffic is enabled.
347
348 Returns True on success, False on failure.
349 """
350 fRc = False;
351 if sCaptureFile is None:
352 fRc = oSession.addUsbDeviceFilter('Compliance device', sVendorId = sVendorId, sProductId = sProductId, \
353 sPort = format(iBusId, 'x'));
354 else:
355 # Search for the correct device in the USB device list waiting for some time
356 # to let it appear.
357 iVendorId = int(sVendorId, 16);
358 iProductId = int(sProductId, 16);
359
360 # Try a few times to give VBoxSVC a chance to detect the new device.
361 for _ in xrange(5):
362 fFound = False;
363 aoUsbDevs = self.oVBoxMgr.getArray(self.oVBox.host, 'USBDevices');
364 for oUsbDev in aoUsbDevs:
365 if oUsbDev.vendorId == iVendorId \
366 and oUsbDev.productId == iProductId \
367 and oUsbDev.port == iBusId:
368 fFound = True;
369 fRc = oSession.attachUsbDevice(oUsbDev.id, sCaptureFile);
370 break;
371
372 if fFound:
373 break;
374
375 # Wait a moment until the next try.
376 self.sleep(1);
377
378 if fRc:
379 # Wait a moment to let the USB device appear
380 self.sleep(9);
381
382 return fRc;
383
384 #
385 # Test execution helpers.
386 #
387 def testUsbCompliance(self, oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile = None):
388 """
389 Test VirtualBoxs USB stack in a VM.
390 """
391 # Get configured USB test devices from hostname we are running on
392 sGadgetHost, uGadgetPort = self.getGadgetParams(self.sHostname, sSpeed);
393
394 oUsbGadget = usbgadget.UsbGadget();
395 reporter.log('Connecting to UTS: ' + sGadgetHost);
396 fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost, uPort = uGadgetPort, fTryConnect = True);
397 if fRc is True:
398 reporter.log('Connect succeeded');
399 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost + (':%s' % oUsbGadget.getUsbIpPort()), [], []);
400
401 fSuperSpeed = False;
402 if sSpeed == 'Super':
403 fSuperSpeed = True;
404
405 # Create test device gadget and a filter to attach the device automatically.
406 fRc = oUsbGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest, fSuperSpeed);
407 if fRc is True:
408 iBusId, _ = oUsbGadget.getGadgetBusAndDevId();
409 fRc = self.attachUsbDeviceToVm(oSession, '0525', 'a4a0', iBusId, sCaptureFile);
410 if fRc is True:
411 tupCmdLine = ('UsbTest', );
412 # Exclude a few tests which hang and cause a timeout, need investigation.
413 lstTestsExclude = self.kdUsbTestsDisabled.get(sSpeed);
414 for iTestExclude in lstTestsExclude:
415 tupCmdLine = tupCmdLine + ('--exclude', str(iTestExclude));
416
417 fRc = self.txsRunTest(oTxsSession, 'UsbTest', 3600 * 1000, \
418 '${CDROM}/${OS/ARCH}/UsbTest${EXESUFF}', tupCmdLine);
419 if not fRc:
420 reporter.testFailure('Running USB test utility failed');
421 else:
422 reporter.testFailure('Failed to attach USB device to VM');
423 oUsbGadget.disconnectFrom();
424 else:
425 reporter.testFailure('Failed to impersonate test device');
426
427 self.oVBox.host.removeUSBDeviceSource(sGadgetHost);
428 else:
429 reporter.log('warning: Failed to connect to USB gadget');
430 fRc = None
431
432 _ = sUsbCtrl;
433 return fRc;
434
435 def testUsbReattach(self, oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile = None): # pylint: disable=unused-argument
436 """
437 Tests that rapid connect/disconnect cycles work.
438 """
439 # Get configured USB test devices from hostname we are running on
440 sGadgetHost, uGadgetPort = self.getGadgetParams(self.sHostname, sSpeed);
441
442 oUsbGadget = usbgadget.UsbGadget();
443 reporter.log('Connecting to UTS: ' + sGadgetHost);
444 fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost, uPort = uGadgetPort, fTryConnect = True);
445 if fRc is True:
446 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost + (':%s' % oUsbGadget.getUsbIpPort()), [], []);
447
448 fSuperSpeed = False;
449 if sSpeed == 'Super':
450 fSuperSpeed = True;
451
452 # Create test device gadget and a filter to attach the device automatically.
453 fRc = oUsbGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest, fSuperSpeed);
454 if fRc is True:
455 iBusId, _ = oUsbGadget.getGadgetBusAndDevId();
456 fRc = self.attachUsbDeviceToVm(oSession, '0525', 'a4a0', iBusId, sCaptureFile);
457 if fRc is True:
458
459 # Wait a moment to let the USB device appear
460 self.sleep(3);
461
462 # Do a rapid disconnect reconnect cycle. Wait a second before disconnecting
463 # again or it will happen so fast that the VM can't attach the new device.
464 # @todo: Get rid of the constant wait and use an event to get notified when
465 # the device was attached.
466 for iCycle in xrange (0, self.cUsbReattachCycles):
467 fRc = oUsbGadget.disconnectUsb();
468 fRc = fRc and oUsbGadget.connectUsb();
469 if not fRc:
470 reporter.testFailure('Reattach cycle %s failed on the gadget device' % (iCycle));
471 break;
472 self.sleep(1);
473
474 else:
475 reporter.testFailure('Failed to create USB device filter');
476
477 oUsbGadget.disconnectFrom();
478 else:
479 reporter.testFailure('Failed to impersonate test device');
480 else:
481 reporter.log('warning: Failed to connect to USB gadget');
482 fRc = None
483
484 return fRc;
485
486 def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed, sUsbTest):
487 """
488 Runs the specified VM thru one specified test.
489
490 Returns a success indicator on the general test execution. This is not
491 the actual test result.
492 """
493 oVM = self.getVmByName(sVmName);
494
495 # Reconfigure the VM
496 fRc = True;
497 oSession = self.openSession(oVM);
498 if oSession is not None:
499 fRc = fRc and oSession.enableVirtEx(True);
500 fRc = fRc and oSession.enableNestedPaging(True);
501
502 # Make sure controllers are disabled initially.
503 fRc = fRc and oSession.enableUsbOhci(False);
504 fRc = fRc and oSession.enableUsbEhci(False);
505 fRc = fRc and oSession.enableUsbXhci(False);
506
507 if sUsbCtrl == 'OHCI':
508 fRc = fRc and oSession.enableUsbOhci(True);
509 elif sUsbCtrl == 'EHCI':
510 fRc = fRc and oSession.enableUsbEhci(True);
511 elif sUsbCtrl == 'XHCI':
512 fRc = fRc and oSession.enableUsbXhci(True);
513 fRc = fRc and oSession.saveSettings();
514 fRc = oSession.close() and fRc and True; # pychecker hack.
515 oSession = None;
516 else:
517 fRc = False;
518
519 # Start up.
520 if fRc is True:
521 self.logVmInfo(oVM);
522 oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = False);
523 if oSession is not None:
524 self.addTask(oTxsSession);
525
526 # Fudge factor - Allow the guest to finish starting up.
527 self.sleep(5);
528
529 sCaptureFile = None;
530 if self.fUsbCapture:
531 sCaptureFile = self.getCaptureFilePath(sUsbCtrl, sSpeed);
532
533 if sUsbTest == 'Compliance':
534 fRc = self.testUsbCompliance(oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile);
535 elif sUsbTest == 'Reattach':
536 fRc = self.testUsbReattach(oSession, oTxsSession, sUsbCtrl, sSpeed, sCaptureFile);
537
538 # cleanup.
539 self.removeTask(oTxsSession);
540 self.terminateVmBySession(oSession)
541
542 # Add the traffic dump if it exists and the test failed
543 if reporter.testErrorCount() > 0 \
544 and sCaptureFile is not None \
545 and os.path.exists(sCaptureFile):
546 reporter.addLogFile(sCaptureFile, 'misc/other', 'USB traffic dump');
547 else:
548 fRc = False;
549 return fRc;
550
551 def testUsbForOneVM(self, sVmName):
552 """
553 Runs one VM thru the various configurations.
554 """
555 fRc = False;
556 reporter.testStart(sVmName);
557 for sUsbCtrl in self.asUsbCtrls:
558 reporter.testStart(sUsbCtrl)
559 for sUsbSpeed in self.asUsbSpeed:
560 asSupportedSpeeds = self.kdUsbSpeedMappings.get(sUsbCtrl);
561 if sUsbSpeed in asSupportedSpeeds:
562 reporter.testStart(sUsbSpeed)
563 for sUsbTest in self.asUsbTests:
564 reporter.testStart(sUsbTest)
565 fRc = self.testUsbOneCfg(sVmName, sUsbCtrl, sUsbSpeed, sUsbTest);
566 reporter.testDone();
567 reporter.testDone();
568 reporter.testDone();
569 reporter.testDone();
570 return fRc;
571
572 def testUsb(self):
573 """
574 Executes USB test.
575 """
576
577 reporter.log("Running on host: " + self.sHostname);
578
579 # Loop thru the test VMs.
580 for sVM in self.asTestVMs:
581 # run test on the VM.
582 fRc = self.testUsbForOneVM(sVM);
583
584 return fRc;
585
586
587
588if __name__ == '__main__':
589 sys.exit(tdUsbBenchmark().main(sys.argv));
590
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