VirtualBox

Changeset 94228 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 14, 2022 7:19:18 PM (3 years ago)
Author:
vboxsync
Message:

Validation Kit/HGCM: Split out the HGCM testing (mocking) framework into an own header, added documentation, more code for generalizing this [build fix].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardMockHGCM.cpp

    r93969 r94228  
    1616 */
    1717
    18 #include <VBox/GuestHost/HGCMMock.h>
    19 
    2018#include "../VBoxSharedClipboardSvc-internal.h"
    2119
     
    2523# include <VBox/GuestHost/SharedClipboard-x11.h>
    2624#endif
     25
     26#include <VBox/GuestHost/HGCMMock.h>
    2727
    2828#include <iprt/assert.h>
     
    3939*   Static globals                                                                                                               *
    4040*********************************************************************************************************************************/
    41 
    4241static RTTEST     g_hTest;
    4342static SHCLCLIENT g_Client;
     
    163162    VBOXHGCMSVCPARM aParms[2];
    164163    HGCMSvcSetU32(&aParms[0], uMode);
    165     int rc2 = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, aParms);
     164    int rc2 = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, aParms);
    166165    RTTESTI_CHECK_MSG_RET(rc == rc2, ("Expected %Rrc, got %Rrc\n", rc, rc2), rc2);
    167166    uint32_t const uModeRet = ShClSvcGetMode();
     
    190189    RTTestISub("Testing VBOX_SHCL_HOST_FN_SET_MODE");
    191190
    192     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
     191    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
    193192
    194193    /* Reset global variable which doesn't reset itself. */
    195194    HGCMSvcSetU32(&parms[0], VBOX_SHCL_MODE_OFF);
    196     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, parms);
     195    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, parms);
    197196    RTTESTI_CHECK_RC_OK(rc);
    198197    u32Mode = ShClSvcGetMode();
    199198    RTTESTI_CHECK_MSG(u32Mode == VBOX_SHCL_MODE_OFF, ("u32Mode=%u\n", (unsigned) u32Mode));
    200199
    201     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 0, parms);
     200    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 0, parms);
    202201    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
    203202
    204     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 2, parms);
     203    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 2, parms);
    205204    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
    206205
    207206    HGCMSvcSetU64(&parms[0], 99);
    208     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, parms);
     207    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_MODE, 1, parms);
    209208    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
    210209
     
    219218    RTTestISub("Testing VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE");
    220219
    221     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
     220    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
    222221
    223222    /* Invalid parameter. */
    224223    VBOXHGCMSVCPARM parms[2];
    225224    HGCMSvcSetU64(&parms[0], 99);
    226     int rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
     225    int rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
    227226    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
    228227
    229228    /* Invalid mode. */
    230229    HGCMSvcSetU32(&parms[0], 99);
    231     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
     230    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
    232231    RTTESTI_CHECK_RC(rc, VERR_INVALID_FLAGS);
    233232
    234233    /* Enable transfers. */
    235234    HGCMSvcSetU32(&parms[0], VBOX_SHCL_TRANSFER_MODE_ENABLED);
    236     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
     235    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
    237236    RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
    238237
    239238    /* Disable transfers again. */
    240239    HGCMSvcSetU32(&parms[0], VBOX_SHCL_TRANSFER_MODE_DISABLED);
    241     rc = tstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
     240    rc = TstHgcmMockSvcHostCall(pSvc, NULL, VBOX_SHCL_HOST_FN_SET_TRANSFER_MODE, 1, parms);
    242241    RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
    243242}
     
    249248    RTTestISub("Setting up VBOX_SHCL_GUEST_FN_MSG_OLD_GET_WAIT test");
    250249
    251     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
     250    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
    252251
    253252    VBOXHGCMSVCPARM parms[2];
     
    345344    RTTestISub("Testing client (guest) API - Simple");
    346345
    347     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
     346    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
    348347
    349348    /* Preparations. */
     
    523522    RTTestISub("Testing HOST_FN_SET_HEADLESS");
    524523
    525     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
     524    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
    526525
    527526    VBOXHGCMSVCPARM parms[2];
     
    839838    pTask->cbChunk   = pTask->cbData;
    840839
    841     PTSTHGCMMOCKSVC    pSvc        = tstHgcmMockSvcInst();
    842     PTSTHGCMMOCKCLIENT pMockClient = tstHgcmMockSvcWaitForConnect(pSvc);
    843 RT_BREAKPOINT();
     840    PTSTHGCMMOCKSVC    pSvc        = TstHgcmMockSvcInst();
     841    PTSTHGCMMOCKCLIENT pMockClient = TstHgcmMockSvcWaitForConnect(pSvc);
     842
    844843    AssertPtrReturn(pMockClient, VERR_INVALID_POINTER);
    845844
     
    963962    RTAssertSetMayPanic(false);
    964963
    965     PTSTHGCMMOCKSVC pSvc = tstHgcmMockSvcInst();
    966 
    967     tstHgcmMockSvcCreate(pSvc, sizeof(SHCLCLIENT));
    968     tstHgcmMockSvcStart(pSvc);
     964    PTSTHGCMMOCKSVC pSvc = TstHgcmMockSvcInst();
     965
     966    TstHgcmMockSvcCreate(pSvc, sizeof(SHCLCLIENT));
     967    TstHgcmMockSvcStart(pSvc);
    969968
    970969    /*
     
    985984    tstTaskDestroy(&g_TstCtx.Task);
    986985
    987     tstHgcmMockSvcStop(pSvc);
    988     tstHgcmMockSvcDestroy(pSvc);
     986    TstHgcmMockSvcStop(pSvc);
     987    TstHgcmMockSvcDestroy(pSvc);
     988
     989    VBOXHGCMSVCFNTABLE fn;
     990    VBoxHGCMSvcLoad(&fn);
    989991
    990992    /*
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