VirtualBox

Changeset 10947 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 29, 2008 6:27:35 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33813
Message:

tstOnce: extended the checks a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstOnce.cpp

    r10940 r10947  
    4747static int g_cErrors = 0;
    4848static bool g_fOnceCB1 = false;
    49 static uint32_t volatile g_cOnceCB2 = 0;
     49static uint32_t volatile g_cOnce2CB = 0;
     50static bool volatile g_fOnce2Ready = false;
    5051static RTONCE g_Once2 = RTONCE_INITIALIZER;
    5152static RTSEMEVENTMULTI g_hEventMulti = NIL_RTSEMEVENTMULTI;
     
    6869static DECLCALLBACK(int) Once2CB(void *pvUser1, void *pvUser2)
    6970{
    70     if (ASMAtomicIncU32(&g_cOnceCB2) != 1)
     71    if (ASMAtomicIncU32(&g_cOnce2CB) != 1)
    7172    {
    72         RTPrintf("tstOnce: ERROR - Once2CB: g_cOnceCB2 not zero!\n");
     73        RTPrintf("tstOnce: ERROR - Once2CB: g_cOnce2CB not zero!\n");
    7374        g_cErrors++;
    7475        return VERR_WRONG_ORDER;
     
    8081        return VERR_INVALID_PARAMETER;
    8182    }
     83    RTThreadSleep(2);
     84    Assert(!g_fOnce2Ready);
     85    ASMAtomicWriteBool(&g_fOnce2Ready, true);
    8286    return VINF_SUCCESS;
    8387}
     
    9094    if (RT_FAILURE(rc))
    9195        return rc;
    92     return RTOnce(&g_Once2, Once2CB, (void *)42, (void *)1);
     96    rc = RTOnce(&g_Once2, Once2CB, (void *)42, (void *)1);
     97    if (RT_SUCCESS(rc))
     98    {
     99        if (!ASMAtomicUoReadBool(&g_fOnce2Ready))
     100        {
     101            RTPrintf("tstOnce: ERROR - Once2CB: Not initialized!\n");
     102            g_cErrors++;
     103        }
     104    }
     105    return rc;
    93106}
    94107
     
    97110{
    98111    RTR3Init();
    99     RTPrintf("tstOnce: SUCCESS\n");
    100112
    101113    /*
    102114     * Just a simple testcase.
    103115     */
     116    RTPrintf("tstOnce: TESTING - smoke...\n");
    104117    RTONCE Once1 = RTONCE_INITIALIZER;
    105118    g_fOnceCB1 = false;
     
    115128     * Throw a bunch of threads up against a init once thing.
    116129     */
     130    RTPrintf("tstOnce: TESTING - bunch of threads...\n");
    117131    /* create the semaphore they'll be waiting on. */
    118132    rc = RTSemEventMultiCreate(&g_hEventMulti);
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