Changeset 78667 in vbox for trunk/src/VBox
- Timestamp:
- May 22, 2019 3:42:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/serial/SerialTest.cpp
r76553 r78667 157 157 {"--tests", 't', RTGETOPT_REQ_STRING }, 158 158 {"--txbytes", 'x', RTGETOPT_REQ_UINT32 }, 159 {"--abort-on-error", 'a', RTGETOPT_REQ_NOTHING}, 159 160 {"--verbose", 'v', RTGETOPT_REQ_NOTHING}, 160 161 {"--help", 'h', RTGETOPT_REQ_NOTHING} … … 188 189 /** Number of bytes to transmit for read/write tests. */ 189 190 static size_t g_cbTx = _1M; 191 /** Flag whether to abort the tool when encountering the first error. */ 192 static bool g_fAbortOnError = false; 190 193 /** The config used. */ 191 194 static RTSERIALPORTCFG g_SerialPortCfg = … … 203 206 204 207 /** 208 * RTTestFailed() wrapper which aborts the program if the option is set. 209 */ 210 static void serialTestFailed(RTTEST hTest, const char *pszFmt, ...) 211 { 212 va_list va; 213 va_start(va, pszFmt); 214 RTTestFailedV(hTest, pszFmt, va); 215 va_end(va); 216 if (g_fAbortOnError) 217 RT_BREAKPOINT(); 218 } 219 220 221 /** 205 222 * Initializes a TX buffer. 206 223 * … … 344 361 fFailed = true; 345 362 if (g_cVerbosity > 0) 346 RTTestFailed(hTest, "Data corruption/loss detected, expected counter value %u got %u\n",347 pSerBuf->iCnt, u32Val);363 serialTestFailed(hTest, "Data corruption/loss detected, expected counter value %u got %u\n", 364 pSerBuf->iCnt, u32Val); 348 365 } 349 366 } … … 352 369 { 353 370 fFailed = true; 354 RTTestFailed(hTest, "Overtook the send buffer, expected maximum counter value %u got %u\n",355 iCntTx, pSerBuf->iCnt);371 serialTestFailed(hTest, "Overtook the send buffer, expected maximum counter value %u got %u\n", 372 iCntTx, pSerBuf->iCnt); 356 373 } 357 374 … … 372 389 return RTRandAdvU32Ex(g_hRand, 0, 1) == 1; 373 390 } 391 374 392 375 393 /** … … 415 433 { 416 434 fFailed = true; 417 RTTestFailed(pSerialTest->hTest, "Data corruption/loss detected\n");435 serialTestFailed(pSerialTest->hTest, "Data corruption/loss detected\n"); 418 436 } 419 437 } … … 523 541 if (RT_FAILURE(rc)) 524 542 { 525 RTTestFailed(g_hTest, "Changing status lines failed with %Rrc on iteration %u (fSet=%#x fClear=%#x)\n",526 rc, i, fStsLinesSet, fStsLinesClear);543 serialTestFailed(g_hTest, "Changing status lines failed with %Rrc on iteration %u (fSet=%#x fClear=%#x)\n", 544 rc, i, fStsLinesSet, fStsLinesClear); 527 545 break; 528 546 } … … 535 553 && (rc != VERR_TIMEOUT && !fStsLinesSet && !fStsLinesClear)) 536 554 { 537 RTTestFailed(g_hTest, "Waiting for status line change failed with %Rrc on iteration %u\n",538 rc, i);555 serialTestFailed(g_hTest, "Waiting for status line change failed with %Rrc on iteration %u\n", 556 rc, i); 539 557 break; 540 558 } … … 544 562 if (RT_FAILURE(rc)) 545 563 { 546 RTTestFailed(g_hTest, "Querying status lines failed with %Rrc on iteration %u\n",547 rc, i);564 serialTestFailed(g_hTest, "Querying status lines failed with %Rrc on iteration %u\n", 565 rc, i); 548 566 break; 549 567 } … … 555 573 if ( (fStsLinesQueried & RTSERIALPORT_STS_LINE_DSR) 556 574 && !(fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 557 RTTestFailed(g_hTest, "DSR line got set when it shouldn't be on iteration %u\n", i);575 serialTestFailed(g_hTest, "DSR line got set when it shouldn't be on iteration %u\n", i); 558 576 else if ( !(fStsLinesQueried & RTSERIALPORT_STS_LINE_DSR) 559 577 && !(fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 560 RTTestFailed(g_hTest, "DSR line got cleared when it shouldn't be on iteration %u\n", i);578 serialTestFailed(g_hTest, "DSR line got cleared when it shouldn't be on iteration %u\n", i); 561 579 } 562 580 else if ( (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR) 563 581 || (fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 564 RTTestFailed(g_hTest, "DSR line didn't change when it should have on iteration %u\n", i);582 serialTestFailed(g_hTest, "DSR line didn't change when it should have on iteration %u\n", i); 565 583 566 584 if ( (fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD) … … 569 587 if ( (fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD) 570 588 && !(fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 571 RTTestFailed(g_hTest, "DCD line got set when it shouldn't be on iteration %u\n", i);589 serialTestFailed(g_hTest, "DCD line got set when it shouldn't be on iteration %u\n", i); 572 590 else if ( !(fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD) 573 591 && !(fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 574 RTTestFailed(g_hTest, "DCD line got cleared when it shouldn't be on iteration %u\n", i);592 serialTestFailed(g_hTest, "DCD line got cleared when it shouldn't be on iteration %u\n", i); 575 593 } 576 594 else if ( (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR) 577 595 || (fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_DTR)) 578 RTTestFailed(g_hTest, "DCD line didn't change when it should have on iteration %u\n", i);596 serialTestFailed(g_hTest, "DCD line didn't change when it should have on iteration %u\n", i); 579 597 580 598 if ( (fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS) … … 583 601 if ( (fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS) 584 602 && !(fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_RTS)) 585 RTTestFailed(g_hTest, "CTS line got set when it shouldn't be on iteration %u\n", i);603 serialTestFailed(g_hTest, "CTS line got set when it shouldn't be on iteration %u\n", i); 586 604 else if ( !(fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS) 587 605 && !(fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_RTS)) 588 RTTestFailed(g_hTest, "CTS line got cleared when it shouldn't be on iteration %u\n", i);606 serialTestFailed(g_hTest, "CTS line got cleared when it shouldn't be on iteration %u\n", i); 589 607 } 590 608 else if ( (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_RTS) 591 609 || (fStsLinesClear & RTSERIALPORT_CHG_STS_LINES_F_RTS)) 592 RTTestFailed(g_hTest, "CTS line didn't change when it should have on iteration %u\n", i);610 serialTestFailed(g_hTest, "CTS line didn't change when it should have on iteration %u\n", i); 593 611 594 612 if (RTTestErrorCount(g_hTest) > 0) … … 601 619 } 602 620 else 603 RTTestFailed(g_hTest, "Status lines active which should be clear (%#x, but expected %#x)\n",604 fStsLinesQueriedOld, 0);621 serialTestFailed(g_hTest, "Status lines active which should be clear (%#x, but expected %#x)\n", 622 fStsLinesQueriedOld, 0); 605 623 } 606 624 else 607 RTTestFailed(g_hTest, "Querying status lines failed with %Rrc\n", rc);625 serialTestFailed(g_hTest, "Querying status lines failed with %Rrc\n", rc); 608 626 } 609 627 else 610 RTTestFailed(g_hTest, "Clearing status lines failed with %Rrc\n", rc);628 serialTestFailed(g_hTest, "Clearing status lines failed with %Rrc\n", rc); 611 629 } 612 630 else … … 856 874 g_cbTx = ValueUnion.u32; 857 875 break; 876 case 'a': 877 g_fAbortOnError = true; 878 break; 858 879 default: 859 880 return RTGetOptPrintError(rc, &ValueUnion); … … 909 930 rc = RTSerialPortOpen(&g_hSerialPortSecondary, pszDeviceSecondary, fFlags); 910 931 if (RT_FAILURE(rc)) 911 RTTestFailed(g_hTest, "Opening secondary device \"%s\" failed with %Rrc\n", pszDevice, rc);932 serialTestFailed(g_hTest, "Opening secondary device \"%s\" failed with %Rrc\n", pszDevice, rc); 912 933 } 913 934 … … 924 945 rc = RTSerialPortCfgSet(g_hSerialPortSecondary, &g_SerialPortCfg, NULL); 925 946 if (RT_FAILURE(rc)) 926 RTTestFailed(g_hTest, "Setting configuration of secondary device \"%s\" failed with %Rrc\n", pszDevice, rc);947 serialTestFailed(g_hTest, "Setting configuration of secondary device \"%s\" failed with %Rrc\n", pszDevice, rc); 927 948 } 928 949 … … 942 963 if ( RT_FAILURE(rc) 943 964 || RTTestErrorCount(g_hTest) > 0) 944 RTTestFailed(g_hTest, "Running test \"%s\" failed (%Rrc, cErrors=%u)\n",945 pTest->pszId, rc, RTTestErrorCount(g_hTest));965 serialTestFailed(g_hTest, "Running test \"%s\" failed (%Rrc, cErrors=%u)\n", 966 pTest->pszId, rc, RTTestErrorCount(g_hTest)); 946 967 947 968 RTTestSubDone(g_hTest); … … 951 972 } 952 973 else 953 RTTestFailed(g_hTest, "Setting configuration of device \"%s\" failed with %Rrc\n", pszDevice, rc);974 serialTestFailed(g_hTest, "Setting configuration of device \"%s\" failed with %Rrc\n", pszDevice, rc); 954 975 955 976 RTSerialPortClose(g_hSerialPort); … … 957 978 } 958 979 else 959 RTTestFailed(g_hTest, "Opening device \"%s\" failed with %Rrc\n", pszDevice, rc);980 serialTestFailed(g_hTest, "Opening device \"%s\" failed with %Rrc\n", pszDevice, rc); 960 981 } 961 982 else 962 RTTestFailed(g_hTest, "No device given on command line\n");983 serialTestFailed(g_hTest, "No device given on command line\n"); 963 984 964 985 RTRandAdvDestroy(g_hRand);
Note:
See TracChangeset
for help on using the changeset viewer.