VirtualBox

Changeset 10419 in vbox for trunk/src/VBox/Runtime/testcase


Ignore:
Timestamp:
Jul 9, 2008 1:46:17 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33078
Message:

Linux implementation of the RTMp* bits we current need in ring-3.

Location:
trunk/src/VBox/Runtime/testcase
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/Makefile.kmk

    r10048 r10419  
    7272        tstLog \
    7373        tstMove \
     74        tstMp-1 \
    7475        tstNoCrt-1 \
    7576        tstPath \
     
    246247tstMove_SOURCES = tstMove.cpp
    247248
     249tstMp-1_SOURCES = tstMp-1.cpp
     250
    248251tstNoCrt-1_DEFS = RT_WITHOUT_NOCRT_WRAPPER_ALIASES
    249252tstNoCrt-1_SOURCES = \
  • trunk/src/VBox/Runtime/testcase/tstMp-1.cpp

    r10405 r10419  
    11/* $Id$ */
    22/** @file
    3  * IPRT Testcase - IPv4.
     3 * IPRT Testcase - RTMp.
    44 */
    55
     
    3333*   Header Files                                                               *
    3434*******************************************************************************/
    35 #include <iprt/cidr.h>
     35#include <iprt/mp.h>
     36#include <iprt/cpuset.h>
    3637#include <iprt/err.h>
    3738#include <iprt/stream.h>
     
    4243*   Defined Constants And Macros                                               *
    4344*******************************************************************************/
    44 #define CHECKNETWORK(string, expected_result, expected_network, expected_netmask) \
    45     do { \
    46         RTIPV4ADDR network, netmask; \
    47         int result = RTCidrStrToIPv4(string, &network, &netmask); \
    48         if (expected_result && !result) \
    49         { \
    50             g_cErrors++; \
    51             RTPrintf("%s, %d: %s: expected %Vrc got %Vrc\n", \
    52                     __FUNCTION__, __LINE__, string, expected_result, result); \
    53         } \
    54         else if (   expected_result != result \
    55                  || (   result == VINF_SUCCESS \
    56                      && (   expected_network != network \
    57                          || expected_netmask != netmask))) \
    58         { \
    59             g_cErrors++; \
    60             RTPrintf("%s, %d: '%s': expected %Vrc got %Vrc, expected network %08x got %08x, expected netmask %08x got %08x\n", \
    61                     __FUNCTION__, __LINE__, string, expected_result, result, expected_network, network, expected_netmask, netmask); \
    62         } \
    63     } while (0)
    64 
    6545
    6646/*******************************************************************************
     
    7353{
    7454    RTR3Init();
    75     CHECKNETWORK("10.0.0/24",                VINF_SUCCESS, 0x0A000000, 0xFFFFFF00);
    76     CHECKNETWORK("10.0.0/8",                 VINF_SUCCESS, 0x0A000000, 0xFF000000);
    77     CHECKNETWORK("10.0.0./24",     VERR_INVALID_PARAMETER,          0,          0);
    78     CHECKNETWORK("0.1.0/24",       VERR_INVALID_PARAMETER,          0,          0);
    79     CHECKNETWORK("10.255.0.0/24",  VERR_INVALID_PARAMETER,          0,          0);
    80     CHECKNETWORK("10.1234.0.0/24", VERR_INVALID_PARAMETER,          0,          0);
    81     CHECKNETWORK("10.256.0.0/24",  VERR_INVALID_PARAMETER,          0,          0);
    82     CHECKNETWORK("10.0.0/3",       VERR_INVALID_PARAMETER,          0,          0);
    83     CHECKNETWORK("10.1.2.3/8",               VINF_SUCCESS, 0x0A010203, 0xFF000000);
    84     CHECKNETWORK("10.0.0/29",      VERR_INVALID_PARAMETER,          0,          0);
    85     CHECKNETWORK("10.0.0/240",     VERR_INVALID_PARAMETER,          0,          0);
    86     CHECKNETWORK("10.0.0/24.",     VERR_INVALID_PARAMETER,          0,          0);
    87     CHECKNETWORK("10.1.2/16",                VINF_SUCCESS, 0x0A010200, 0xFFFF0000);
    88     CHECKNETWORK("1.2.3.4",                  VINF_SUCCESS, 0x01020304, 0xFFFFFFFF);
     55    RTPrintf("tstMp-1: TESTING...\n");
     56
     57#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS) || defined(RT_OS_LINUX)
     58    /*
     59     * Present and possible CPUs.
     60     */
     61    RTCPUID cCpus = RTMpGetCount();
     62    if (cCpus > 0)
     63        RTPrintf("tstMp-1: RTMpGetCount -> %d\n", (int)cCpus);
     64    else
     65    {
     66        RTPrintf("tstMp-1: FAILURE: RTMpGetCount -> %d\n", (int)cCpus);
     67        g_cErrors++;
     68        cCpus = 1;
     69    }
     70
     71    RTCPUSET Set;
     72    PRTCPUSET pSet = RTMpGetSet(&Set);
     73    if (pSet == &Set)
     74    {
     75        if ((RTCPUID)RTCpuSetCount(&Set) != cCpus)
     76        {
     77            RTPrintf("tstMp-1: FAILURE: RTMpGetSet returned a set with a different cpu count; %d, expected %d\n",
     78                     RTCpuSetCount(&Set), cCpus);
     79            g_cErrors++;
     80        }
     81        RTPrintf("tstMp-1: Possible CPU mask:\n");
     82        for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
     83        {
     84            if (RTCpuSetIsMemberByIndex(&Set, iCpu))
     85            {
     86                RTPrintf("tstMp-1: %2d - id %d\n", iCpu, RTMpCpuIdFromSetIndex(iCpu));
     87                if (!RTMpIsCpuPossible(RTMpCpuIdFromSetIndex(iCpu)))
     88                {
     89                    RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTCpuSet but not RTMpIsCpuPossible!\n", iCpu);
     90                    g_cErrors++;
     91                }
     92            }
     93            else if (RTMpIsCpuPossible(RTMpCpuIdFromSetIndex(iCpu)))
     94            {
     95                RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTMpIsCpuPossible but not RTCpuSet!\n", iCpu);
     96                g_cErrors++;
     97            }
     98        }
     99    }
     100    else
     101    {
     102        RTPrintf("tstMp-1: FAILURE: RTMpGetSet -> %p, expected %p\n", pSet, &Set);
     103        g_cErrors++;
     104        RTCpuSetEmpty(&Set);
     105        RTCpuSetAdd(&Set, RTMpCpuIdFromSetIndex(0));
     106    }
     107
     108    /*
     109     * Online CPUs.
     110     */
     111    RTCPUID cCpusOnline = RTMpGetOnlineCount();
     112    if (cCpusOnline > 0)
     113    {
     114        if (cCpusOnline <= cCpus)
     115            RTPrintf("tstMp-1: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
     116        else
     117        {
     118            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d, expected <= %d\n", (int)cCpusOnline, (int)cCpus);
     119            g_cErrors++;
     120            cCpusOnline = cCpus;
     121        }
     122    }
     123    else
     124    {
     125        RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
     126        g_cErrors++;
     127        cCpusOnline = 1;
     128    }
     129
     130    RTCPUSET SetOnline;
     131    pSet = RTMpGetOnlineSet(&SetOnline);
     132    if (pSet == &SetOnline)
     133    {
     134        if (RTCpuSetCount(&SetOnline) <= 0)
     135        {
     136            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet returned an empty set!\n");
     137            g_cErrors++;
     138        }
     139        else if ((RTCPUID)RTCpuSetCount(&SetOnline) > cCpus)
     140        {
     141            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet returned a too high value; %d, expected <= %d\n",
     142                     RTCpuSetCount(&SetOnline), cCpus);
     143            g_cErrors++;
     144        }
     145        RTPrintf("tstMp-1: Online CPU mask:\n");
     146        for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
     147            if (RTCpuSetIsMemberByIndex(&SetOnline, iCpu))
     148            {
     149                RTPrintf("tstMp-1: %2d - id %d\n", iCpu, RTMpCpuIdFromSetIndex(iCpu));
     150                if (!RTCpuSetIsMemberByIndex(&Set, iCpu))
     151                {
     152                    RTPrintf("tstMp-1: FAILURE: online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
     153                    g_cErrors++;
     154                }
     155            }
     156
     157        /* There isn't any sane way of testing RTMpIsCpuOnline really... :-/ */
     158    }
     159    else
     160    {
     161        RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet -> %p, expected %p\n", pSet, &Set);
     162        g_cErrors++;
     163    }
     164
     165#else
     166    RTPrintf("tstMp-1: SKIPPED - RTMp is not implemented on this host OS.\n");
     167#endif
     168
    89169    if (!g_cErrors)
    90         RTPrintf("tstIp: SUCCESS\n", g_cErrors);
     170        RTPrintf("tstMp-1: SUCCESS\n", g_cErrors);
    91171    else
    92         RTPrintf("tstIp: FAILURE - %d errors\n", g_cErrors);
     172        RTPrintf("tstMp-1: FAILURE - %d errors\n", g_cErrors);
    93173    return !!g_cErrors;
    94174}
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