VirtualBox

Ignore:
Timestamp:
Jan 28, 2018 8:19:53 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit/SerialTest: Add write only test

File:
1 edited

Legend:

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

    r70652 r70761  
    138138
    139139static DECLCALLBACK(int) serialTestRunReadWrite(PSERIALTEST pSerialTest);
     140static DECLCALLBACK(int) serialTestRunWrite(PSERIALTEST pSerialTest);
    140141
    141142/** Implemented tests. */
    142143static const SERIALTESTDESC g_aSerialTests[] =
    143144{
    144     {"readwrite", "Simple Read/Write test", serialTestRunReadWrite }
     145    {"readwrite", "Simple Read/Write test on the same serial port",       serialTestRunReadWrite },
     146    {"write",     "Simple write test (verification done somewhere else)", serialTestRunWrite },
    145147};
    146148
     
    364366        if (   RT_SUCCESS(rc)
    365367            && (fEvts & RTSERIALPORT_EVT_F_DATA_TX))
     368            rc = serialTestTxBufSend(pSerialTest->hSerialPort, &SerBufTx);
     369    }
     370
     371    uint64_t tsRuntime = RTTimeMilliTS() - tsStart;
     372    tsRuntime /= 1000; /* Seconds */
     373    RTTestValue(pSerialTest->hTest, "Throughput", g_cbTx / tsRuntime, RTTESTUNIT_BYTES_PER_SEC);
     374
     375    return rc;
     376}
     377
     378
     379/**
     380 * Runs a simple write test without doing any verification.
     381 *
     382 * @returns IPRT status code.
     383 * @param   pSerialTest         The serial test configuration.
     384 */
     385static DECLCALLBACK(int) serialTestRunWrite(PSERIALTEST pSerialTest)
     386{
     387    uint64_t tsStart = RTTimeMilliTS();
     388    SERIALTESTTXRXBUFCNT SerBufTx;
     389
     390    serialTestTxBufInit(&SerBufTx, g_cbTx);
     391
     392    int rc = serialTestTxBufSend(pSerialTest->hSerialPort, &SerBufTx);
     393    while (   RT_SUCCESS(rc)
     394           && SerBufTx.cbTxRxLeft)
     395    {
     396        uint32_t fEvts = 0;
     397
     398        rc = RTSerialPortEvtPoll(pSerialTest->hSerialPort, RTSERIALPORT_EVT_F_DATA_TX, &fEvts, RT_INDEFINITE_WAIT);
     399        if (RT_FAILURE(rc))
     400            break;
     401
     402        if (fEvts & RTSERIALPORT_EVT_F_DATA_TX)
    366403            rc = serialTestTxBufSend(pSerialTest->hSerialPort, &SerBufTx);
    367404    }
     
    645682                    {
    646683                        RTTestSub(g_hTest, "Setting serial port configuration for loopback device");
    647                         rc = RTSerialPortCfgSet(g_hSerialPortLoopback,&g_SerialPortCfg ,NULL);
     684                        rc = RTSerialPortCfgSet(g_hSerialPortLoopback, &g_SerialPortCfg, NULL);
    648685                        if (RT_FAILURE(rc))
    649686                            RTTestFailed(g_hTest, "Setting configuration of loopback device \"%s\" failed with %Rrc\n", pszDevice, rc);
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