VirtualBox

Ignore:
Timestamp:
Nov 7, 2008 4:07:57 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
39008
Message:

HostServices/GuestProperties: added blocking waits for notifications

File:
1 edited

Legend:

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

    r13916 r13971  
    735735    }
    736736
    737     /* Test when no new events are available */
    738     pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL,
    739                     GET_NOTIFICATION, 3, paParms);
    740     if (   RT_FAILURE(callHandle.rc)
    741         || RT_FAILURE(paParms[0].getUInt64 (&u64Timestamp))
    742         || u64Timestamp != 0
    743        )
    744     {
    745         RTPrintf("Failed to signal properly that no new notifications are available.\n");
    746         rc = VERR_UNRESOLVED_ERROR;
    747     }
    748 
    749737    /* Test a query with an unknown timestamp */
    750738    paParms[0].setUInt64 (1);
     
    775763 * @note    prints its own diagnostic information to stdout.
    776764 */
    777 int testNoNotifications(VBOXHGCMSVCFNTABLE *pTable)
     765int testNoNotifications(VBOXHGCMSVCFNTABLE *pTable, VBOXHGCMCALLHANDLE_TYPEDEF *callHandle,
     766                        VBOXHGCMSVCPARM *paParms, char *pchBuffer, size_t cchBuffer)
    778767{
    779768    int rc = VINF_SUCCESS;
    780     VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS };
    781     char chBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN];
    782 
    783     RTPrintf("Testing the GET_NOTIFICATION call when no notifications are available.\n");
     769
     770    RTPrintf("Testing the asynchronous GET_NOTIFICATION call with no notifications are available.\n");
    784771    uint64_t u64Timestamp = 0;
    785772    uint32_t u32Size = 0;
    786     VBOXHGCMSVCPARM paParms[3];
    787773
    788774    paParms[0].setUInt64 (u64Timestamp);
    789     paParms[1].setPointer ((void *) chBuffer, sizeof(chBuffer));
    790     pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL,
     775    paParms[1].setPointer ((void *) pchBuffer, cchBuffer);
     776    callHandle->rc = VINF_HGCM_ASYNC_EXECUTE;
     777    pTable->pfnCall(pTable->pvService, callHandle, 0, NULL,
    791778                    GET_NOTIFICATION, 3, paParms);
    792     if (   RT_FAILURE(callHandle.rc)
    793         || RT_FAILURE(paParms[0].getUInt64 (&u64Timestamp))
    794         || u64Timestamp != 0
    795        )
    796     {
    797         RTPrintf("Failed to signal properly that no new notifications are available.\n");
     779    if (callHandle->rc != VINF_HGCM_ASYNC_EXECUTE)
     780    {
     781        RTPrintf("GET_NOTIFICATION call completed when new notifications should be available.\n");
    798782        rc = VERR_UNRESOLVED_ERROR;
    799783    }
     
    805789    VBOXHGCMSVCFNTABLE svcTable;
    806790    VBOXHGCMSVCHELPERS svcHelpers;
     791    /* Paramters for the asynchronous guest notification call */
     792    VBOXHGCMSVCPARM aParm[3];
     793    char chBuffer[MAX_NAME_LEN + MAX_VALUE_LEN + MAX_FLAGS_LEN];
     794    VBOXHGCMCALLHANDLE_TYPEDEF callHandleStruct;
     795
    807796    initTable(&svcTable, &svcHelpers);
    808797    RTR3Init();
     
    819808    if (RT_FAILURE(testEnumPropsHost(&svcTable)))
    820809        return 1;
    821     if (RT_FAILURE(testNoNotifications(&svcTable)))
     810    /* Asynchronous notification call */
     811    if (RT_FAILURE(testNoNotifications(&svcTable, &callHandleStruct, aParm,
     812                   chBuffer, sizeof(chBuffer))))
    822813        return 1;
    823814    if (RT_FAILURE(testSetProp(&svcTable)))
    824815        return 1;
     816    RTPrintf("Checking the data returned by the asynchronous notification call.\n");
     817    /* Our previous notification call should have completed by now. */
     818    uint64_t u64Timestamp;
     819    uint32_t u32Size;
     820    if (   callHandleStruct.rc != VINF_SUCCESS
     821        || RT_FAILURE(aParm[0].getUInt64 (&u64Timestamp))
     822        || RT_FAILURE(aParm[2].getUInt32 (&u32Size))
     823        || u32Size != getNotifications[0].cchBuffer
     824        || memcmp(chBuffer, getNotifications[0].pchBuffer, u32Size) != 0
     825       )
     826    {
     827        RTPrintf("Asynchronous GET_NOTIFICATION call did not complete as expected, rc=%Rrc\n",
     828                 callHandleStruct.rc);
     829        return 1;
     830    }
    825831    if (RT_FAILURE(testDelProp(&svcTable)))
    826832        return 1;
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