VirtualBox

Ignore:
Timestamp:
Apr 11, 2025 8:03:05 AM (4 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168449
Message:

VMM/testcase/tstPGMAllGst-armv8.cpp: Allow using names for status codes in the testcase, bugref:10388

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/testcase/tstPGMAllGst-armv8.cpp

    r108931 r108939  
    237237
    238238
    239 static int tstMmuCfgReadS64(RTTEST hTest, RTJSONVAL hObj, const char *pszName, int64_t *pi64Result)
    240 {
    241     int rc = RTJsonValueQueryIntegerByName(hObj, pszName, pi64Result);
     239static int tstMmuCfgReadS64(RTTEST hTest, RTJSONVAL hObj, const char *pszName, PCTSTCFGNAMEDVALUE paNamedValues, int64_t *pi64Result)
     240{
     241    RTJSONVAL hValue = NIL_RTJSONVAL;
     242    int rc = RTJsonValueQueryByName(hObj, pszName, &hValue);
    242243    if (RT_FAILURE(rc))
     244    {
    243245        RTTestFailed(hTest, "Failed to query \"%s\" with %Rrc", pszName, rc);
    244 
     246        return rc;
     247    }
     248
     249    RTJSONVALTYPE enmType = RTJsonValueGetType(hValue);
     250    switch (enmType)
     251    {
     252        case RTJSONVALTYPE_INTEGER:
     253            rc = RTJsonValueQueryInteger(hValue, pi64Result);
     254            break;
     255        case RTJSONVALTYPE_STRING:
     256        {
     257            if (paNamedValues)
     258            {
     259                const char *pszNamedValue = RTJsonValueGetString(hValue);
     260                PCTSTCFGNAMEDVALUE pNamedValue = &paNamedValues[0];
     261                while (pNamedValue->pszName)
     262                {
     263                    if (!RTStrICmp(pszNamedValue, pNamedValue->pszName))
     264                    {
     265                        *pi64Result = (int64_t)pNamedValue->u64Val;
     266                        break;
     267                    }
     268                    pNamedValue++;
     269                }
     270                if (!pNamedValue->pszName)
     271                {
     272                    RTTestFailed(hTest, "\"%s\" ist not a known named value for '%s'", pszNamedValue, pszName);
     273                    rc = VERR_NOT_FOUND;
     274                }
     275            }
     276            else
     277            {
     278                RTTestFailed(hTest, "Integer \"%s\" doesn't support named values", pszName);
     279                rc = VERR_NOT_SUPPORTED;
     280            }
     281            break;
     282        }
     283        default:
     284            rc = VERR_NOT_SUPPORTED;
     285            RTTestFailed(hTest, "JSON value type %d is not supported\n", enmType);
     286            break;
     287    }
     288
     289    RTJsonValueRelease(hValue);
    245290    return rc;
    246291}
    247292
    248293
    249 static int tstMmuCfgReadS32(RTTEST hTest, RTJSONVAL hObj, const char *pszName, int32_t *pi32Result)
    250 {
     294static int tstMmuCfgReadRc(RTTEST hTest, RTJSONVAL hObj, const char *pszName, int32_t *pi32Result)
     295{
     296    static const TSTCFGNAMEDVALUE s_aRc[] =
     297    {
     298#define CREATE_RC(a_Rc) \
     299        {#a_Rc, (uint64_t)a_Rc}
     300        CREATE_RC(VINF_SUCCESS),
     301        CREATE_RC(VERR_RESERVED_PAGE_TABLE_BITS),
     302        CREATE_RC(VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS),
     303        CREATE_RC(VERR_PAGE_TABLE_NOT_PRESENT),
     304        CREATE_RC(VERR_ACCESS_DENIED),
     305        { NULL,   0 }
     306    };
     307
     308
    251309    int64_t i64 = 0;
    252     int rc = tstMmuCfgReadS64(hTest, hObj, pszName, &i64);
     310    int rc = tstMmuCfgReadS64(hTest, hObj, pszName, &s_aRc[0], &i64);
    253311    if (RT_SUCCESS(rc))
    254312    {
     
    825883                         int *prcGetPage)
    826884{
    827     int rc = tstMmuCfgReadS32(hTest, hMemResult, "rcQueryPageFast", prcQueryPageFast);
    828     if (RT_SUCCESS(rc))
    829         rc = tstMmuCfgReadS32(hTest, hMemResult, "rcGetPage", prcGetPage);
     885    int rc = tstMmuCfgReadRc(hTest, hMemResult, "rcQueryPageFast", prcQueryPageFast);
     886    if (RT_SUCCESS(rc))
     887        rc = tstMmuCfgReadRc(hTest, hMemResult, "rcGetPage", prcGetPage);
    830888    if (RT_SUCCESS(rc))
    831889        rc = tstResultQueryGCPhys(hTest, hMemResult, "GCPhys", &pWalkResult->GCPhys);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette