Changeset 58937 in vbox for trunk/src/VBox/ValidationKit/tests/usb
- Timestamp:
- Dec 1, 2015 1:04:30 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/tests/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py
r58907 r58937 88 88 def __init__(self): 89 89 vbox.TestDriver.__init__(self); 90 self.asRsrcs = None; 91 self.asTestVMsDef = ['tst-arch']; 92 self.asTestVMs = self.asTestVMsDef; 93 self.asSkipVMs = []; 94 self.asVirtModesDef = ['hwvirt', 'hwvirt-np', 'raw']; 95 self.asVirtModes = self.asVirtModesDef; 96 self.acCpusDef = [1, 2,]; 97 self.acCpus = self.acCpusDef; 98 self.asUsbCtrlsDef = ['OHCI', 'EHCI', 'XHCI']; 99 self.asUsbCtrls = self.asUsbCtrlsDef; 100 self.asUsbSpeedDef = ['Low', 'Full', 'High', 'Super']; 101 self.asUsbSpeed = self.asUsbSpeedDef; 102 self.sHostname = socket.gethostname().lower(); 90 self.asRsrcs = None; 91 self.asTestVMsDef = ['tst-arch']; 92 self.asTestVMs = self.asTestVMsDef; 93 self.asSkipVMs = []; 94 self.asVirtModesDef = ['hwvirt', 'hwvirt-np', 'raw']; 95 self.asVirtModes = self.asVirtModesDef; 96 self.acCpusDef = [1, 2,]; 97 self.acCpus = self.acCpusDef; 98 self.asUsbCtrlsDef = ['OHCI', 'EHCI', 'XHCI']; 99 self.asUsbCtrls = self.asUsbCtrlsDef; 100 self.asUsbSpeedDef = ['Low', 'Full', 'High', 'Super']; 101 self.asUsbSpeed = self.asUsbSpeedDef; 102 self.asUsbTestsDef = ['Compliance', 'Reattach']; 103 self.asUsbTests = self.asUsbTestsDef; 104 self.cUsbReattachCyclesDef = 100; 105 self.cUsbReattachCycles = self.cUsbReattachCyclesDef; 106 self.sHostname = socket.gethostname().lower(); 103 107 104 108 # … … 123 127 reporter.log(' --usb-speed <s1[:s2[:]]'); 124 128 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.asUsbSpeedDef))); 129 reporter.log(' --usb-tests <s1[:s2[:]]'); 130 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.asUsbTestsDef))); 131 reporter.log(' --usb-reattach-cycles <cycles>'); 132 reporter.log(' Default: %s' % (self.cUsbReattachCyclesDef)); 125 133 return rc; 126 134 … … 172 180 if s not in self.asUsbSpeedDef: 173 181 reporter.log('warning: The "--usb-speed" value "%s" is not a valid USB speed.' % (s)); 182 elif asArgs[iArg] == '--usb-tests': 183 iArg += 1; 184 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-tests" takes a colon separated list of USB tests'); 185 self.asUsbTests = asArgs[iArg].split(':'); 186 for s in self.asUsbTests: 187 if s not in self.asUsbTestsDef: 188 reporter.log('warning: The "--usb-tests" value "%s" is not a valid USB test.' % (s)); 189 elif asArgs[iArg] == '--usb-reattach-cycles': 190 iArg += 1; 191 if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-reattach-cycles" takes cycle count'); 192 try: self.cUsbReattachCycles = int(asArgs[iArg]); 193 except: raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is not an integer' % (asArgs[iArg],)); 194 if self.cUsbReattachCycles <= 0: 195 raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is zero or negative.' % (self.cUsbReattachCycles,)); 174 196 else: 175 197 return vbox.TestDriver.parseOption(self, asArgs, iArg); … … 285 307 tupCmdLine = tupCmdLine + ('--exclude', '10', '--exclude', '24'); 286 308 287 fRc = self.txsRunTest(oTxsSession, ' Compliance', 3600 * 1000, \309 fRc = self.txsRunTest(oTxsSession, 'UsbTest', 3600 * 1000, \ 288 310 '${CDROM}/${OS/ARCH}/UsbTest${EXESUFF}', tupCmdLine); 311 if not fRc: 312 reporter.testFailure('Running USB test utility failed'); 289 313 290 314 else: … … 299 323 return fRc; 300 324 301 def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed): 302 """ 303 Runs the specified VM thru test #1. 325 def testUsbReattach(self, oSession, oTxsSession, sUsbCtrl, sSpeed): 326 """ 327 Tests that rapid connect/disconnect cycles work. 328 """ 329 # Get configured USB test devices from hostname we are running on 330 sGadgetHost, sGadgetType = self.getGadgetParams(self.sHostname, sSpeed); 331 332 # Create device filter 333 fRc = oSession.addUsbDeviceFilter('Compliance device', '0525', 'a4a0'); 334 if fRc is True: 335 oUsbGadget = usbgadget.UsbGadget(); 336 reporter.log('Connecting to gadget: ' + sGadgetType); 337 fRc = oUsbGadget.connectTo(30 * 1000, sGadgetType, sGadgetHost); 338 if fRc is True: 339 reporter.log('Connect succeeded'); 340 fRc = oUsbGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest); 341 if fRc is True: 342 343 self.sleep(1); 344 345 # Do a rapid disconnect reconnect cycle. Wait a second before disconnecting 346 # again or it will happen so fast that the VM can't attach the new device. 347 # @todo: Get rid of the constant wait and use an event to get notified when 348 # the device was attached. 349 for iCycle in xrange (0, self.cUsbReattachCycles): 350 fRc = oUsbGadget.disconnectUsb(); 351 fRc = fRc and oUsbGadget.connectUsb(); 352 if not fRc: 353 reporter.testFailure('Reattach cycle %s failed on the gadget device' % (iCycle)); 354 break; 355 self.sleep(1); 356 357 else: 358 reporter.testFailure('Failed to impersonate test device'); 359 360 oUsbGadget.disconnectFrom(); 361 else: 362 reporter.testFailure('Failed to connect to USB gadget'); 363 else: 364 reporter.testFailure('Failed to create USB device filter'); 365 366 return fRc; 367 368 def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed, sUsbTest): 369 """ 370 Runs the specified VM thru one specified test. 304 371 305 372 Returns a success indicator on the general test execution. This is not … … 342 409 self.sleep(5); 343 410 344 fRc = self.testUsbCompliance(oSession, oTxsSession, sUsbCtrl, sSpeed); 411 if sUsbTest == 'Compliance': 412 fRc = self.testUsbCompliance(oSession, oTxsSession, sUsbCtrl, sSpeed); 413 elif sUsbTest == 'Reattach': 414 fRc = self.testUsbReattach(oSession, oTxsSession, sUsbCtrl, sSpeed); 345 415 346 416 # cleanup. … … 362 432 if sUsbSpeed in asSupportedSpeeds: 363 433 reporter.testStart(sUsbSpeed) 364 fRc = self.testUsbOneCfg(sVmName, sUsbCtrl, sUsbSpeed); 434 for sUsbTest in self.asUsbTests: 435 reporter.testStart(sUsbTest) 436 fRc = self.testUsbOneCfg(sVmName, sUsbCtrl, sUsbSpeed, sUsbTest); 437 reporter.testDone(); 365 438 reporter.testDone(); 366 439 reporter.testDone(); -
trunk/src/VBox/ValidationKit/tests/usb/usbgadget.py
r58907 r58937 72 72 if self.oTxsSession is not None: 73 73 fRc = self.oTxsSession.syncExecEx('/usr/bin/modprobe', ('/usr/bin/modprobe', sModule)); 74 # For the ODroid-XU3 gadget we have to do a soft connect for the attached host to recognise the device. 75 if self.sGadgetType == g_ksGadgetTypeODroidXu3: 76 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 77 ('/usr/bin/sh', '-c', 'echo connect > /sys/class/udc/12400000.dwc3/soft_connect')); 78 elif self.sGadgetType == g_ksGadgetTypeBeaglebone: 79 # Do a soft disconnect/reconnect cycle or the device will not be recognised as high speed after the first test. 80 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 81 ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/musb-hdrc.0.auto/soft_connect')); 82 if fRc: 83 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 84 ('/usr/bin/sh', '-c', 'echo connect > /sys/class/udc/musb-hdrc.0.auto/soft_connect')); 74 fRc = fRc and self.connectUsb(); 85 75 return fRc; 86 76 … … 93 83 fRc = False; 94 84 if self.oTxsSession is not None: 95 # For the ODroid-XU3 gadget we do a soft disconnect before unloading the gadget driver. 96 if self.sGadgetType == g_ksGadgetTypeODroidXu3: 97 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 98 ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/12400000.dwc3/soft_connect')); 99 elif self.sGadgetType == g_ksGadgetTypeBeaglebone: 100 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 101 ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/musb-hdrc.0.auto/soft_connect')); 102 85 self.disconnectUsb(); 103 86 fRc = self.oTxsSession.syncExecEx('/usr/bin/rmmod', ('/usr/bin/rmmod', sModule)); 104 87 … … 127 110 128 111 return False; 112 113 def disconnectUsb(self): 114 """ 115 Disconnects the USB gadget from the host. (USB connection not network 116 connection used for control) 117 """ 118 if self.sGadgetType == g_ksGadgetTypeODroidXu3: 119 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 120 ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/12400000.dwc3/soft_connect')); 121 elif self.sGadgetType == g_ksGadgetTypeBeaglebone: 122 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 123 ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/musb-hdrc.0.auto/soft_connect')); 124 return fRc; 125 126 def connectUsb(self): 127 """ 128 Connect the USB gadget to the host. 129 """ 130 if self.sGadgetType == g_ksGadgetTypeODroidXu3: 131 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 132 ('/usr/bin/sh', '-c', 'echo connect > /sys/class/udc/12400000.dwc3/soft_connect')); 133 elif self.sGadgetType == g_ksGadgetTypeBeaglebone: 134 fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', \ 135 ('/usr/bin/sh', '-c', 'echo connect > /sys/class/udc/musb-hdrc.0.auto/soft_connect')); 136 return fRc; 129 137 130 138 def impersonate(self, sImpersonation):
Note:
See TracChangeset
for help on using the changeset viewer.