/* $Id$ */
/** @file
* Testcase for the shared folder service vbsf API.
*
* Note that this is still very threadbare (there is an awful lot which should
* really be tested, but it already took too long to produce this much). The
* idea is that anyone who makes changes to the shared folders service and who
* cares about unit testing them should add tests to the skeleton framework to
* exercise the bits they change before and after changing them.
*/
/*
* Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/******************************************************************************
* Header Files *
******************************************************************************/
#include "tstSharedFolderService.h"
#include "vbsf.h"
#include "teststubs.h"
/******************************************************************************
* Global Variables *
******************************************************************************/
/******************************************************************************
* Declarations *
******************************************************************************/
/******************************************************************************
* Helpers *
******************************************************************************/
/** Simple call handle structure for the guest call completion callback */
struct VBOXHGCMCALLHANDLE_TYPEDEF
{
/** Where to store the result code */
};
/** Call completion callback for guest calls. */
{
}
/**
* Initialise the HGCM service table as much as we need to start the
* service
* @param pTable the table to initialise
*/
{
}
#define LLUIFY(a) ((unsigned long long)(a))
{
}
{
char *psz;
if (*psz == '\\')
*psz = '/';
}
#define ARRAY_FROM_PATH(a, b) \
do { \
Assert((a) == (a)); /* Constant parameter */ \
Assert(sizeof((a)) > 0); \
bufferFromPath(a, sizeof(a), b); \
} while (0)
/******************************************************************************
* Stub functions and data *
******************************************************************************/
{
/* RTPrintf("%s: pDir=%p\n", __PRETTY_FUNCTION__, pDir); */
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: pszPath=%s, fMode=0x%llx\n", __PRETTY_FUNCTION__, pszPath,
LLUIFY(fMode)); */
return 0;
}
{
/* RTPrintf("%s: pszPath=%s\n", __PRETTY_FUNCTION__, pszPath); */
testRTDirOpenpDir = 0;
return VINF_SUCCESS;
}
/** @todo Do something useful with the last two arguments. */
{
/* RTPrintf("%s: pszPath=%s\n", __PRETTY_FUNCTION__, pszPath); */
testRTDirOpenpDir = 0;
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: pDir=%p, enmAdditionalAttribs=0x%llx\n", __PRETTY_FUNCTION__,
pDir, LLUIFY(enmAdditionalAttribs)); */
return VINF_SUCCESS;
}
extern int testRTDirRemove(const char *pszPath) { RTPrintf("%s\n", __PRETTY_FUNCTION__); return 0; }
{
/* RTPrintf("%s: pDir=%p, pcbDirEntry=%d, enmAdditionalAttribs=%llu, fFlags=0x%llx\n",
__PRETTY_FUNCTION__, pDir, pcbDirEntry ? (int) *pcbDirEntry : -1,
LLUIFY(enmAdditionalAttribs), LLUIFY(fFlags)); */
return VERR_NO_MORE_FILES;
}
{
/* RTPrintf("%s: pDir=%p, *pAccessTime=%lli, *pModificationTime=%lli, *pChangeTime=%lli, *pBirthTime=%lli\n",
__PRETTY_FUNCTION__, pDir,
pAccessTime ? (long long)RTTimeSpecGetNano(pAccessTime) : -1,
pModificationTime
? (long long)RTTimeSpecGetNano(pModificationTime) : -1,
pChangeTime ? (long long)RTTimeSpecGetNano(pChangeTime) : -1,
pBirthTime ? (long long)RTTimeSpecGetNano(pBirthTime) : -1); */
if (pAccessTime)
else
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: File=%p\n", __PRETTY_FUNCTION__, File); */
return 0;
}
extern int testRTFileDelete(const char *pszFilename) { RTPrintf("%s\n", __PRETTY_FUNCTION__); return 0; }
{
/* RTPrintf("%s: File=%p\n", __PRETTY_FUNCTION__, File); */
return VINF_SUCCESS;
}
static unsigned testRTFileLockfLock;
{
/* RTPrintf("%s: hFile=%p, fLock=%u, offLock=%lli, cbLock=%llu\n",
__PRETTY_FUNCTION__, hFile, fLock, (long long) offLock,
LLUIFY(cbLock)); */
return VINF_SUCCESS;
}
{
/* RTPrintf("%s, pszFilename=%s, fOpen=0x%llx\n", __PRETTY_FUNCTION__,
pszFilename, LLUIFY(fOpen)); */
testRTFileOpenpFile = 0;
return VINF_SUCCESS;
}
extern int testRTFileQueryInfo(RTFILE hFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
{
/* RTPrintf("%s, hFile=%p, enmAdditionalAttribs=0x%llx\n",
__PRETTY_FUNCTION__, hFile, LLUIFY(enmAdditionalAttribs)); */
return VINF_SUCCESS;
}
static const char *testRTFileReadData;
{
/* RTPrintf("%s : File=%p, cbToRead=%llu\n", __PRETTY_FUNCTION__, File,
LLUIFY(cbToRead)); */
if (pcbRead)
testRTFileReadData = 0;
return VINF_SUCCESS;
}
{
/* RTPrintf("%s : hFile=%p, offSeek=%llu, uMethod=%u\n", __PRETTY_FUNCTION__,
hFile, LLUIFY(offSeek), uMethod); */
if (poffActual)
*poffActual = 0;
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: fMode=%llu\n", __PRETTY_FUNCTION__, LLUIFY(fMode)); */
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: File=%llu, cbSize=%llu\n", __PRETTY_FUNCTION__, LLUIFY(File),
LLUIFY(cbSize)); */
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: pFile=%p, *pAccessTime=%lli, *pModificationTime=%lli, *pChangeTime=%lli, *pBirthTime=%lli\n",
__PRETTY_FUNCTION__,
pAccessTime ? (long long)RTTimeSpecGetNano(pAccessTime) : -1,
pModificationTime
? (long long)RTTimeSpecGetNano(pModificationTime) : -1,
pChangeTime ? (long long)RTTimeSpecGetNano(pChangeTime) : -1,
pBirthTime ? (long long)RTTimeSpecGetNano(pBirthTime) : -1); */
if (pAccessTime)
else
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: hFile=%p, ofLock=%lli, cbLock=%llu\n", __PRETTY_FUNCTION__,
File, (long long) offLock, LLUIFY(cbLock)); */
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: File=%p, pvBuf=%.*s, cbToWrite=%llu\n", __PRETTY_FUNCTION__,
File, cbToWrite, (const char *)pvBuf, LLUIFY(cbToWrite)); */
if (pcbWritten)
return VINF_SUCCESS;
}
{
/* RTPrintf("%s, pszFsPath=%s\n", __PRETTY_FUNCTION__, pszFsPath);
RT_ZERO(*pProperties); */
pProperties->fCaseSensitive = true;
return VINF_SUCCESS;
}
{
/* RTPrintf("%s: pszPath=%s, enmAdditionalAttribs=0x%x, fFlags=0x%x\n",
__PRETTY_FUNCTION__, pszPath, (unsigned) enmAdditionalAttribs,
(unsigned) fFlags); */
return VINF_SUCCESS;
}
/******************************************************************************
* Tests *
******************************************************************************/
/* Sub-tests for testMappingsQuery(). */
/* Sub-tests for testMappingsQueryName(). */
/* Sub-tests for testMapFolder(). */
/* Sub-tests for testUnmapFolder(). */
/* Sub-tests for testCreate(). */
/* Sub-tests for testClose(). */
/* Sub-tests for testRead(). */
/* Sub-tests for testWrite(). */
/* Sub-tests for testLock(). */
/* Sub-tests for testFlush(). */
/* Sub-tests for testDirList(). */
/* Sub-tests for testReadLink(). */
/* Sub-tests for testFSInfo(). */
/* Sub-tests for testRemove(). */
/* Sub-tests for testRename(). */
/* Sub-tests for testSymlink(). */
/* Sub-tests for testMappingsAdd(). */
/* Sub-tests for testMappingsRemove(). */
struct TESTSHFLSTRING
{
};
const char *pcszSource)
{
}
const char *pcszFolderName,
const char *pcszMapping)
{
int rc;
}
/** @todo Mappings should be automatically removed by unloading the service,
* but unloading is currently a no-op! */
{
int rc;
}
{
return callHandle.rc;
if (pHandle)
if (pResult)
return VINF_SUCCESS;
}
{
if (pcbRead)
return callHandle.rc;
}
{
if (pcbWritten)
return callHandle.rc;
}
{
return callHandle.rc;
}
{
if (pcszPath)
{
}
else
if (pcFiles)
return callHandle.rc;
}
{
return callHandle.rc;
}
{
return callHandle.rc;
}
{
int rc;
&Result);
}
{
int rc;
}
{
int rc;
}
{
int rc;
}
{
int rc;
}
{
int rc;
}
{
int rc;
&Info);
}
{
int rc;
&Info);
(hTest, "ATime=%llu\n",
== ccAtimeNano,
(hTest, "ATime=%llu\n",
}
{
int rc;
&Info);
(hTest, "ATime=%llu\n",
== ccAtimeNano,
(hTest, "ATime=%llu\n",
}
{
int rc;
}
{
int rc;
#ifdef RT_OS_WINDOWS /* Locking is a no-op elsewhere. */
#endif
#ifdef RT_OS_WINDOWS
(hTest, "Offs=%llu\n",
(long long) testRTFileUnlockOffset));
#endif
}
/******************************************************************************
* Main code *
******************************************************************************/
{
/* testSetStatusLed(hTest); */
}
{
&g_hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
return RTTestSummaryAndDestroy(g_hTest);
}