VirtualBox

Ignore:
Timestamp:
Sep 4, 2008 8:10:06 PM (16 years ago)
Author:
vboxsync
Message:

iprt: Updated tstMp-1 with the RTMp*Present* stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstMp-1.cpp

    r10453 r12107  
    5050    RTPrintf("tstMp-1: TESTING...\n");
    5151
    52 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS) || defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
    5352    /*
    5453     * Present and possible CPUs.
     
    8079            if (RTCpuSetIsMemberByIndex(&Set, iCpu))
    8180            {
    82                 RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
    83                          RTMpGetMaxFrequency(idCpu), RTMpIsCpuOnline(idCpu) ? "online" : "offline");
     81                RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz", iCpu, (int)idCpu,
     82                         RTMpGetCurFrequency(idCpu), RTMpGetMaxFrequency(idCpu));
     83                if (RTMpIsCpuPresent(idCpu))
     84                    RTPrintf(RTMpIsCpuOnline(idCpu) ? " online\n" : " offline\n");
     85                else
     86                {
     87                    if (!RTMpIsCpuOnline(idCpu))
     88                        RTPrintf(" absent\n");
     89                    else
     90                    {
     91                        RTPrintf(" online but absent!\n");
     92                        RTPrintf("tstMp-1: FAILURE: Cpu with index %d is report as !RTIsCpuPresent while RTIsCpuOnline returns true!\n", iCpu);
     93                        g_cErrors++;
     94                    }
     95                }
    8496                if (!RTMpIsCpuPossible(idCpu))
    8597                {
     
    172184    }
    173185
    174 #else
    175     RTPrintf("tstMp-1: SKIPPED - RTMp is not implemented on this host OS.\n");
    176 #endif
     186    /*
     187     * Present CPUs.
     188     */
     189    RTCPUID cCpusPresent = RTMpGetPresentCount();
     190    if (cCpusPresent > 0)
     191    {
     192        if (    cCpusPresent <= cCpus
     193            &&  cCpusPresent >= cCpusOnline)
     194            RTPrintf("tstMp-1: RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
     195        else
     196        {
     197            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentCount -> %d, expected <= %d and >= %d\n", (int)cCpusPresent, (int)cCpus, (int)cCpusOnline);
     198            g_cErrors++;
     199        }
     200    }
     201    else
     202    {
     203        RTPrintf("tstMp-1: FAILURE: RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
     204        g_cErrors++;
     205        cCpusPresent = 1;
     206    }
     207
     208    RTCPUSET SetPresent;
     209    pSet = RTMpGetPresentSet(&SetPresent);
     210    if (pSet == &SetPresent)
     211    {
     212        if (RTCpuSetCount(&SetPresent) <= 0)
     213        {
     214            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet returned an empty set!\n");
     215            g_cErrors++;
     216        }
     217        else if ((RTCPUID)RTCpuSetCount(&SetPresent) != cCpusPresent)
     218        {
     219            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet returned a bad value; %d, expected = %d\n",
     220                     RTCpuSetCount(&SetPresent), cCpusPresent);
     221            g_cErrors++;
     222        }
     223        RTPrintf("tstMp-1: Present CPU mask:\n");
     224        for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
     225            if (RTCpuSetIsMemberByIndex(&SetPresent, iCpu))
     226            {
     227                RTCPUID idCpu = RTMpCpuIdFromSetIndex(iCpu);
     228                RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
     229                         RTMpGetMaxFrequency(idCpu), RTMpIsCpuPresent(idCpu) ? "present" : "absent");
     230                if (!RTCpuSetIsMemberByIndex(&Set, iCpu))
     231                {
     232                    RTPrintf("tstMp-1: FAILURE: online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
     233                    g_cErrors++;
     234                }
     235            }
     236
     237        /* There isn't any sane way of testing RTMpIsCpuPresent really... :-/ */
     238    }
     239    else
     240    {
     241        RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet -> %p, expected %p\n", pSet, &Set);
     242        g_cErrors++;
     243    }
     244
     245
    177246
    178247    if (!g_cErrors)
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