Index: /trunk/src/VBox/Runtime/testcase/tstMp-1.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstMp-1.cpp	(revision 46631)
+++ /trunk/src/VBox/Runtime/testcase/tstMp-1.cpp	(revision 46632)
@@ -31,19 +31,16 @@
 #include <iprt/cpuset.h>
 #include <iprt/err.h>
-#include <iprt/initterm.h>
-#include <iprt/stream.h>
 #include <iprt/string.h>
-
-
-/*******************************************************************************
-*   Global Variables                                                           *
-*******************************************************************************/
-static unsigned g_cErrors = 0;
+#include <iprt/test.h>
+
 
 
 int main()
 {
-    RTR3InitExeNoArguments(0);
-    RTPrintf("tstMp-1: TESTING...\n");
+    RTTEST hTest;
+    RTEXITCODE rcExit = RTTestInitAndCreate("tstRTMp-1", &hTest);
+    if (rcExit != RTEXITCODE_SUCCESS)
+        return rcExit;
+    RTTestBanner(hTest);
 
     /*
@@ -52,9 +49,8 @@
     RTCPUID cCpus = RTMpGetCount();
     if (cCpus > 0)
-        RTPrintf("tstMp-1: RTMpGetCount -> %d\n", (int)cCpus);
-    else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetCount -> %d\n", (int)cCpus);
-        g_cErrors++;
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetCount -> %u\n", cCpus);
+    else
+    {
+        RTTestIFailed("RTMpGetCount returned zero");
         cCpus = 1;
     }
@@ -62,23 +58,20 @@
     RTCPUID cCoreCpus = RTMpGetCoreCount();
     if (cCoreCpus > 0)
-        RTPrintf("tstMp-1: RTMpGetCoreCount -> %d\n", (int)cCoreCpus);
-    else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetCoreCount -> %d\n", (int)cCoreCpus);
-        g_cErrors++;
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetCoreCount -> %d\n", (int)cCoreCpus);
+    else
+    {
+        RTTestIFailed("RTMpGetCoreCount returned zero");
         cCoreCpus = 1;
     }
+    RTTESTI_CHECK(cCoreCpus <= cCpus);
 
     RTCPUSET Set;
     PRTCPUSET pSet = RTMpGetSet(&Set);
+    RTTESTI_CHECK(pSet == &Set);
     if (pSet == &Set)
     {
-        if ((RTCPUID)RTCpuSetCount(&Set) != cCpus)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetSet returned a set with a different cpu count; %d, expected %d\n",
-                     RTCpuSetCount(&Set), cCpus);
-            g_cErrors++;
-        }
-        RTPrintf("tstMp-1: Possible CPU mask:\n");
+        RTTESTI_CHECK((RTCPUID)RTCpuSetCount(&Set) == cCpus);
+
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "Possible CPU mask:\n");
         for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
         {
@@ -86,46 +79,31 @@
             if (RTCpuSetIsMemberByIndex(&Set, iCpu))
             {
-                RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz", iCpu, (int)idCpu,
-                         RTMpGetCurFrequency(idCpu), RTMpGetMaxFrequency(idCpu));
+                RTTestIPrintf(RTTESTLVL_ALWAYS, "%2d - id %d: %u/%u MHz", iCpu, (int)idCpu,
+                              RTMpGetCurFrequency(idCpu), RTMpGetMaxFrequency(idCpu));
                 if (RTMpIsCpuPresent(idCpu))
-                    RTPrintf(RTMpIsCpuOnline(idCpu) ? " online\n" : " offline\n");
+                    RTTestIPrintf(RTTESTLVL_ALWAYS, RTMpIsCpuOnline(idCpu) ? " online\n" : " offline\n");
                 else
                 {
                     if (!RTMpIsCpuOnline(idCpu))
-                        RTPrintf(" absent\n");
+                        RTTestIPrintf(RTTESTLVL_ALWAYS, " absent\n");
                     else
                     {
-                        RTPrintf(" online but absent!\n");
-                        RTPrintf("tstMp-1: FAILURE: Cpu with index %d is report as !RTIsCpuPresent while RTIsCpuOnline returns true!\n", iCpu);
-                        g_cErrors++;
+                        RTTestIPrintf(RTTESTLVL_ALWAYS, " online but absent!\n");
+                        RTTestIFailed("Cpu with index %d is report as !RTIsCpuPresent while RTIsCpuOnline returns true!\n", iCpu);
                     }
                 }
                 if (!RTMpIsCpuPossible(idCpu))
-                {
-                    RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTCpuSet but not RTMpIsCpuPossible!\n", iCpu);
-                    g_cErrors++;
-                }
+                    RTTestIFailed("Cpu with index %d is returned by RTCpuSet but not RTMpIsCpuPossible!\n", iCpu);
             }
             else if (RTMpIsCpuPossible(idCpu))
-            {
-                RTPrintf("tstMp-1: FAILURE: Cpu with index %d is returned by RTMpIsCpuPossible but not RTCpuSet!\n", iCpu);
-                g_cErrors++;
-            }
+                RTTestIFailed("Cpu with index %d is returned by RTMpIsCpuPossible but not RTCpuSet!\n", iCpu);
             else if (RTMpGetCurFrequency(idCpu) != 0)
-            {
-                RTPrintf("tstMp-1: FAILURE: RTMpGetCurFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
-                g_cErrors++;
-            }
+                RTTestIFailed("RTMpGetCurFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
             else if (RTMpGetMaxFrequency(idCpu) != 0)
-            {
-                RTPrintf("tstMp-1: FAILURE: RTMpGetMaxFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
-                g_cErrors++;
-            }
+                RTTestIFailed("RTMpGetMaxFrequency(%d[idx=%d]) didn't return 0 as it should\n", (int)idCpu, iCpu);
         }
     }
     else
     {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetSet -> %p, expected %p\n", pSet, &Set);
-        g_cErrors++;
         RTCpuSetEmpty(&Set);
         RTCpuSetAdd(&Set, RTMpCpuIdFromSetIndex(0));
@@ -139,9 +117,8 @@
     {
         if (cCpusOnline <= cCpus)
-            RTPrintf("tstMp-1: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
+            RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
         else
         {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d, expected <= %d\n", (int)cCpusOnline, (int)cCpus);
-            g_cErrors++;
+            RTTestIFailed("RTMpGetOnlineCount -> %d, expected <= %d\n", (int)cCpusOnline, (int)cCpus);
             cCpusOnline = cCpus;
         }
@@ -149,6 +126,5 @@
     else
     {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
-        g_cErrors++;
+        RTTestIFailed("RTMpGetOnlineCount -> %d\n", (int)cCpusOnline);
         cCpusOnline = 1;
     }
@@ -159,26 +135,17 @@
     {
         if (RTCpuSetCount(&SetOnline) <= 0)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet returned an empty set!\n");
-            g_cErrors++;
-        }
+            RTTestIFailed("RTMpGetOnlineSet returned an empty set!\n");
         else if ((RTCPUID)RTCpuSetCount(&SetOnline) > cCpus)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet returned a too high value; %d, expected <= %d\n",
-                     RTCpuSetCount(&SetOnline), cCpus);
-            g_cErrors++;
-        }
-        RTPrintf("tstMp-1: Online CPU mask:\n");
+            RTTestIFailed("RTMpGetOnlineSet returned a too high value; %d, expected <= %d\n",
+                          RTCpuSetCount(&SetOnline), cCpus);
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "Online CPU mask:\n");
         for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
             if (RTCpuSetIsMemberByIndex(&SetOnline, iCpu))
             {
                 RTCPUID idCpu = RTMpCpuIdFromSetIndex(iCpu);
-                RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
-                         RTMpGetMaxFrequency(idCpu), RTMpIsCpuOnline(idCpu) ? "online" : "offline");
+                RTTestIPrintf(RTTESTLVL_ALWAYS, "%2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
+                              RTMpGetMaxFrequency(idCpu), RTMpIsCpuOnline(idCpu) ? "online" : "offline");
                 if (!RTCpuSetIsMemberByIndex(&Set, iCpu))
-                {
-                    RTPrintf("tstMp-1: FAILURE: online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
-                    g_cErrors++;
-                }
+                    RTTestIFailed("online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
             }
 
@@ -186,8 +153,5 @@
     }
     else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetOnlineSet -> %p, expected %p\n", pSet, &Set);
-        g_cErrors++;
-    }
+        RTTestIFailed("RTMpGetOnlineSet -> %p, expected %p\n", pSet, &Set);
 
     /*
@@ -199,15 +163,12 @@
         if (    cCpusPresent <= cCpus
             &&  cCpusPresent >= cCpusOnline)
-            RTPrintf("tstMp-1: RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
+            RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
         else
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentCount -> %d, expected <= %d and >= %d\n", (int)cCpusPresent, (int)cCpus, (int)cCpusOnline);
-            g_cErrors++;
-        }
-    }
-    else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
-        g_cErrors++;
+            RTTestIFailed("RTMpGetPresentCount -> %d, expected <= %d and >= %d\n",
+                          (int)cCpusPresent, (int)cCpus, (int)cCpusOnline);
+    }
+    else
+    {
+        RTTestIFailed("RTMpGetPresentCount -> %d\n", (int)cCpusPresent);
         cCpusPresent = 1;
     }
@@ -218,26 +179,17 @@
     {
         if (RTCpuSetCount(&SetPresent) <= 0)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet returned an empty set!\n");
-            g_cErrors++;
-        }
+            RTTestIFailed("RTMpGetPresentSet returned an empty set!\n");
         else if ((RTCPUID)RTCpuSetCount(&SetPresent) != cCpusPresent)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet returned a bad value; %d, expected = %d\n",
-                     RTCpuSetCount(&SetPresent), cCpusPresent);
-            g_cErrors++;
-        }
-        RTPrintf("tstMp-1: Present CPU mask:\n");
+            RTTestIFailed("RTMpGetPresentSet returned a bad value; %d, expected = %d\n",
+                          RTCpuSetCount(&SetPresent), cCpusPresent);
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "Present CPU mask:\n");
         for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
             if (RTCpuSetIsMemberByIndex(&SetPresent, iCpu))
             {
                 RTCPUID idCpu = RTMpCpuIdFromSetIndex(iCpu);
-                RTPrintf("tstMp-1: %2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
-                         RTMpGetMaxFrequency(idCpu), RTMpIsCpuPresent(idCpu) ? "present" : "absent");
+                RTTestIPrintf(RTTESTLVL_ALWAYS, "%2d - id %d: %u/%u MHz %s\n", iCpu, (int)idCpu, RTMpGetCurFrequency(idCpu),
+                              RTMpGetMaxFrequency(idCpu), RTMpIsCpuPresent(idCpu) ? "present" : "absent");
                 if (!RTCpuSetIsMemberByIndex(&Set, iCpu))
-                {
-                    RTPrintf("tstMp-1: FAILURE: online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
-                    g_cErrors++;
-                }
+                    RTTestIFailed("online cpu with index %2d is not a member of the possible cpu set!\n", iCpu);
             }
 
@@ -245,8 +197,5 @@
     }
     else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetPresentSet -> %p, expected %p\n", pSet, &Set);
-        g_cErrors++;
-    }
+        RTTestIFailed("RTMpGetPresentSet -> %p, expected %p\n", pSet, &Set);
 
 
@@ -264,32 +213,19 @@
     if (RT_SUCCESS(rc))
     {
-        RTPrintf("tstMp-1: RTMpGetDescription -> '%s'\n", szBuf);
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "RTMpGetDescription -> '%s'\n", szBuf);
 
         size_t cch = strlen(szBuf);
         rc = RTMpGetDescription(idCpuOnline, &szBuf[0], cch);
         if (rc != VERR_BUFFER_OVERFLOW)
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetDescription -> %Rrc, expected VERR_BUFFER_OVERFLOW\n", rc);
-            g_cErrors++;
-        }
+            RTTestIFailed("RTMpGetDescription -> %Rrc, expected VERR_BUFFER_OVERFLOW\n", rc);
+
         rc = RTMpGetDescription(idCpuOnline, &szBuf[0], cch + 1);
         if (RT_FAILURE(rc))
-        {
-            RTPrintf("tstMp-1: FAILURE: RTMpGetDescription -> %Rrc, expected VINF_SUCCESS\n", rc);
-            g_cErrors++;
-        }
-    }
-    else
-    {
-        RTPrintf("tstMp-1: FAILURE: RTMpGetDescription -> %Rrc\n", rc);
-        g_cErrors++;
-    }
-
-
-    if (!g_cErrors)
-        RTPrintf("tstMp-1: SUCCESS\n", g_cErrors);
-    else
-        RTPrintf("tstMp-1: FAILURE - %d errors\n", g_cErrors);
-    return !!g_cErrors;
+            RTTestIFailed("RTMpGetDescription -> %Rrc, expected VINF_SUCCESS\n", rc);
+    }
+    else
+        RTTestIFailed("RTMpGetDescription -> %Rrc\n", rc);
+
+    return RTTestSummaryAndDestroy(hTest);
 }
 
