Changeset 86015 in vbox for trunk/src/VBox/ValidationKit/utils/serial/SerialTest.cpp
- Timestamp:
- Sep 3, 2020 8:05:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/serial/SerialTest.cpp
r85121 r86015 165 165 static DECLCALLBACK(int) serialTestRunReadWrite(PSERIALTEST pSerialTest); 166 166 static DECLCALLBACK(int) serialTestRunWrite(PSERIALTEST pSerialTest); 167 static DECLCALLBACK(int) serialTestRunReadVerify(PSERIALTEST pSerialTest); 167 168 static DECLCALLBACK(int) serialTestRunStsLines(PSERIALTEST pSerialTest); 168 169 … … 170 171 static const SERIALTESTDESC g_aSerialTests[] = 171 172 { 172 {"readwrite", "Simple Read/Write test on the same serial port", serialTestRunReadWrite }, 173 {"write", "Simple write test (verification done somewhere else)", serialTestRunWrite }, 174 {"stslines", "Testing the status line setting and receiving", serialTestRunStsLines } 173 {"readwrite", "Simple Read/Write test on the same serial port", serialTestRunReadWrite }, 174 {"write", "Simple write test (verification done somewhere else)", serialTestRunWrite }, 175 {"readverify", "Counterpart to write test (reads and verifies data)", serialTestRunReadVerify }, 176 {"stslines", "Testing the status line setting and receiving", serialTestRunStsLines } 175 177 }; 176 178 … … 345 347 * @param hTest The test handle to report errors to. 346 348 * @param pSerBuf The RX buffer pointer. 347 * @param iCntTx The current TX counter value the RX buffer should never get ahead of. 349 * @param iCntTx The current TX counter value the RX buffer should never get ahead of, 350 * UINT32_MAX disables this check. 348 351 */ 349 352 static bool serialTestRxBufVerify(RTTEST hTest, PSERIALTESTTXRXBUFCNT pSerBuf, uint32_t iCntTx) … … 475 478 if (fEvts & RTSERIALPORT_EVT_F_DATA_TX) 476 479 rc = serialTestTxBufSend(pSerialTest->hSerialPort, &SerBufTx); 480 } 481 482 uint64_t tsRuntime = RTTimeNanoTS() - tsStart; 483 size_t cNsPerByte = tsRuntime / g_cbTx; 484 uint64_t cbBytesPerSec = RT_NS_1SEC / cNsPerByte; 485 RTTestValue(pSerialTest->hTest, "Throughput", cbBytesPerSec, RTTESTUNIT_BYTES_PER_SEC); 486 487 return rc; 488 } 489 490 491 /** 492 * Runs the counterpart to the write test, reading and verifying data. 493 * 494 * @returns IPRT status code. 495 * @param pSerialTest The serial test configuration. 496 */ 497 static DECLCALLBACK(int) serialTestRunReadVerify(PSERIALTEST pSerialTest) 498 { 499 int rc = VINF_SUCCESS; 500 uint64_t tsStart = RTTimeNanoTS(); 501 bool fFailed = false; 502 SERIALTESTTXRXBUFCNT SerBufRx; 503 504 serialTestRxBufInit(&SerBufRx, g_cbTx); 505 506 while ( RT_SUCCESS(rc) 507 && SerBufRx.cbTxRxLeft) 508 { 509 uint32_t fEvts = 0; 510 uint32_t fEvtsQuery = RTSERIALPORT_EVT_F_DATA_RX; 511 512 rc = RTSerialPortEvtPoll(pSerialTest->hSerialPort, fEvtsQuery, &fEvts, RT_INDEFINITE_WAIT); 513 if (RT_FAILURE(rc)) 514 break; 515 516 if (fEvts & RTSERIALPORT_EVT_F_DATA_RX) 517 { 518 rc = serialTestRxBufRecv(pSerialTest->hSerialPort, &SerBufRx); 519 if (RT_FAILURE(rc)) 520 break; 521 522 bool fRes = serialTestRxBufVerify(pSerialTest->hTest, &SerBufRx, UINT32_MAX); 523 if (fRes && !fFailed) 524 { 525 fFailed = true; 526 serialTestFailed(pSerialTest->hTest, "Data corruption/loss detected\n"); 527 } 528 } 477 529 } 478 530
Note:
See TracChangeset
for help on using the changeset viewer.