VirtualBox

Changeset 40533 in vbox for trunk


Ignore:
Timestamp:
Mar 19, 2012 11:43:47 AM (13 years ago)
Author:
vboxsync
Message:

Additions/VBoxGuest: more testing for Solaris STREAMS-based driver and some code layout changes.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk

    r40511 r40533  
    213213  PROGRAMS += tstVBoxGuest-solaris
    214214  tstVBoxGuest-solaris_TEMPLATE = VBOXR3TSTEXE
    215   tstVBoxGuest-solaris_SOURCES  = \
    216         VBoxGuest-solaris-streams.c \
    217         testcase/tstVBoxGuest-solaris.cpp
     215  tstVBoxGuest-solaris_SOURCES  = VBoxGuest-solaris-streams.c
    218216  tstVBoxGuest-solaris_DEFS     = TESTCASE
    219217  tstVBoxGuest-solaris_LIBS     = $(LIB_RUNTIME)
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris-streams.c

    r40501 r40533  
    5151#ifdef TESTCASE  /* Include this last as we . */
    5252# include "testcase/solaris.h"
    53 # include "testcase/tstVBoxGuest-solaris.h"
     53# include <iprt/test.h>
    5454#endif  /* TESTCASE */
    5555
     
    312312#ifdef TESTCASE
    313313/** Simple test of the flow through _init. */
    314 void test_init(RTTEST hTest)
     314static void test_init(RTTEST hTest)
    315315{
    316316    RTTestSub(hTest, "Testing _init");
     
    474474#ifdef TESTCASE
    475475/** Simple test of vbgr0SolOpen and vbgr0SolClose. */
    476 void testOpenClose(RTTEST hTest)
     476static void testOpenClose(RTTEST hTest)
    477477{
    478478    queue_t aQueues[4];
     
    538538    return 0;
    539539}
     540
     541
     542#ifdef TESTCASE
     543/** Test WPut's handling of different IOCtls, which is bulk of the logic in
     544 * this file. */
     545static void testWPut(RTTEST hTest)
     546{
     547    queue_t aQueues[2];
     548    dev_t device = 0;
     549    struct msgb MBlk, MBlkCont;
     550    struct datab DBlk;
     551    struct iocblk IOCBlk;
     552    int rc, cFormat = 0;
     553
     554    /* Single simple test to start with.  We can try to make it more systematic
     555     * next. */
     556    RTTestSub(hTest, "Testing vbgr0WPut");
     557    RT_ZERO(aQueues);
     558    doInitQueues(&aQueues[0]);
     559    rc = vbgr0SolOpen(RD(&aQueues[0]), &device, 0, 0, NULL);
     560    RTTEST_CHECK(hTest, rc == 0);
     561    RTTEST_CHECK(hTest, g_aOpenNodeStates[1].pWriteQueue == WR(&aQueues[0]));
     562    RT_ZERO(MBlk);
     563    RT_ZERO(DBlk);
     564    RT_ZERO(IOCBlk);
     565    RT_ZERO(MBlkCont);
     566    DBlk.db_type = M_IOCTL;
     567    IOCBlk.ioc_cmd = VUIDSFORMAT;
     568    IOCBlk.ioc_count = sizeof(int);
     569    MBlkCont.b_rptr = (unsigned char *)&cFormat;
     570    MBlkCont.b_rptr = (unsigned char *)&cFormat + sizeof(cFormat);
     571    MBlk.b_cont = &MBlkCont;
     572    MBlk.b_rptr = (unsigned char *)&IOCBlk;
     573    MBlkCont.b_rptr = (unsigned char *)&IOCBlk + sizeof(IOCBlk);
     574    MBlk.b_datap = &DBlk;
     575    rc = vbgr0SolWPut(WR(&aQueues[0]), &MBlk);
     576    RTTEST_CHECK(hTest, rc == 0);
     577    vbgr0SolClose(RD(&aQueues[1]), 0, NULL);
     578}
     579#endif
    540580
    541581
     
    698738        return vbgr0SolHandleIOCtlData(pWriteQueue, pMBlk, pfnHandler, cCmd,
    699739                                       cbTransparent, enmDirection);
    700     else if (pIOCBlk->ioc_count == TRANSPARENT)
     740    else if (   pMBlk->b_datap->db_type == M_IOCTL
     741             && pIOCBlk->ioc_count == TRANSPARENT)
    701742        return vbgr0SolHandleTransparentIOCtl(pWriteQueue, pMBlk, pfnHandler,
    702743                                              cCmd, cbTransparent,
    703744                                              enmDirection);
    704     else
     745    else if (pMBlk->b_datap->db_type == M_IOCTL)
    705746        return vbgr0SolHandleIStrIOCtl(pWriteQueue, pMBlk, pfnHandler, cCmd);
     747    return EINVAL;
    706748}
    707749
     
    719761{
    720762    struct copyresp *pCopyResp = (struct copyresp *)pMBlk->b_rptr;
    721     struct iocblk   *pIOCBlk   = (struct iocblk *)pMBlk->b_rptr;
    722763    PVBGR0STATE pState = (PVBGR0STATE)pWriteQueue->q_ptr;
    723764
    724     if (pCopyResp->cp_rval)
     765    if (pCopyResp->cp_rval)  /* cp_rval is a pointer used as a boolean. */
    725766    {
    726767        freemsg(pMBlk);
    727         return EAGAIN;  /* cp_rval is a pointer but should be the error. */
     768        return EAGAIN;
    728769    }
    729770    if ((pCopyResp->cp_private && enmDirection == BOTH) || enmDirection == IN)
    730771    {
    731         size_t cbBuffer = pIOCBlk->ioc_count, cbData = 0;
     772        size_t cbData = 0;
    732773        void *pvData = NULL;
    733774        int err;
     
    740781            return EINVAL;
    741782        pvData = pMBlk->b_cont->b_rptr;
    742         err = pfnHandler(pState, cCmd, pvData, cbBuffer, &cbData, NULL);
     783        err = pfnHandler(pState, cCmd, pvData, cbTransparent, &cbData, NULL);
    743784        if (!err && enmDirection == BOTH)
    744785            mcopyout(pMBlk, NULL, cbData, pCopyResp->cp_private, NULL);
     
    13681409# include "VBoxGuestIDC-unix.c.h"
    13691410#endif
     1411
     1412#ifdef TESTCASE
     1413int main(void)
     1414{
     1415    RTTEST hTest;
     1416    int rc = RTTestInitAndCreate("tstVBoxGuest-solaris", &hTest);
     1417    if (rc)
     1418        return rc;
     1419    RTTestBanner(hTest);
     1420    test_init(hTest);
     1421    testOpenClose(hTest);
     1422    testWPut(hTest);
     1423
     1424    /*
     1425     * Summary.
     1426     */
     1427    return RTTestSummaryAndDestroy(hTest);
     1428}
     1429#endif
  • trunk/src/VBox/Additions/common/VBoxGuest/testcase/solaris.h

    r40501 r40533  
    221221    unsigned char      db_ref;
    222222    unsigned char      db_type;
    223 } dlk_t;
     223} dblk_t;
    224224
    225225struct iocblk
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