VirtualBox

Changeset 33032 in vbox


Ignore:
Timestamp:
Oct 11, 2010 9:30:34 AM (14 years ago)
Author:
vboxsync
Message:

tstSupSem.cpp: Some more tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/testcase/tstSupSem.cpp

    r33011 r33032  
    55
    66/*
    7  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2009-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040#include <iprt/env.h>
    4141#include <iprt/string.h>
     42#include <iprt/time.h>
    4243
    4344
     
    230231    /*
    231232     * Fork test.
    232      * Spawn a thread waiting for an event, then spawn a new child process (of ourselves)
    233      * and make sure that this does not alter the intended behaviour of our event semaphore implementation (see #5090).
     233     * Spawn a thread waiting for an event, then spawn a new child process (of
     234     * ourselves) and make sure that this does not alter the intended behaviour
     235     * of our event semaphore implementation (see #5090).
    234236     */
    235237    RTTestSub(hTest, "SRE Process Spawn");
     
    280282
    281283#endif /* !OS2 && !WINDOWS */
     284
     285    if (RTTestErrorCount(hTest) == 0)
     286    {
     287        RTTestSub(hTest, "MRE Timeout Accuracy");
     288        RTTESTI_CHECK_RC(SUPSemEventMultiCreate(pSession, &hEvent), VINF_SUCCESS);
     289
     290        static unsigned const s_acMsIntervals[] = { 0, 1, 2, 3, 4, 8, 10, 16, 32 };
     291        for (unsigned i = 0; i < RT_ELEMENTS(s_acMsIntervals); i++)
     292        {
     293            uint64_t cMs        = s_acMsIntervals[i];
     294            uint64_t cNsMinSys  = UINT64_MAX;
     295            uint64_t cNsMin     = UINT64_MAX;
     296            uint64_t cNsTotalSys= 0;
     297            uint64_t cNsTotal   = 0;
     298            for (unsigned j = 0; j < 10; j++)
     299            {
     300                uint64_t u64StartSys = RTTimeSystemNanoTS();
     301                uint64_t u64Start    = RTTimeNanoTS();
     302                int rcX = SUPSemEventMultiWaitNoResume(pSession, hEvent, cMs);
     303                if (rc == VERR_TIMEOUT)
     304                    RTTestFailed(hTest, "%Rrc j=%u cMs=%u", rcX, j, cMs);
     305                uint64_t cNsElapsedSys = RTTimeSystemNanoTS() - u64StartSys;
     306                uint64_t cNsElapsed    = RTTimeNanoTS()       - u64Start;
     307                if (cNsElapsedSys < cNsMinSys)
     308                    cNsMinSys = cNsElapsedSys;
     309                if (cNsElapsed < cNsMin)
     310                    cNsMin = cNsElapsed;
     311                cNsTotalSys += cNsElapsedSys;
     312                cNsTotal    += cNsElapsed;
     313            }
     314            RTTestValueF(hTest, cNsMinSys, RTTESTUNIT_NS, "%u ms min (clock=sys)", cMs);
     315            RTTestValueF(hTest, cNsTotalSys / 10, RTTESTUNIT_NS, "%u ms avg - (clock=sys)", cMs);
     316            RTTestValueF(hTest, cNsMin, RTTESTUNIT_NS, "%u ms min (clock=gip)", cMs);
     317            RTTestValueF(hTest, cNsTotal / 10, RTTESTUNIT_NS, "%u ms avg - (clock=gip)", cMs);
     318        }
     319
     320        RTTESTI_CHECK_RC(SUPSemEventMultiClose(pSession, hEvent), VINF_OBJECT_DESTROYED);
     321    }
     322
    282323
    283324    /*
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