VirtualBox

Ignore:
Timestamp:
Dec 11, 2017 3:02:07 PM (7 years ago)
Author:
vboxsync
Message:

GuestPropertySvc.h: Working on making it usable from C (VBoxGuest, ++)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp

    r69500 r70058  
    106106{
    107107    int rc = VINF_SUCCESS;
    108     char *pszFlagBuffer = (char *)RTTestGuardedAllocTail(g_hTest, MAX_FLAGS_LEN);
     108    char *pszFlagBuffer = (char *)RTTestGuardedAllocTail(g_hTest, GUEST_PROP_MAX_FLAGS_LEN);
    109109
    110110    RTTestISub("Conversion of valid flags strings");
     
    112112    {
    113113        uint32_t fFlags;
    114         rc = validateFlags(g_aValidFlagStrings[i].pcszIn, &fFlags);
     114        rc = GuestPropValidateFlags(g_aValidFlagStrings[i].pcszIn, &fFlags);
    115115        if (RT_FAILURE(rc))
    116116            RTTestIFailed("Failed to validate flag string '%s'", g_aValidFlagStrings[i].pcszIn);
    117117        if (RT_SUCCESS(rc))
    118118        {
    119             rc = writeFlags(fFlags, pszFlagBuffer);
     119            rc = GuestPropWriteFlags(fFlags, pszFlagBuffer);
    120120            if (RT_FAILURE(rc))
    121121                RTTestIFailed("Failed to convert flag string '%s' back to a string.",
    122122                              g_aValidFlagStrings[i].pcszIn);
    123123        }
    124         if (RT_SUCCESS(rc) && (strlen(pszFlagBuffer) > MAX_FLAGS_LEN - 1))
     124        if (RT_SUCCESS(rc) && (strlen(pszFlagBuffer) > GUEST_PROP_MAX_FLAGS_LEN - 1))
    125125        {
    126126            RTTestIFailed("String '%s' converts back to a flag string which is too long.\n",
     
    143143            uint32_t fFlags;
    144144            /* This is required to fail. */
    145             if (RT_SUCCESS(validateFlags(g_apszInvalidFlagStrings[i], &fFlags)))
     145            if (RT_SUCCESS(GuestPropValidateFlags(g_apszInvalidFlagStrings[i], &fFlags)))
    146146            {
    147147                RTTestIFailed("String '%s' was incorrectly accepted as a valid flag string.\n",
     
    153153    if (RT_SUCCESS(rc))
    154154    {
    155         uint32_t u32BadFlags = ALLFLAGS << 1;
     155        uint32_t u32BadFlags = GUEST_PROP_F_ALLFLAGS << 1;
    156156        RTTestISub("Rejection of an invalid flags field");
    157157        /* This is required to fail. */
    158         if (RT_SUCCESS(writeFlags(u32BadFlags, pszFlagBuffer)))
     158        if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer)))
    159159        {
    160160            RTTestIFailed("Flags 0x%x were incorrectly written out as '%.*s'\n",
    161                           u32BadFlags, MAX_FLAGS_LEN, pszFlagBuffer);
     161                          u32BadFlags, GUEST_PROP_MAX_FLAGS_LEN, pszFlagBuffer);
    162162            rc = VERR_PARSE_ERROR;
    163163        }
     
    226226    aParms[2].setPointer((void *)g_au64TimestampBlock, 0);
    227227    aParms[3].setPointer((void *)g_apcszFlagsBlock, 0);
    228     RTTESTI_CHECK_RC(ptable->pfnHostCall(ptable->pvService, SET_PROPS_HOST, 4, &aParms[0]), VINF_SUCCESS);
     228    RTTESTI_CHECK_RC(ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_SET_PROPS_HOST, 4, &aParms[0]), VINF_SUCCESS);
    229229}
    230230
     
    337337        aParms[1].setPointer((void *)abBuffer, g_aEnumStrings[i].cbBuffer - 1);
    338338        memset(abBuffer, 0x55, sizeof(abBuffer));
    339         int rc2 = ptable->pfnHostCall(ptable->pvService, ENUM_PROPS_HOST, 3, aParms);
     339        int rc2 = ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, 3, aParms);
    340340        if (rc2 == VERR_BUFFER_OVERFLOW)
    341341        {
     
    353353        aParms[1].setPointer((void *)abBuffer, g_aEnumStrings[i].cbBuffer);
    354354        memset(abBuffer, 0x55, sizeof(abBuffer));
    355         rc2 = ptable->pfnHostCall(ptable->pvService, ENUM_PROPS_HOST, 3, aParms);
     355        rc2 = ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, 3, aParms);
    356356        if (rc2 == VINF_SUCCESS)
    357357        {
     
    394394{
    395395    VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS };
    396     int command = SET_PROP_VALUE;
     396    int command = GUEST_PROP_FN_SET_PROP_VALUE;
    397397    if (isHost)
    398398    {
    399399        if (useSetProp)
    400             command = SET_PROP_HOST;
     400            command = GUEST_PROP_FN_SET_PROP_HOST;
    401401        else
    402             command = SET_PROP_VALUE_HOST;
     402            command = GUEST_PROP_FN_SET_PROP_VALUE_HOST;
    403403    }
    404404    else if (useSetProp)
    405         command = SET_PROP;
     405        command = GUEST_PROP_FN_SET_PROP;
    406406    VBOXHGCMSVCPARM aParms[3];
    407407    /* Work around silly constant issues - we ought to allow passing
    408408     * constant strings in the hgcm parameters. */
    409     char szName[MAX_NAME_LEN];
    410     char szValue[MAX_VALUE_LEN];
    411     char szFlags[MAX_FLAGS_LEN];
     409    char szName[GUEST_PROP_MAX_NAME_LEN];
     410    char szValue[GUEST_PROP_MAX_VALUE_LEN];
     411    char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    412412    RTStrPrintf(szName, sizeof(szName), "%s", pcszName);
    413413    RTStrPrintf(szValue, sizeof(szValue), "%s", pcszValue);
     
    493493{
    494494    VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS };
    495     int command = DEL_PROP;
     495    int command = GUEST_PROP_FN_DEL_PROP;
    496496    if (isHost)
    497         command = DEL_PROP_HOST;
     497        command = GUEST_PROP_FN_DEL_PROP_HOST;
    498498    VBOXHGCMSVCPARM aParms[1];
    499499    aParms[0].setString(pcszName);
     
    595595        /* Work around silly constant issues - we ought to allow passing
    596596         * constant strings in the hgcm parameters. */
    597         char szBuffer[MAX_VALUE_LEN + MAX_FLAGS_LEN];
     597        char szBuffer[GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN];
    598598        RTTESTI_CHECK_RETV(s_aGetProperties[i].cchValue < sizeof(szBuffer));
    599599
     
    601601        memset(szBuffer, 0x55, sizeof(szBuffer));
    602602        aParms[1].setPointer(szBuffer, sizeof(szBuffer));
    603         int rc2 = pTable->pfnHostCall(pTable->pvService, GET_PROP_HOST, 4, aParms);
     603        int rc2 = pTable->pfnHostCall(pTable->pvService, GUEST_PROP_FN_GET_PROP_HOST, 4, aParms);
    604604
    605605        if (s_aGetProperties[i].exists && RT_FAILURE(rc2))
     
    689689        aParms[1].setUInt64(1);
    690690        aParms[2].setPointer(pvBuf, cbBuf);
    691         pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GET_NOTIFICATION, 4, aParms);
     691        pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GUEST_PROP_FN_GET_NOTIFICATION, 4, aParms);
    692692
    693693        if (   callHandle.rc != VERR_BUFFER_OVERFLOW
     
    715715        aParms[1].setUInt64(u64Timestamp);
    716716        aParms[2].setPointer(pvBuf, cbBuf);
    717         pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GET_NOTIFICATION, 4, aParms);
     717        pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GUEST_PROP_FN_GET_NOTIFICATION, 4, aParms);
    718718        if (   RT_FAILURE(callHandle.rc)
    719719            || (i == 0 && callHandle.rc != VWRN_NOT_FOUND)
     
    737737    VBOXHGCMSVCPARM aParms[4];
    738738    /** Result buffer */
    739     char abBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN];
     739    char abBuffer[GUEST_PROP_MAX_NAME_LEN + GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN];
    740740    /** Return value */
    741741    VBOXHGCMCALLHANDLE_TYPEDEF callHandle;
     
    756756    g_AsyncNotification.callHandle.rc = VINF_HGCM_ASYNC_EXECUTE;
    757757    pTable->pfnCall(pTable->pvService, &g_AsyncNotification.callHandle, 0, NULL,
    758                     GET_NOTIFICATION, 4, g_AsyncNotification.aParms);
     758                    GUEST_PROP_FN_GET_NOTIFICATION, 4, g_AsyncNotification.aParms);
    759759    if (RT_FAILURE(g_AsyncNotification.callHandle.rc))
    760760        RTTestIFailed("GET_NOTIFICATION call failed, rc=%Rrc.", g_AsyncNotification.callHandle.rc);
     
    815815 *
    816816 * @param   pTable  the service instance handle
    817  * @param   eFlags  the flags to set
    818  */
    819 static int doSetGlobalFlags(VBOXHGCMSVCFNTABLE *pTable, ePropFlags eFlags)
     817 * @param   fFlags  the flags to set
     818 */
     819static int doSetGlobalFlags(VBOXHGCMSVCFNTABLE *pTable, uint32_t fFlags)
    820820{
    821821    VBOXHGCMSVCPARM paParm;
    822     paParm.setUInt32(eFlags);
    823     int rc = pTable->pfnHostCall(pTable->pvService, SET_GLOBAL_FLAGS_HOST, 1, &paParm);
     822    paParm.setUInt32(fFlags);
     823    int rc = pTable->pfnHostCall(pTable->pvService, GUEST_PROP_FN_SET_GLOBAL_FLAGS_HOST, 1, &paParm);
    824824    if (RT_FAILURE(rc))
    825825    {
    826         char szFlags[MAX_FLAGS_LEN];
    827         if (RT_FAILURE(writeFlags(eFlags, szFlags)))
     826        char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
     827        if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags)))
    828828            RTTestIFailed("Failed to set the global flags.");
    829829        else
     
    874874
    875875    RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(pTable));
    876     int rc = doSetGlobalFlags(pTable, RDONLYGUEST);
     876    int rc = doSetGlobalFlags(pTable, GUEST_PROP_F_RDONLYGUEST);
    877877    if (RT_SUCCESS(rc))
    878878    {
     
    942942
    943943    RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(pTable));
    944     int rc = doSetGlobalFlags(pTable, RDONLYGUEST);
     944    int rc = doSetGlobalFlags(pTable, GUEST_PROP_F_RDONLYGUEST);
    945945    if (RT_SUCCESS(rc))
    946946    {
     
    10061006            aParms[0].setString(s_szProp);
    10071007            aParms[1].setPointer(pvBuf, cbBuf);
    1008             svcTable.pfnHostCall(svcTable.pvService, GET_PROP_HOST, RT_ELEMENTS(aParms), aParms);
     1008            svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_GET_PROP_HOST, RT_ELEMENTS(aParms), aParms);
    10091009
    10101010            RTTestGuardedFree(g_hTest, pvBuf);
     
    10421042            aParms[0].setString("*");
    10431043            aParms[1].setPointer(pvBuf, cbBuf);
    1044             svcTable.pfnHostCall(svcTable.pvService, ENUM_PROPS_HOST, RT_ELEMENTS(aParms), aParms);
     1044            svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, RT_ELEMENTS(aParms), aParms);
    10451045
    10461046            RTTestGuardedFree(g_hTest, pvBuf);
     
    11111111            aParms[0].setPointer(szProp, (uint32_t)cchProp + 1);
    11121112            aParms[1].setPointer(szBuffer, sizeof(szBuffer));
    1113             RTTESTI_CHECK_RC_BREAK(svcTable.pfnHostCall(svcTable.pvService, GET_PROP_HOST, 4, aParms), VINF_SUCCESS);
     1113            RTTESTI_CHECK_RC_BREAK(svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_GET_PROP_HOST, 4, aParms), VINF_SUCCESS);
    11141114        }
    11151115        cNsElapsed = RTTimeNanoTS() - cNsElapsed;
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