VirtualBox

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

Last change on this file since 78351 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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