VirtualBox

忽略:
時間撮記:
2011-12-6 下午03:17:59 (13 年 以前)
作者:
vboxsync
訊息:

HostServices/SharedFolders: starter unit test.

位置:
trunk/src/VBox/HostServices/SharedFolders
檔案:
新增 3 筆資料
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/HostServices/SharedFolders/mappings.cpp

    r31055 r39540  
    1414 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 */
     16
     17#ifdef UNITTEST
     18# include "teststubs.h"
     19# include "testcase/tstSharedFolderService.h"
     20#endif
    1621
    1722#include "mappings.h"
     
    170175
    171176
     177#ifdef UNITTEST
     178/** Unit test the SHFL_FN_ADD_MAPPING API.  Located here as a form of API
     179 * documentation. */
     180void testMappingsAdd(RTTEST hTest)
     181{
     182    /* If the number or types of parameters are wrong the API should fail. */
     183    testMappingsAddBadParameters(hTest);
     184    /* Add tests as required... */
     185}
     186#endif
    172187/*
    173188 * We are always executed from one specific HGCM thread. So thread safe.
     
    255270}
    256271
     272#ifdef UNITTEST
     273/** Unit test the SHFL_FN_REMOVE_MAPPING API.  Located here as a form of API
     274 * documentation. */
     275void testMappingsRemove(RTTEST hTest)
     276{
     277    /* If the number or types of parameters are wrong the API should fail. */
     278    testMappingsRemoveBadParameters(hTest);
     279    /* Add tests as required... */
     280}
     281#endif
    257282int vbsfMappingsRemove(PSHFLSTRING pMapName)
    258283{
     
    331356}
    332357
     358#ifdef UNITTEST
     359/** Unit test the SHFL_FN_QUERY_MAPPINGS API.  Located here as a form of API
     360 * documentation (or should it better be inline in include/VBox/shflsvc.h?) */
     361void testMappingsQuery(RTTEST hTest)
     362{
     363    /* The API should return all mappings if we provide enough buffers. */
     364    testMappingsQuerySimple(hTest);
     365    /* If we provide too few buffers that should be signalled correctly. */
     366    testMappingsQueryTooFewBuffers(hTest);
     367    /* The SHFL_MF_AUTOMOUNT flag means return only auto-mounted mappings. */
     368    testMappingsQueryAutoMount(hTest);
     369    /* The mappings return array must have numberOfMappings entries. */
     370    testMappingsQueryArrayWrongSize(hTest);
     371}
     372#endif
    333373/**
    334374 * Note: If pMappings / *pcMappings is smaller than the actual amount of mappings
     
    376416}
    377417
     418#ifdef UNITTEST
     419/** Unit test the SHFL_FN_QUERY_MAP_NAME API.  Located here as a form of API
     420 * documentation. */
     421void testMappingsQueryName(RTTEST hTest)
     422{
     423    /* If we query an valid mapping it should be returned. */
     424    testMappingsQueryNameValid(hTest);
     425    /* If we query an invalid mapping that should be signalled. */
     426    testMappingsQueryNameInvalid(hTest);
     427    /* If we pass in a bad string buffer that should be detected. */
     428    testMappingsQueryNameBadBuffer(hTest);
     429}
     430#endif
    378431int vbsfMappingsQueryName(PSHFLCLIENTDATA pClient, SHFLROOT root, SHFLSTRING *pString)
    379432{
     
    455508}
    456509
     510#ifdef UNITTEST
     511/** Unit test the SHFL_FN_MAP_FOLDER API.  Located here as a form of API
     512 * documentation. */
     513void testMapFolder(RTTEST hTest)
     514{
     515    /* If we try to map a valid name we should get the root. */
     516    testMapFolderValid(hTest);
     517    /* If we try to map a valid name we should get VERR_FILE_NOT_FOUND. */
     518    testMapFolderInvalid(hTest);
     519    /* If we map a folder twice we can unmap it twice.
     520     * Currently unmapping too often is only asserted but not signalled. */
     521    testMapFolderTwice(hTest);
     522    /* The delimiter should be converted in e.g. file delete operations. */
     523    testMapFolderDelimiter(hTest);
     524    /* Test case sensitive mapping by opening a file with the wrong case. */
     525    testMapFolderCaseSensitive(hTest);
     526    /* Test case insensitive mapping by opening a file with the wrong case. */
     527    testMapFolderCaseInsensitive(hTest);
     528    /* If the number or types of parameters are wrong the API should fail. */
     529    testMapFolderBadParameters(hTest);
     530}
     531#endif
    457532int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName,
    458533                  RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot)
     
    506581}
    507582
     583#ifdef UNITTEST
     584/** Unit test the SHFL_FN_UNMAP_FOLDER API.  Located here as a form of API
     585 * documentation. */
     586void testUnmapFolder(RTTEST hTest)
     587{
     588    /* Unmapping a mapped folder should succeed.
     589     * If the folder is not mapped this is only asserted, not signalled. */
     590    testUnmapFolderValid(hTest);
     591    /* Unmapping a non-existant root should fail. */
     592    testUnmapFolderInvalid(hTest);
     593    /* If the number or types of parameters are wrong the API should fail. */
     594    testUnmapFolderBadParameters(hTest);
     595}
     596#endif
    508597int vbsfUnmapFolder(PSHFLCLIENTDATA pClient, SHFLROOT root)
    509598{
  • trunk/src/VBox/HostServices/SharedFolders/service.cpp

    r38735 r39540  
    112112static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
    113113{
     114#ifndef UNITTEST  /* Read this as not yet tested */
    114115    SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
    115116
     
    167168    }
    168169
     170#endif
    169171    return VINF_SUCCESS;
    170172}
     
    172174static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
    173175{
     176#ifndef UNITTEST  /* Read this as not yet tested */
    174177    uint32_t        nrMappings;
    175178    SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
     
    260263    }
    261264    Log(("SharedFolders host service: successfully loaded state\n"));
     265#endif
    262266    return VINF_SUCCESS;
    263267}
  • trunk/src/VBox/HostServices/SharedFolders/testcase/Makefile.kmk

    r38152 r39540  
    5151tstShflCase_LIBS     = $(LIB_RUNTIME)
    5252
     53#
     54# HGCM service testcase.
     55#
     56
     57# As there are differences between the Windows build of the service and others,
     58# we do an additional build with RT_OS_WINDOWS defined on non-Windows targets.
     59PROGRAMS += \
     60    tstSharedFolderService \
     61    $(if $(eq $(KBUILD_TARGET),win),,tstSharedFolderService-win)
     62
     63tstSharedFolderService_TEMPLATE = VBOXR3TSTEXE
     64tstSharedFolderService_DEFS     = VBOX_WITH_HGCM UNITTEST
     65tstSharedFolderService_INCS     = ..
     66tstSharedFolderService_SOURCES  = \
     67    tstSharedFolderService.cpp \
     68    ../mappings.cpp \
     69    ../service.cpp \
     70    ../shflhandle.cpp \
     71    ../vbsf.cpp
     72tstSharedFolderService_LIBS     = $(LIB_RUNTIME)
     73
     74tstSharedFolderService-win_TEMPLATE = $(tstSharedFolderService_TEMPLATE)
     75tstSharedFolderService-win_DEFS     = \
     76    $(tstSharedFolderService_DEFS) \
     77    RT_OS_WINDOWS
     78tstSharedFolderService-win_INCS     = $(tstSharedFolderService_INCS)
     79tstSharedFolderService-win_SOURCES  = $(tstSharedFolderService_SOURCES)
     80tstSharedFolderService-win_LIBS     = $(tstSharedFolderService_LIBS)
     81
    5382endif # VBOX_WITH_TESTCASES
    5483
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r38736 r39540  
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
     18#ifdef UNITTEST
     19# include "teststubs.h"
     20# include "testcase/tstSharedFolderService.h"
     21#endif
    1722
    1823#include "mappings.h"
     
    11891194}
    11901195
     1196#ifdef UNITTEST
     1197/** Unit test the SHFL_FN_CREATE API.  Located here as a form of API
     1198 * documentation. */
     1199void testCreate(RTTEST hTest)
     1200{
     1201    /* Simple opening of an existing file. */
     1202    testCreateFileSimple(hTest);
     1203    /* Simple opening of an existing directory. */
     1204    testCreateDirSimple(hTest);
     1205    /* If the number or types of parameters are wrong the API should fail. */
     1206    testCreateBadParameters(hTest);
     1207    /* Add tests as required... */
     1208}
     1209#endif
    11911210/**
    11921211 * Create or open a file or folder.  Perform character set and case
     
    13251344}
    13261345
     1346#ifdef UNITTEST
     1347/** Unit test the SHFL_FN_CLOSE API.  Located here as a form of API
     1348 * documentation. */
     1349void testClose(RTTEST hTest)
     1350{
     1351    /* If the API parameters are invalid the API should fail. */
     1352    testCloseBadParameters(hTest);
     1353    /* Add tests as required... */
     1354}
     1355#endif
    13271356int vbsfClose (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle)
    13281357{
     
    13601389}
    13611390
     1391#ifdef UNITTEST
     1392/** Unit test the SHFL_FN_READ API.  Located here as a form of API
     1393 * documentation. */
     1394void testRead(RTTEST hTest)
     1395{
     1396    /* If the number or types of parameters are wrong the API should fail. */
     1397    testReadBadParameters(hTest);
     1398    /* Basic reading from a file. */
     1399    testReadFileSimple(hTest);
     1400    /* Add tests as required... */
     1401}
     1402#endif
    13621403int vbsfRead  (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
    13631404{
     
    13911432}
    13921433
     1434#ifdef UNITTEST
     1435/** Unit test the SHFL_FN_WRITE API.  Located here as a form of API
     1436 * documentation. */
     1437void testWrite(RTTEST hTest)
     1438{
     1439    /* If the number or types of parameters are wrong the API should fail. */
     1440    testWriteBadParameters(hTest);
     1441    /* Simple test of writing to a file. */
     1442    testWriteFileSimple(hTest);
     1443    /* Add tests as required... */
     1444}
     1445#endif
    13931446int vbsfWrite (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
    13941447{
     
    14291482
    14301483
     1484#ifdef UNITTEST
     1485/** Unit test the SHFL_FN_FLUSH API.  Located here as a form of API
     1486 * documentation. */
     1487void testFlush(RTTEST hTest)
     1488{
     1489    /* If the number or types of parameters are wrong the API should fail. */
     1490    testFlushBadParameters(hTest);
     1491    /* Simple opening and flushing of a file. */
     1492    testFlushFileSimple(hTest);
     1493    /* Add tests as required... */
     1494}
     1495#endif
    14311496int vbsfFlush(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle)
    14321497{
     
    14461511}
    14471512
     1513#ifdef UNITTEST
     1514/** Unit test the SHFL_FN_LIST API.  Located here as a form of API
     1515 * documentation. */
     1516void testDirList(RTTEST hTest)
     1517{
     1518    /* If the number or types of parameters are wrong the API should fail. */
     1519    testDirListBadParameters(hTest);
     1520    /* Test listing an empty directory (simple edge case). */
     1521    testDirListEmpty(hTest);
     1522    /* Add tests as required... */
     1523}
     1524#endif
    14481525int vbsfDirList(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, SHFLSTRING *pPath, uint32_t flags,
    14491526                uint32_t *pcbBuffer, uint8_t *pBuffer, uint32_t *pIndex, uint32_t *pcFiles)
     
    16501727}
    16511728
     1729#ifdef UNITTEST
     1730/** Unit test the SHFL_FN_READLINK API.  Located here as a form of API
     1731 * documentation. */
     1732void testReadLink(RTTEST hTest)
     1733{
     1734    /* If the number or types of parameters are wrong the API should fail. */
     1735    testReadLinkBadParameters(hTest);
     1736    /* Add tests as required... */
     1737}
     1738#endif
    16521739int vbsfReadLink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint8_t *pBuffer, uint32_t cbBuffer)
    16531740{
     
    19232010}
    19242011
     2012#ifdef UNITTEST
     2013/** Unit test the SHFL_FN_INFORMATION API.  Located here as a form of API
     2014 * documentation. */
     2015void testFSInfo(RTTEST hTest)
     2016{
     2017    /* If the number or types of parameters are wrong the API should fail. */
     2018    testFSInfoBadParameters(hTest);
     2019    /* Basic get and set file size test. */
     2020    testFSInfoQuerySetFMode(hTest);
     2021    /* Basic get and set dir atime test. */
     2022    testFSInfoQuerySetDirATime(hTest);
     2023    /* Basic get and set file atime test. */
     2024    testFSInfoQuerySetFileATime(hTest);
     2025    /* Basic set end of file. */
     2026    testFSInfoQuerySetEndOfFile(hTest);
     2027    /* Add tests as required... */
     2028}
     2029#endif
    19252030int vbsfSetFSInfo(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer)
    19262031{
     
    19512056}
    19522057
     2058#ifdef UNITTEST
     2059/** Unit test the SHFL_FN_LOCK API.  Located here as a form of API
     2060 * documentation. */
     2061void testLock(RTTEST hTest)
     2062{
     2063    /* If the number or types of parameters are wrong the API should fail. */
     2064    testLockBadParameters(hTest);
     2065    /* Simple file locking and unlocking test. */
     2066    testLockFileSimple(hTest);
     2067    /* Add tests as required... */
     2068}
     2069#endif
    19532070int vbsfLock(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint64_t offset, uint64_t length, uint32_t flags)
    19542071{
     
    20362153
    20372154
     2155#ifdef UNITTEST
     2156/** Unit test the SHFL_FN_REMOVE API.  Located here as a form of API
     2157 * documentation. */
     2158void testRemove(RTTEST hTest)
     2159{
     2160    /* If the number or types of parameters are wrong the API should fail. */
     2161    testRemoveBadParameters(hTest);
     2162    /* Add tests as required... */
     2163}
     2164#endif
    20382165int vbsfRemove(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint32_t flags)
    20392166{
     
    20842211
    20852212
     2213#ifdef UNITTEST
     2214/** Unit test the SHFL_FN_RENAME API.  Located here as a form of API
     2215 * documentation. */
     2216void testRename(RTTEST hTest)
     2217{
     2218    /* If the number or types of parameters are wrong the API should fail. */
     2219    testRenameBadParameters(hTest);
     2220    /* Add tests as required... */
     2221}
     2222#endif
    20862223int vbsfRename(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pSrc, SHFLSTRING *pDest, uint32_t flags)
    20872224{
     
    21422279}
    21432280
     2281#ifdef UNITTEST
     2282/** Unit test the SHFL_FN_SYMLINK API.  Located here as a form of API
     2283 * documentation. */
     2284void testSymlink(RTTEST hTest)
     2285{
     2286    /* If the number or types of parameters are wrong the API should fail. */
     2287    testSymlinkBadParameters(hTest);
     2288    /* Add tests as required... */
     2289}
     2290#endif
    21442291int vbsfSymlink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pNewPath, SHFLSTRING *pOldPath, SHFLFSOBJINFO *pInfo)
    21452292{
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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