VirtualBox

Changeset 26604 in vbox


Ignore:
Timestamp:
Feb 17, 2010 12:32:58 PM (15 years ago)
Author:
vboxsync
Message:

tstSystemQueryOsInfo: converted to RTTest.

Location:
trunk/src/VBox/Runtime/testcase
Files:
2 edited

Legend:

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

    r26525 r26604  
    408408tstRTStrVersion_SOURCES = tstRTStrVersion.cpp
    409409
     410tstSystemQueryOsInfo_TEMPLATE = VBOXR3TSTEXE
    410411tstSystemQueryOsInfo_SOURCES = tstSystemQueryOsInfo.cpp
    411412
  • trunk/src/VBox/Runtime/testcase/tstSystemQueryOsInfo.cpp

    r26344 r26604  
    3333*******************************************************************************/
    3434#include <iprt/system.h>
    35 #include <iprt/initterm.h>
    3635#include <iprt/string.h>
    37 #include <iprt/stream.h>
     36#include <iprt/test.h>
    3837
    3938
     
    4645int main()
    4746{
    48     RTR3Init();
    49 
    50     RTPrintf("tstSystemQueryOsInfo: TESTINGS...\n");
     47    RTTEST hTest;
     48    int rc = RTTestInitAndCreate("tstRTSystemQueryOsInfo", &hTest);
     49    if (rc)
     50        return rc;
     51    RTTestBanner(hTest);
    5152
    5253    /*
     
    5455     */
    5556    char szInfo[256];
    56     int rc;
    5757
    5858    rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo));
    59     RTPrintf("tstSystemQueryOsInfo: PRODUCT: \"%s\", rc=%Rrc\n", szInfo, rc);
     59    RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT: \"%s\", rc=%Rrc\n", szInfo, rc);
    6060
    6161    rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
    62     RTPrintf("tstSystemQueryOsInfo: RELEASE: \"%s\", rc=%Rrc\n", szInfo, rc);
     62    RTTestIPrintf(RTTESTLVL_ALWAYS, "RELEASE: \"%s\", rc=%Rrc\n", szInfo, rc);
    6363
    6464    rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo));
    65     RTPrintf("tstSystemQueryOsInfo: VERSION: \"%s\", rc=%Rrc\n", szInfo, rc);
     65    RTTestIPrintf(RTTESTLVL_ALWAYS, "VERSION: \"%s\", rc=%Rrc\n", szInfo, rc);
    6666
    6767    rc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo));
    68     RTPrintf("tstSystemQueryOsInfo: SERVICE_PACK: \"%s\", rc=%Rrc\n", szInfo, rc);
     68    RTTestIPrintf(RTTESTLVL_ALWAYS, "SERVICE_PACK: \"%s\", rc=%Rrc\n", szInfo, rc);
    6969
    7070    /*
     
    7777        if (    rc == VERR_NOT_SUPPORTED
    7878            &&  szInfo[0] != '\0')
    79         {
    80             RTPrintf("tstSystemQueryOsInfo: FAILED - level=%d, rc=VERR_NOT_SUPPORTED, buffer not terminated\n", i);
    81             g_cErrors++;
    82         }
     79            RTTestIFailed("level=%d; unterminated buffer on VERR_NOT_SUPPORTED\n", i);
     80        else if (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW)
     81            RTTESTI_CHECK(memchr(szInfo, '\0', sizeof(szInfo)) != NULL);
     82        else if (rc != VERR_NOT_SUPPORTED)
     83            RTTestIFailed("level=%d unexpected rc=%Rrc\n", i, rc);
    8384    }
    8485
     
    9899                if (szInfo[off] != 0x7f)
    99100                {
    100                     RTPrintf("tstSystemQueryOsInfo: FAILED - level=%d, rc=%Rrc, cch=%zu, off=%zu: Wrote too much!\n", i, rc, cch, off);
    101                     g_cErrors++;
     101                    RTTestIFailed("level=%d, rc=%Rrc, cch=%zu, off=%zu: Wrote too much!\n", i, rc, cch, off);
    102102                    break;
    103103                }
     
    111111            {
    112112
    113                 RTPrintf("tstSystemQueryOsInfo: FAILED - level=%d, rc=%Rrc, cch=%zu: Buffer not terminated!\n", i, rc, cch);
     113                RTTestIFailed("level=%d, rc=%Rrc, cch=%zu: Buffer not terminated!\n", i, rc, cch);
    114114                g_cErrors++;
    115115            }
     
    117117    }
    118118
    119     /*
    120      * Summarize and exit.
    121      */
    122     if (!g_cErrors)
    123         RTPrintf("tstSystemQueryOsInfo: SUCCESS\n");
    124     else
    125         RTPrintf("tstSystemQueryOsInfo: FAILED - %d errors\n", g_cErrors);
    126     return !!g_cErrors;
     119    return RTTestSummaryAndDestroy(hTest);
    127120}
    128121
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