Changeset 60522 in vbox
- Timestamp:
- Apr 15, 2016 2:34:35 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106643
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py
r60493 r60522 64 64 # and the hardware type. 65 65 kdGadgetParams = { 66 # The following is for local testing and not for the test lab.67 #'adaris': {68 # 'Low': ('beaglebone',),69 # 'Full': ('beaglebone',),70 # 'High': ('beaglebone',),71 # 'Super': ('odroidxu3',)72 #},73 66 'adaris': { 74 'Low': (' 127.0.0.1', 0),75 'Full': (' 127.0.0.1', 0),76 'High': (' 127.0.0.1', 0),77 'Super': (' 127.0.0.1', 0)67 'Low': ('usbtest.de.oracle.com', None), 68 'Full': ('usbtest.de.oracle.com', None), 69 'High': ('usbtest.de.oracle.com', None), 70 'Super': ('usbtest.de.oracle.com', None) 78 71 }, 79 72 }; … … 105 98 self.cUsbReattachCycles = self.cUsbReattachCyclesDef; 106 99 self.sHostname = socket.gethostname().lower(); 100 self.sGadgetHostnameDef = 'usbtest.de.oracle.com'; 101 self.uGadgetPortDef = None; 107 102 108 103 # … … 131 126 reporter.log(' --usb-reattach-cycles <cycles>'); 132 127 reporter.log(' Default: %s' % (self.cUsbReattachCyclesDef)); 128 reporter.log(' --hostname: <hostname>'); 129 reporter.log(' Default: %s' % (self.sHostname)); 130 reporter.log(' --default-gadget-host <hostname>'); 131 reporter.log(' Default: %s' % (self.sGadgetHostnameDef)); 132 reporter.log(' --default-gadget-port <port>'); 133 reporter.log(' Default: %s' % (6042)); 133 134 return rc; 134 135 … … 196 197 raise base.InvalidOption('The "--usb-reattach-cycles" value "%s" is zero or negative.' \ 197 198 % (self.cUsbReattachCycles,)); 199 elif asArgs[iArg] == '--hostname': 200 iArg += 1; 201 if iArg >= len(asArgs): raise base.InvalidOption('The "--hostname" takes a hostname'); 202 self.sHostname = asArgs[iArg]; 203 elif asArgs[iArg] == '--default-gadget-host': 204 iArg += 1; 205 if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-host" takes a hostname'); 206 self.sGadgetHostnameDef = asArgs[iArg]; 207 elif asArgs[iArg] == '--default-gadget-port': 208 iArg += 1; 209 if iArg >= len(asArgs): raise base.InvalidOption('The "--default-gadget-port" takes port number'); 210 try: self.uGadgetPortDef = int(asArgs[iArg]); 211 except: raise base.InvalidOption('The "--default-gadget-port" value "%s" is not an integer' \ 212 % (asArgs[iArg],)); 213 if self.uGadgetPortDef <= 0: 214 raise base.InvalidOption('The "--default-gadget-port" value "%s" is zero or negative.' \ 215 % (self.uGadgetPortDef,)); 198 216 else: 199 217 return vbox.TestDriver.parseOption(self, asArgs, iArg); … … 271 289 def getGadgetParams(self, sHostname, sSpeed): 272 290 """ 273 Returns the gadget hostname and typefrom the291 Returns the gadget hostname and port from the 274 292 given hostname the test is running on and device speed we want to test. 275 293 """ … … 278 296 return kdGadgetsConfigured.get(sSpeed); 279 297 280 return ( None, None);298 return (self.sGadgetHostnameDef, self.uGadgetPortDef); 281 299 282 300 # … … 288 306 """ 289 307 # Get configured USB test devices from hostname we are running on 290 sGadgetHost, _= self.getGadgetParams(self.sHostname, sSpeed);308 sGadgetHost, uGadgetPort = self.getGadgetParams(self.sHostname, sSpeed); 291 309 292 310 oUsbGadget = usbgadget2.UsbGadget(); 293 311 reporter.log('Connecting to UTS: ' + sGadgetHost); 294 fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost );312 fRc = oUsbGadget.connectTo(30 * 1000, sGadgetHost, uPort = uGadgetPort); 295 313 if fRc is True: 296 314 reporter.log('Connect succeeded'); -
trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py
r60488 r60522 37 37 sys.path.insert(0, '.'); 38 38 sys.path.insert(0, '..'); 39 sys.path.insert(0, '../..'); 39 40 import usbgadget2 as usbgadget; 40 41 import testdriver.reporter as reporter … … 98 99 99 100 if fStdTests: 101 if oGadget.getUsbIpPort() is not None: 102 rc = True; 103 else: 104 rc = False; 105 print '%s: getUsbIpPort() -> %s' % (boolRes(rc), oGadget.getUsbIpPort()); 100 106 107 rc = oGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest); 108 print '%s: impersonate()' % (boolRes(rc)); 109 110 rc = oGadget.disconnectUsb(); 111 print '%s: disconnectUsb()' % (boolRes(rc)); 112 113 rc = oGadget.connectUsb(); 114 print '%s: connectUsb()' % (boolRes(rc)); 115 116 rc = oGadget.clearImpersonation(); 117 print '%s: clearImpersonation()' % (boolRes(rc)); 101 118 102 119 # Done 103 120 rc = oGadget.disconnectFrom(); 104 print '%s: disconnect () -> %s' % (boolRes(rc), rc);121 print '%s: disconnectFrom() -> %s' % (boolRes(rc), rc); 105 122 106 123 if g_cFailures != 0: -
trunk/src/VBox/ValidationKit/tests/usb/usbgadget2.py
r60493 r60522 758 758 def taskGadgetDestroy(self, iGadgetId): 759 759 """Destroys the given gadget handle on UTS""" 760 fRc = self.sendMsg("GDGTDTOR", (iGadgetId, ));760 fRc = self.sendMsg("GDGTDTOR", (iGadgetId, zeroByteArray(12))); 761 761 if fRc is True: 762 762 fRc = self.recvAckLogged("GDGTDTOR"); … … 765 765 def taskGadgetConnect(self, iGadgetId): 766 766 """Connects the given gadget handle on UTS""" 767 fRc = self.sendMsg("GDGTCNCT", (iGadgetId, ));767 fRc = self.sendMsg("GDGTCNCT", (iGadgetId, zeroByteArray(12))); 768 768 if fRc is True: 769 769 fRc = self.recvAckLogged("GDGTCNCT"); … … 772 772 def taskGadgetDisconnect(self, iGadgetId): 773 773 """Disconnects the given gadget handle from UTS""" 774 fRc = self.sendMsg("GDGTDCNT", (iGadgetId, ));774 fRc = self.sendMsg("GDGTDCNT", (iGadgetId, zeroByteArray(12))); 775 775 if fRc is True: 776 776 fRc = self.recvAckLogged("GDGTDCNT"); … … 877 877 """ 878 878 return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetConnect", self.taskGadgetConnect, \ 879 ( long(iGadgetId), ));879 (iGadgetId, )); 880 880 881 881 def syncGadgetConnect(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False): … … 892 892 """ 893 893 return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetDisconnect", self.taskGadgetDisconnect, \ 894 ( long(iGadgetId), ));894 (iGadgetId, )); 895 895 896 896 def syncGadgetDisconnect(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False): … … 1297 1297 self.iUsbIpPort = None; 1298 1298 1299 def _clearImpersonation(self):1299 def clearImpersonation(self): 1300 1300 """ 1301 1301 Removes the current impersonation of the gadget. … … 1305 1305 if self.idGadget is not None: 1306 1306 fRc = self.oUtsSession.syncGadgetDestroy(self.idGadget); 1307 self.idGadget = None; 1307 1308 1308 1309 return fRc; … … 1327 1328 1328 1329 # Clear any previous impersonation 1329 self. _clearImpersonation();1330 self.clearImpersonation(); 1330 1331 self.sImpersonation = sImpersonation; 1331 1332 1332 1333 fRc = False; 1333 1334 if sImpersonation == g_ksGadgetImpersonationTest: 1334 fRc = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp); 1335 fDone = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp); 1336 if fDone is True and self.oUtsSession.isSuccess(): 1337 # Get the gadget ID. 1338 _, _, abPayload = self.oUtsSession.getLastReply(); 1339 1340 fRc = True; 1341 self.idGadget = getU32(abPayload, 16); 1335 1342 else: 1336 1343 reporter.log('Invalid or unsupported impersonation'); … … 1388 1395 fRc = True; 1389 1396 1390 self. _clearImpersonation();1397 self.clearImpersonation(); 1391 1398 if self.oUtsSession is not None: 1392 1399 fRc = self.oUtsSession.syncDisconnect(); -
trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp
r58930 r60522 30 30 * Header Files * 31 31 *********************************************************************************************************************************/ 32 #include <iprt/dir.h> 32 33 #include <iprt/err.h> 34 #include <iprt/file.h> 33 35 #include <iprt/getopt.h> 34 36 #include <iprt/path.h> … … 38 40 #include <iprt/string.h> 39 41 #include <iprt/test.h> 40 #include <iprt/file.h>41 42 42 43 #include <unistd.h> … … 273 274 * Assumption is that the path looks like /dev/bus/usb/%3d/%3d. 274 275 */ 275 uint8_t uBus = 1; 276 bool fBusExists = false; 277 char aszDevPath[64]; 278 279 RT_ZERO(aszDevPath); 280 281 do 276 char *pszDevPath = NULL; 277 278 PRTDIR pDirUsb = NULL; 279 int rc = RTDirOpen(&pDirUsb, "/dev/bus/usb"); 280 if (RT_SUCCESS(rc)) 282 281 { 283 RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d", uBus); 284 285 fBusExists = RTPathExists(aszDevPath); 286 287 if (fBusExists) 282 do 288 283 { 289 /* Check every device. */ 290 bool fDevExists = false; 291 uint8_t uDev = 1; 292 293 do 284 RTDIRENTRY DirUsbBus; 285 rc = RTDirRead(pDirUsb, &DirUsbBus, NULL); 286 if (RT_SUCCESS(rc)) 294 287 { 295 RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d/%03d", uBus, uDev); 296 297 fDevExists = RTPathExists(aszDevPath); 298 299 if (fDevExists) 288 char aszPath[RTPATH_MAX + 1]; 289 RTStrPrintf(&aszPath[0], RT_ELEMENTS(aszPath), "/dev/bus/usb/%s", DirUsbBus.szName); 290 291 PRTDIR pDirUsbBus = NULL; 292 rc = RTDirOpen(&pDirUsbBus, &aszPath[0]); 293 if (RT_SUCCESS(rc)) 300 294 { 301 RTFILE hFileDev; 302 int rc = RTFileOpen(&hFileDev, aszDevPath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE); 303 if (RT_SUCCESS(rc)) 295 do 304 296 { 305 USBDEVDESC DevDesc; 306 307 rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL); 308 RTFileClose(hFileDev); 309 310 if ( RT_SUCCESS(rc) 311 && DevDesc.idVendor == 0x0525 312 && DevDesc.idProduct == 0xa4a0) 313 return RTStrDup(aszDevPath); 314 } 297 RTDIRENTRY DirUsbDev; 298 rc = RTDirRead(pDirUsbBus, &DirUsbDev, NULL); 299 if (RT_SUCCESS(rc)) 300 { 301 char aszPathDev[RTPATH_MAX + 1]; 302 RTStrPrintf(&aszPathDev[0], RT_ELEMENTS(aszPathDev), "/dev/bus/usb/%s/%s", 303 DirUsbBus.szName, DirUsbDev.szName); 304 305 RTFILE hFileDev; 306 rc = RTFileOpen(&hFileDev, aszPathDev, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE); 307 if (RT_SUCCESS(rc)) 308 { 309 USBDEVDESC DevDesc; 310 311 rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL); 312 RTFileClose(hFileDev); 313 314 if ( RT_SUCCESS(rc) 315 && DevDesc.idVendor == 0x0525 316 && DevDesc.idProduct == 0xa4a0) 317 pszDevPath = RTStrDup(aszPathDev); 318 } 319 320 rc = VINF_SUCCESS; 321 } 322 else if (rc != VERR_NO_MORE_FILES) 323 rc = VINF_SUCCESS; 324 325 } while ( RT_SUCCESS(rc) 326 && !pszDevPath); 327 328 rc = VINF_SUCCESS; 329 RTDirClose(pDirUsbBus); 315 330 } 316 317 uDev++; 318 } while (fDevExists); 319 } 320 321 uBus++; 322 } while (fBusExists); 323 324 return NULL; 331 } 332 else if (rc != VERR_NO_MORE_FILES) 333 rc = VINF_SUCCESS; 334 } while ( RT_SUCCESS(rc) 335 && !pszDevPath); 336 337 RTDirClose(pDirUsb); 338 } 339 340 return pszDevPath; 325 341 } 326 342 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp
r60517 r60522 832 832 rc = utsDoGadgetCreate(pClient, pPktHdr); 833 833 else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_DESTROY)) 834 rc = utsDoGadget Create(pClient, pPktHdr);834 rc = utsDoGadgetDestroy(pClient, pPktHdr); 835 835 else if (utsIsSameOpcode(pPktHdr, UTSPKT_OPCODE_GADGET_CONNECT)) 836 836 rc = utsDoGadgetConnect(pClient, pPktHdr); -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp
r60517 r60522 32 32 #include <iprt/string.h> 33 33 #include <iprt/symlink.h> 34 #include <iprt/thread.h> 34 35 #include <iprt/types.h> 35 36 … … 359 360 if (RT_SUCCESS(rc)) 360 361 rc = RTLinuxSysFsWriteStrFile(pClass->pszUdc, 0, NULL, "%s/UDC", pClass->pszGadgetPath); 362 if (RT_SUCCESS(rc)) 363 RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */ 361 364 } 362 365 } … … 406 409 static DECLCALLBACK(int) utsGadgetClassTestConnect(PUTSGADGETCLASSINT pClass) 407 410 { 408 return RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc); 411 int rc = RTLinuxSysFsWriteStrFile("connect", 0, NULL, "/sys/class/udc/%s/soft_connect", pClass->pszUdc); 412 if (RT_SUCCESS(rc)) 413 RTThreadSleep(500); /* Fudge: Sleep a bit to give the device a chance to appear on the host so binding succeeds. */ 414 415 return rc; 409 416 } 410 417 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServicePlatform-linux.cpp
r60518 r60522 178 178 g_paDummyHcd[idxHcdCur].uBusId = uBusId; 179 179 g_paDummyHcd[idxHcdCur].fAvailable = true; 180 idxHcdCur++; 180 181 } 181 182 } … … 300 301 pszIdx++; 301 302 uint32_t idxHcd = 0; 302 rc = RTStrToUInt32Ex(psz Udc, NULL, 10, &idxHcd);303 rc = RTStrToUInt32Ex(pszIdx, NULL, 10, &idxHcd); 303 304 if (RT_SUCCESS(rc)) 304 305 {
Note:
See TracChangeset
for help on using the changeset viewer.