Changeset 58930 in vbox for trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp
- Timestamp:
- Nov 30, 2015 10:45:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/usb/UsbTest.cpp
r58907 r58930 108 108 #define USBTEST_REQUEST _IOWR('U', 100, USBTESTPARMS) 109 109 110 /** 111 * Callback to set up the test parameters for a specific test. 112 * 113 * @returns IPRT status code. 114 * @retval VINF_SUCCESS if setting the parameters up succeeded. Any other error code 115 * otherwise indicating the kind of error. 116 * @param idxTest The test index. 117 * @param pszTest Test name. 118 * @param pParams The USB test parameters to set up. 119 */ 120 typedef DECLCALLBACK(int) FNUSBTESTPARAMSSETUP(unsigned idxTest, const char *pszTest, PUSBTESTPARAMS pParams); 121 /** Pointer to a USB test parameters setup callback. */ 122 typedef FNUSBTESTPARAMSSETUP *PFNUSBTESTPARAMSSETUP; 123 124 /** 125 * USB test descriptor. 126 */ 127 typedef struct USBTESTDESC 128 { 129 /** (Sort of) Descriptive test name. */ 130 const char *pszName; 131 /** Flag whether the test is excluded. */ 132 bool fExcluded; 133 /** The parameter setup callback. */ 134 PFNUSBTESTPARAMSSETUP pfnParamsSetup; 135 } USBTESTDESC; 136 /** Pointer a USB test descriptor. */ 137 typedef USBTESTDESC *PUSBTESTDESC; 110 138 111 139 /********************************************************************************************************************************* 112 140 * Global Variables * 113 141 *********************************************************************************************************************************/ 142 143 /** Some forward method declarations. */ 144 static DECLCALLBACK(int) usbTestParamsSetupReadWrite(unsigned idxTest, const char *pszTest, PUSBTESTPARAMS pParams); 145 static DECLCALLBACK(int) usbTestParamsSetupControlWrites(unsigned idxTest, const char *pszTest, PUSBTESTPARAMS pParams); 114 146 115 147 /** Command line parameters */ … … 121 153 }; 122 154 123 /**124 * USB test descriptor.125 */126 typedef struct USBTESTDESC127 {128 /** (Sort of) Descriptive test name. */129 const char *pszName;130 /** Flag whether the test is excluded. */131 bool fExcluded;132 } USBTESTDESC;133 /** Pointer a USB test descriptor. */134 typedef USBTESTDESC *PUSBTESTDESC;135 136 155 static USBTESTDESC g_aTests[] = 137 156 { 138 /* pszTest fExcluded */139 {"NOP", false },140 {"Non-queued Bulk write", false },141 {"Non-queued Bulk read", false },142 {"Non-queued Bulk write variabe size", false },143 {"Non-queued Bulk read variabe size", false },144 {"Queued Bulk write", false },145 {"Queued Bulk read", false },146 {"Queued Bulk write variabe size", false },147 {"Queued Bulk read variabe size", false },148 {"Chapter 9 Control Test", false },149 {"Queued control messaging", false },150 {"Unlink reads", false },151 {"Unlink writes", false },152 {"Set/Clear halts", false },153 {"Control writes", false },154 {"Isochronous write", false },155 {"Isochronous read", false },156 {"Bulk write unaligned (DMA)", false },157 {"Bulk read unaligned (DMA)", false },158 {"Bulk write unaligned (no DMA)", false },159 {"Bulk read unaligned (no DMA)", false },160 {"Control writes unaligned", false },161 {"Isochronous write unaligned", false },162 {"Isochronous read unaligned", false },163 {"Unlink queued Bulk", false }157 /* pszTest fExcluded pfnParamsSetup */ 158 {"NOP", false, usbTestParamsSetupReadWrite}, 159 {"Non-queued Bulk write", false, usbTestParamsSetupReadWrite}, 160 {"Non-queued Bulk read", false, usbTestParamsSetupReadWrite}, 161 {"Non-queued Bulk write variabe size", false, usbTestParamsSetupReadWrite}, 162 {"Non-queued Bulk read variabe size", false, usbTestParamsSetupReadWrite}, 163 {"Queued Bulk write", false, usbTestParamsSetupReadWrite}, 164 {"Queued Bulk read", false, usbTestParamsSetupReadWrite}, 165 {"Queued Bulk write variabe size", false, usbTestParamsSetupReadWrite}, 166 {"Queued Bulk read variabe size", false, usbTestParamsSetupReadWrite}, 167 {"Chapter 9 Control Test", false, usbTestParamsSetupReadWrite}, 168 {"Queued control messaging", false, usbTestParamsSetupReadWrite}, 169 {"Unlink reads", false, usbTestParamsSetupReadWrite}, 170 {"Unlink writes", false, usbTestParamsSetupReadWrite}, 171 {"Set/Clear halts", false, usbTestParamsSetupReadWrite}, 172 {"Control writes", false, usbTestParamsSetupControlWrites}, 173 {"Isochronous write", false, usbTestParamsSetupReadWrite}, 174 {"Isochronous read", false, usbTestParamsSetupReadWrite}, 175 {"Bulk write unaligned (DMA)", false, usbTestParamsSetupReadWrite}, 176 {"Bulk read unaligned (DMA)", false, usbTestParamsSetupReadWrite}, 177 {"Bulk write unaligned (no DMA)", false, usbTestParamsSetupReadWrite}, 178 {"Bulk read unaligned (no DMA)", false, usbTestParamsSetupReadWrite}, 179 {"Control writes unaligned", false, usbTestParamsSetupControlWrites}, 180 {"Isochronous write unaligned", false, usbTestParamsSetupReadWrite}, 181 {"Isochronous read unaligned", false, usbTestParamsSetupReadWrite}, 182 {"Unlink queued Bulk", false, usbTestParamsSetupReadWrite} 164 183 }; 165 184 … … 167 186 static RTTEST g_hTest; 168 187 169 188 /** 189 * Setup callback for basic read/write (bulk, isochronous) tests. 190 * 191 * @copydoc FNUSBTESTPARAMSSETUP 192 */ 193 static DECLCALLBACK(int) usbTestParamsSetupReadWrite(unsigned idxTest, const char *pszTest, PUSBTESTPARAMS pParams) 194 { 195 NOREF(idxTest); 196 NOREF(pszTest); 197 198 pParams->cIterations = 1000; 199 pParams->cbData = 512; 200 pParams->cbVariation = 512; 201 pParams->cSgLength = 32; 202 203 return VINF_SUCCESS; 204 } 205 206 /** 207 * Setup callback for the control writes test. 208 * 209 * @copydoc FNUSBTESTPARAMSSETUP 210 */ 211 static DECLCALLBACK(int) usbTestParamsSetupControlWrites(unsigned idxTest, const char *pszTest, PUSBTESTPARAMS pParams) 212 { 213 NOREF(idxTest); 214 NOREF(pszTest); 215 216 pParams->cIterations = 1000; 217 pParams->cbData = 512; 218 /* 219 * Must be smaller than cbData or the parameter check in the usbtest module fails, 220 * no idea yet why it must be this. 221 */ 222 pParams->cbVariation = 256; 223 pParams->cSgLength = 32; 224 225 return VINF_SUCCESS; 226 } 227 228 /** 229 * Shows tool usage text. 230 */ 170 231 static void usbTestUsage(PRTSTREAM pStrm) 171 232 { … … 292 353 RTTestPassed(g_hTest, "Opening device successful\n"); 293 354 294 /*295 * Fill params with some defaults.296 * @todo: Make them configurable.297 */298 Params.cIterations = 1000;299 Params.cbData = 512;300 Params.cbVariation = 512;301 Params.cSgLength = 32;302 303 355 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++) 304 356 { … … 311 363 } 312 364 313 Params.idxTest = i; 314 315 /* Assume the test interface has the number 0 for now. */ 316 int rcPosix = usbTestIoctl(iDevFd, 0, &Params); 317 if (rcPosix < 0 && errno == EOPNOTSUPP) 365 int rc = g_aTests[i].pfnParamsSetup(i, g_aTests[i].pszName, &Params); 366 if (RT_SUCCESS(rc)) 318 367 { 319 RTTestSkipped(g_hTest, "Not supported"); 320 continue; 368 Params.idxTest = i; 369 370 /* Assume the test interface has the number 0 for now. */ 371 int rcPosix = usbTestIoctl(iDevFd, 0, &Params); 372 if (rcPosix < 0 && errno == EOPNOTSUPP) 373 { 374 RTTestSkipped(g_hTest, "Not supported"); 375 continue; 376 } 377 378 if (rcPosix < 0) 379 RTTestFailed(g_hTest, "Test failed with %Rrc\n", RTErrConvertFromErrno(errno)); 380 else 381 { 382 uint64_t u64Ns = Params.TimeTest.tv_sec * RT_NS_1SEC + Params.TimeTest.tv_usec * RT_NS_1US; 383 RTTestValue(g_hTest, "Runtime", u64Ns, RTTESTUNIT_NS); 384 } 321 385 } 322 323 if (rcPosix < 0)324 RTTestFailed(g_hTest, "Test failed with %Rrc\n", RTErrConvertFromErrno(errno));325 386 else 326 { 327 uint64_t u64Ns = Params.TimeTest.tv_sec * RT_NS_1SEC + Params.TimeTest.tv_usec * RT_NS_1US; 328 RTTestValue(g_hTest, "Runtime", u64Ns, RTTESTUNIT_NS); 329 } 387 RTTestFailed(g_hTest, "Setting up test parameters failed with %Rrc\n", rc); 330 388 RTTestSubDone(g_hTest); 331 389 } … … 370 428 else 371 429 { 372 RTTestPrintf(g_hTest, RTTESTLVL_FAILURE, " Failed to find a test device\n");430 RTTestPrintf(g_hTest, RTTESTLVL_FAILURE, "Invalid test number passed to --exclude\n"); 373 431 RTTestErrorInc(g_hTest); 374 432 return RTGetOptPrintError(VERR_INVALID_PARAMETER, &ValueUnion); … … 387 445 /* Find the first test device if none was given. */ 388 446 if (!pszDevice) 447 { 448 RTTestSub(g_hTest, "Detecting device"); 389 449 pszDevice = usbTestFindDevice(); 450 if (!pszDevice) 451 RTTestFailed(g_hTest, "Failed to find suitable device\n"); 452 453 RTTestSubDone(g_hTest); 454 } 390 455 391 456 if (pszDevice) 392 457 usbTestExec(pszDevice); 393 else394 {395 RTTestPrintf(g_hTest, RTTESTLVL_FAILURE, "Failed to find a test device\n");396 RTTestErrorInc(g_hTest);397 }398 458 399 459 RTEXITCODE rcExit = RTTestSummaryAndDestroy(g_hTest);
Note:
See TracChangeset
for help on using the changeset viewer.