VirtualBox

Changeset 78667 in vbox for trunk/src


Ignore:
Timestamp:
May 22, 2019 3:42:14 PM (6 years ago)
Author:
vboxsync
Message:

ValidationKit/SerialTest: Add option to abort the process when the first error is hit so there is a chance to find the problemativ spot in the VM debug logs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/serial/SerialTest.cpp

    r76553 r78667  
    157157    {"--tests",            't', RTGETOPT_REQ_STRING },
    158158    {"--txbytes",          'x', RTGETOPT_REQ_UINT32 },
     159    {"--abort-on-error",   'a', RTGETOPT_REQ_NOTHING},
    159160    {"--verbose",          'v', RTGETOPT_REQ_NOTHING},
    160161    {"--help",             'h', RTGETOPT_REQ_NOTHING}
     
    188189/** Number of bytes to transmit for read/write tests. */
    189190static size_t          g_cbTx                 = _1M;
     191/** Flag whether to abort the tool when encountering the first error. */
     192static bool            g_fAbortOnError        = false;
    190193/** The config used. */
    191194static RTSERIALPORTCFG g_SerialPortCfg =
     
    203206
    204207/**
     208 * RTTestFailed() wrapper which aborts the program if the option is set.
     209 */
     210static 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/**
    205222 * Initializes a TX buffer.
    206223 *
     
    344361            fFailed = true;
    345362            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);
    348365        }
    349366    }
     
    352369    {
    353370        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);
    356373    }
    357374
     
    372389    return RTRandAdvU32Ex(g_hRand, 0, 1) == 1;
    373390}
     391
    374392
    375393/**
     
    415433            {
    416434                fFailed = true;
    417                 RTTestFailed(pSerialTest->hTest, "Data corruption/loss detected\n");
     435                serialTestFailed(pSerialTest->hTest, "Data corruption/loss detected\n");
    418436            }
    419437        }
     
    523541                        if (RT_FAILURE(rc))
    524542                        {
    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);
    527545                            break;
    528546                        }
     
    535553                            && (rc != VERR_TIMEOUT && !fStsLinesSet && !fStsLinesClear))
    536554                        {
    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);
    539557                            break;
    540558                        }
     
    544562                        if (RT_FAILURE(rc))
    545563                        {
    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);
    548566                            break;
    549567                        }
     
    555573                            if (   (fStsLinesQueried & RTSERIALPORT_STS_LINE_DSR)
    556574                                && !(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);
    558576                            else if (   !(fStsLinesQueried & RTSERIALPORT_STS_LINE_DSR)
    559577                                     && !(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);
    561579                        }
    562580                        else if (   (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR)
    563581                                 || (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);
    565583
    566584                        if (   (fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD)
     
    569587                            if (   (fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD)
    570588                                && !(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);
    572590                            else if (   !(fStsLinesQueried & RTSERIALPORT_STS_LINE_DCD)
    573591                                     && !(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);
    575593                        }
    576594                        else if (   (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_DTR)
    577595                                 || (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);
    579597
    580598                        if (   (fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS)
     
    583601                            if (   (fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS)
    584602                                && !(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);
    586604                            else if (   !(fStsLinesQueried & RTSERIALPORT_STS_LINE_CTS)
    587605                                     && !(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);
    589607                        }
    590608                        else if (   (fStsLinesSet & RTSERIALPORT_CHG_STS_LINES_F_RTS)
    591609                                 || (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);
    593611
    594612                        if (RTTestErrorCount(g_hTest) > 0)
     
    601619                }
    602620                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);
    605623            }
    606624            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);
    608626        }
    609627        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);
    611629    }
    612630    else
     
    856874                g_cbTx = ValueUnion.u32;
    857875                break;
     876            case 'a':
     877                g_fAbortOnError = true;
     878                break;
    858879            default:
    859880                return RTGetOptPrintError(rc, &ValueUnion);
     
    909930                rc = RTSerialPortOpen(&g_hSerialPortSecondary, pszDeviceSecondary, fFlags);
    910931                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);
    912933            }
    913934
     
    924945                        rc = RTSerialPortCfgSet(g_hSerialPortSecondary, &g_SerialPortCfg, NULL);
    925946                        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);
    927948                    }
    928949
     
    942963                            if (   RT_FAILURE(rc)
    943964                                || 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));
    946967
    947968                            RTTestSubDone(g_hTest);
     
    951972                }
    952973                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);
    954975
    955976                RTSerialPortClose(g_hSerialPort);
     
    957978        }
    958979        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);
    960981    }
    961982    else
    962         RTTestFailed(g_hTest, "No device given on command line\n");
     983        serialTestFailed(g_hTest, "No device given on command line\n");
    963984
    964985    RTRandAdvDestroy(g_hRand);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette