- Timestamp:
- Apr 14, 2016 1:45:31 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py
r60488 r60493 295 295 if fRc is True: 296 296 reporter.log('Connect succeeded'); 297 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost , [], []);297 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost + (':%s' % oUsbGadget.getUsbIpPort()), [], []); 298 298 299 299 # Create device filter … … 341 341 if fRc is True: 342 342 reporter.log('Connect succeeded'); 343 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost , [], []);343 self.oVBox.host.addUSBDeviceSource('USBIP', sGadgetHost, sGadgetHost + ':' + oUsbGadget.getUsbIpPort(), [], []); 344 344 345 345 # Create device filter -
trunk/src/VBox/ValidationKit/tests/usb/usbgadget2.py
r60489 r60493 416 416 return None; 417 417 abPayload.extend(u32ToByteArray(o)); 418 elif isinstance(o, types.IntType): 419 if o < 0 or o > 0xffffffff: 420 reporter.fatal('sendMsg: uint32_t payload is out of range: %s' % (hex(o))); 421 return None; 422 abPayload.extend(u32ToByteArray(o)); 418 423 elif isinstance(o, array.array): 419 424 abPayload.extend(o); … … 627 632 if sOpcode == "ACK": 628 633 return True; 629 return (sOpcode, getSZ(abPayload, 0, sOpcode));634 return (sOpcode, getSZ(abPayload, 16, sOpcode)); 630 635 631 636 def recvAckLogged(self, sCommand, fNoDataOk = False): … … 659 664 if sOpcode == "FALSE": 660 665 return False; 661 reporter.maybeErr(self.fErr, 'recvAckLogged: %s response was %s: %s' % (sCommand, sOpcode, getSZ(abPayload, 0, sOpcode)));666 reporter.maybeErr(self.fErr, 'recvAckLogged: %s response was %s: %s' % (sCommand, sOpcode, getSZ(abPayload, 16, sOpcode))); 662 667 return None; 663 668 … … 721 726 sHostname = socket.gethostname().lower(); 722 727 cbFill = 68 - len(sHostname) - 1; 723 rc = self.sendMsg("HOWDY", ( long((1 << 16) | 0), long(0x1), long(len(sHostname)), sHostname, zeroByteArray(cbFill)));728 rc = self.sendMsg("HOWDY", ((1 << 16) | 0, 0x1, len(sHostname), sHostname, zeroByteArray(cbFill))); 724 729 if rc is True: 725 730 rc = self.recvAckLogged("HOWDY", self.fTryConnect); … … 746 751 def taskGadgetCreate(self, iGadgetType, iGadgetAccess): 747 752 """Creates a new gadget on UTS""" 748 fRc = self.sendMsg("GDGTCRT", (iGadgetType, iGadgetAccess, 0 ));753 fRc = self.sendMsg("GDGTCRT", (iGadgetType, iGadgetAccess, 0, 0)); 749 754 if fRc is True: 750 755 fRc = self.recvAckLogged("GDGTCRT"); … … 842 847 """ 843 848 return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetCreate", self.taskGadgetCreate, \ 844 ( long(iGadgetType), long(iGadgetAccess)));849 (iGadgetType, iGadgetAccess)); 845 850 846 851 def syncGadgetCreate(self, iGadgetType, iGadgetAccess, cMsTimeout = 30000, fIgnoreErrors = False): … … 857 862 """ 858 863 return self.startTask(cMsTimeout, fIgnoreErrors, "GadgetDestroy", self.taskGadgetDestroy, \ 859 ( long(iGadgetId), ));864 (iGadgetId, )); 860 865 861 866 def syncGadgetDestroy(self, iGadgetId, cMsTimeout = 30000, fIgnoreErrors = False): … … 1327 1332 fRc = False; 1328 1333 if sImpersonation == g_ksGadgetImpersonationTest: 1329 fRc = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest );1334 fRc = self.oUtsSession.syncGadgetCreate(g_kiGadgetTypeTest, g_kiGadgetAccessUsbIp); 1330 1335 else: 1331 1336 reporter.log('Invalid or unsupported impersonation'); … … 1358 1363 print 'connect: waitForTask -> %s, result %s' % (fDone, self.oUtsSession.getResult()); 1359 1364 if fDone is True and self.oUtsSession.isSuccess(): 1360 fRc = True; 1365 # Parse the reply. 1366 _, _, abPayload = self.oUtsSession.getLastReply(); 1367 1368 if getU32(abPayload, 20) is g_kiGadgetAccessUsbIp: 1369 fRc = True; 1370 self.iUsbIpPort = getU32(abPayload, 24); 1371 else: 1372 reporter.log('Gadget doesn\'t support access over USB/IP despite being requested'); 1373 fRc = False; 1361 1374 else: 1362 1375 fRc = False; … … 1376 1389 1377 1390 self._clearImpersonation(); 1378 self._cleanupGadget();1379 1391 if self.oUtsSession is not None: 1380 1392 fRc = self.oUtsSession.syncDisconnect(); -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestService.cpp
r60488 r60493 566 566 else 567 567 rc = utsReplyBadSize(pClient, pPktHdr, sizeof(UTSPKTHDR)); 568 g_pTransport->pfnNotifyBye(pClient->pTransportClient);569 568 return rc; 570 569 } -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetCfg.cpp
r60303 r60493 171 171 if ( !pCfgItem 172 172 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_UINT8) 173 { 173 174 *pu8 = pCfgItem ? pCfgItem->Val.u.u8 : u8Def; 175 rc = VINF_SUCCESS; 176 } 174 177 175 178 return rc; … … 206 209 if ( !pCfgItem 207 210 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_UINT16) 211 { 208 212 *pu16 = pCfgItem ? pCfgItem->Val.u.u16 : u16Def; 213 rc = VINF_SUCCESS; 214 } 209 215 210 216 return rc; … … 241 247 if ( !pCfgItem 242 248 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_UINT32) 249 { 243 250 *pu32 = pCfgItem ? pCfgItem->Val.u.u32 : u32Def; 251 rc = VINF_SUCCESS; 252 } 244 253 245 254 return rc; … … 276 285 if ( !pCfgItem 277 286 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_UINT64) 287 { 278 288 *pu64 = pCfgItem ? pCfgItem->Val.u.u64 : u64Def; 289 rc = VINF_SUCCESS; 290 } 279 291 280 292 return rc; … … 311 323 if ( !pCfgItem 312 324 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_INT8) 325 { 313 326 *pi8 = pCfgItem ? pCfgItem->Val.u.i8 : i8Def; 327 rc = VINF_SUCCESS; 328 } 314 329 315 330 return rc; … … 346 361 if ( !pCfgItem 347 362 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_INT16) 363 { 348 364 *pi16 = pCfgItem ? pCfgItem->Val.u.i16 : i16Def; 365 rc = VINF_SUCCESS; 366 } 349 367 350 368 return rc; … … 381 399 if ( !pCfgItem 382 400 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_INT32) 401 { 383 402 *pi32 = pCfgItem ? pCfgItem->Val.u.i32 : i32Def; 403 rc = VINF_SUCCESS; 404 } 384 405 385 406 return rc; … … 416 437 if ( !pCfgItem 417 438 || pCfgItem->Val.enmType == UTSGADGETCFGTYPE_INT64) 439 { 418 440 *pi64 = pCfgItem ? pCfgItem->Val.u.i64 : i64Def; 419 420 return rc; 421 } 422 441 rc = VINF_SUCCESS; 442 } 443 444 return rc; 445 } 446 -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetClassTest.cpp
r60394 r60493 184 184 if (cbStr <= sizeof(aszPathFunc) - 1) 185 185 { 186 cbStr = RTStrPrintf(&aszPathCfg[0], sizeof(aszPathCfg), "%s/configs/%s ",187 pClass->pszGadgetPath, pszCfg );186 cbStr = RTStrPrintf(&aszPathCfg[0], sizeof(aszPathCfg), "%s/configs/%s/%s", 187 pClass->pszGadgetPath, pszCfg, pszFunc); 188 188 if (cbStr <= sizeof(aszPathCfg) - 1) 189 189 rc = RTSymlinkCreate(&aszPathCfg[0], &aszPathFunc[0], RTSYMLINKTYPE_DIR, 0); -
trunk/src/VBox/ValidationKit/utils/usb/UsbTestServiceGadgetHostUsbIp.cpp
r60488 r60493 29 29 #include <iprt/process.h> 30 30 #include <iprt/string.h> 31 #include <iprt/thread.h> 32 #include <iprt/time.h> 31 33 #include <iprt/types.h> 32 34 … … 98 100 99 101 rc = utsGadgetCfgQueryU16Def(paCfg, "UsbIp/Port", &uPort, UTS_GADGET_HOST_USBIP_PORT_DEF); 100 if (RT_ FAILURE(rc))102 if (RT_SUCCESS(rc)) 101 103 { 102 104 /* Make sure the kernel drivers are loaded. */ … … 107 109 if (RT_SUCCESS(rc)) 108 110 { 109 char aszPort[10]; 110 char aszPidFile[64]; 111 const char *apszArgv[6]; 112 113 RTStrPrintf(aszPort, RT_ELEMENTS(aszPort), "%u", uPort); 114 RTStrPrintf(aszPidFile, RT_ELEMENTS(aszPidFile), "/var/run/usbipd-%u.pid", uPort); 115 /* Start the USB/IP server process. */ 116 apszArgv[0] = "usbipd"; 117 apszArgv[1] = "--tcp-port"; 118 apszArgv[2] = aszPort; 119 apszArgv[3] = "--pid"; 120 apszArgv[4] = aszPidFile; 121 apszArgv[5] = NULL; 122 rc = RTProcCreate("usbipd", apszArgv, RTENV_DEFAULT, RTPROC_FLAGS_SEARCH_PATH, &pIf->hProcUsbIp); 111 rc = utsGadgetHostUsbIpLoadModule("libcomposite"); 123 112 if (RT_SUCCESS(rc)) 124 113 { 125 /* We are done setting it up at the moment. */ 114 char aszPort[10]; 115 char aszPidFile[64]; 116 const char *apszArgv[6]; 117 118 RTStrPrintf(aszPort, RT_ELEMENTS(aszPort), "%u", uPort); 119 RTStrPrintf(aszPidFile, RT_ELEMENTS(aszPidFile), "/var/run/usbipd-%u.pid", uPort); 120 /* Start the USB/IP server process. */ 121 apszArgv[0] = "usbipd"; 122 apszArgv[1] = "--tcp-port"; 123 apszArgv[2] = aszPort; 124 apszArgv[3] = "--pid"; 125 apszArgv[4] = aszPidFile; 126 apszArgv[5] = NULL; 127 rc = RTProcCreate("usbipd", apszArgv, RTENV_DEFAULT, RTPROC_FLAGS_SEARCH_PATH, &pIf->hProcUsbIp); 128 if (RT_SUCCESS(rc)) 129 { 130 /* Wait for a bit to make sure the server started up successfully. */ 131 uint64_t tsStart = RTTimeMilliTS(); 132 do 133 { 134 RTPROCSTATUS ProcSts; 135 rc = RTProcWait(pIf->hProcUsbIp, RTPROCWAIT_FLAGS_NOBLOCK, &ProcSts); 136 if (rc != VERR_PROCESS_RUNNING) 137 { 138 rc = VERR_INVALID_HANDLE; 139 break; 140 } 141 RTThreadSleep(1); 142 rc = VINF_SUCCESS; 143 } while (RTTimeMilliTS() - tsStart < 2 * 1000); /* 2 seconds. */ 144 } 126 145 } 127 146 } … … 138 157 static DECLCALLBACK(void) utsGadgetHostUsbIpTerm(PUTSGADGETHOSTTYPEINT pIf) 139 158 { 140 /* Kill the process . */159 /* Kill the process and wait for it to terminate. */ 141 160 RTProcTerminate(pIf->hProcUsbIp); 161 162 RTPROCSTATUS ProcSts; 163 RTProcWait(pIf->hProcUsbIp, RTPROCWAIT_FLAGS_BLOCK, &ProcSts); 142 164 } 143 165
Note:
See TracChangeset
for help on using the changeset viewer.