mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
tst: winfsp-tests: --external tests done within a temporary directory
This commit is contained in:
parent
50af8f6444
commit
26092211a8
@ -843,7 +843,7 @@ void create_curdir_dotest(ULONG Flags, PWSTR Prefix)
|
|||||||
Success = SetCurrentDirectoryW(FilePath);
|
Success = SetCurrentDirectoryW(FilePath);
|
||||||
ASSERT(Success);
|
ASSERT(Success);
|
||||||
|
|
||||||
Success = SetCurrentDirectoryW(CurrentDirectory);
|
Success = RealSetCurrentDirectoryW(CurrentDirectory);
|
||||||
ASSERT(Success);
|
ASSERT(Success);
|
||||||
|
|
||||||
memfs_stop(memfs);
|
memfs_stop(memfs);
|
||||||
|
@ -332,3 +332,17 @@ BOOL WINAPI HookSetVolumeLabelW(
|
|||||||
MaybeAdjustTraversePrivilege(TRUE);
|
MaybeAdjustTraversePrivilege(TRUE);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI HookSetCurrentDirectoryW(
|
||||||
|
LPCWSTR lpPathName)
|
||||||
|
{
|
||||||
|
WCHAR FileNameBuf[FILENAMEBUF_SIZE];
|
||||||
|
BOOL Success;
|
||||||
|
|
||||||
|
PrepareFileName(lpPathName, FileNameBuf);
|
||||||
|
|
||||||
|
MaybeAdjustTraversePrivilege(FALSE);
|
||||||
|
Success = SetCurrentDirectoryW(FileNameBuf);
|
||||||
|
MaybeAdjustTraversePrivilege(TRUE);
|
||||||
|
return Success;
|
||||||
|
}
|
||||||
|
@ -38,6 +38,9 @@ WCHAR OptShareNameBuf[MAX_PATH], *OptShareName, *OptShareTarget;
|
|||||||
HANDLE OptNoTraverseToken = 0;
|
HANDLE OptNoTraverseToken = 0;
|
||||||
LUID OptNoTraverseLuid;
|
LUID OptNoTraverseLuid;
|
||||||
|
|
||||||
|
static WCHAR CurrentDirectory[MAX_PATH];
|
||||||
|
static PWSTR TestDirectory = L"winfsp-tests";
|
||||||
|
|
||||||
static void exiting(void);
|
static void exiting(void);
|
||||||
|
|
||||||
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen)
|
int mywcscmp(PWSTR a, int alen, PWSTR b, int blen)
|
||||||
@ -252,6 +255,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
myrandseed = (unsigned)time(0);
|
myrandseed = (unsigned)time(0);
|
||||||
|
|
||||||
|
if (NtfsTests)
|
||||||
|
{
|
||||||
|
if (!GetCurrentDirectoryW(MAX_PATH, CurrentDirectory))
|
||||||
|
ABORT("cannot get test directory");
|
||||||
|
|
||||||
|
/* create a directory for testing */
|
||||||
|
if (!CreateDirectoryW(TestDirectory, 0))
|
||||||
|
ABORT("cannot create test directory");
|
||||||
|
|
||||||
|
/* change into the directory */
|
||||||
|
if (!SetCurrentDirectoryW(TestDirectory))
|
||||||
|
ABORT("cannot change to test directory");
|
||||||
|
}
|
||||||
|
|
||||||
tlib_run_tests(argc, argv);
|
tlib_run_tests(argc, argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -259,5 +276,12 @@ int main(int argc, char *argv[])
|
|||||||
static void exiting(void)
|
static void exiting(void)
|
||||||
{
|
{
|
||||||
OutputDebugStringA("winfsp-tests: exiting\n");
|
OutputDebugStringA("winfsp-tests: exiting\n");
|
||||||
|
|
||||||
|
if (NtfsTests)
|
||||||
|
{
|
||||||
|
if (SetCurrentDirectoryW(CurrentDirectory))
|
||||||
|
RemoveDirectoryW(TestDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveNetShareIfNeeded();
|
RemoveNetShareIfNeeded();
|
||||||
}
|
}
|
||||||
|
@ -28,20 +28,6 @@
|
|||||||
#define testalpha(c) ('a' <= ((c) | 0x20) && ((c) | 0x20) <= 'z')
|
#define testalpha(c) ('a' <= ((c) | 0x20) && ((c) | 0x20) <= 'z')
|
||||||
#define togglealpha(c) ((c) ^ 0x20)
|
#define togglealpha(c) ((c) ^ 0x20)
|
||||||
|
|
||||||
#if !defined(WINFSP_TESTS_NO_HOOKS)
|
|
||||||
#define CreateFileW HookCreateFileW
|
|
||||||
#define CloseHandle HookCloseHandle
|
|
||||||
#define SetFileAttributesW HookSetFileAttributesW
|
|
||||||
#define CreateDirectoryW HookCreateDirectoryW
|
|
||||||
#define DeleteFileW HookDeleteFileW
|
|
||||||
#define RemoveDirectoryW HookRemoveDirectoryW
|
|
||||||
#define MoveFileExW HookMoveFileExW
|
|
||||||
#define FindFirstFileW HookFindFirstFileW
|
|
||||||
#define FindFirstStreamW HookFindFirstStreamW
|
|
||||||
#define GetDiskFreeSpaceW HookGetDiskFreeSpaceW
|
|
||||||
#define GetVolumeInformationW HookGetVolumeInformationW
|
|
||||||
#define SetVolumeLabelW HookSetVolumeLabelW
|
|
||||||
#endif
|
|
||||||
HANDLE WINAPI HookCreateFileW(
|
HANDLE WINAPI HookCreateFileW(
|
||||||
LPCWSTR lpFileName,
|
LPCWSTR lpFileName,
|
||||||
DWORD dwDesiredAccess,
|
DWORD dwDesiredAccess,
|
||||||
@ -92,6 +78,28 @@ BOOL WINAPI HookGetVolumeInformationW(
|
|||||||
BOOL WINAPI HookSetVolumeLabelW(
|
BOOL WINAPI HookSetVolumeLabelW(
|
||||||
LPCWSTR lpRootPathName,
|
LPCWSTR lpRootPathName,
|
||||||
LPCWSTR lpVolumeName);
|
LPCWSTR lpVolumeName);
|
||||||
|
BOOL WINAPI HookSetCurrentDirectoryW(
|
||||||
|
LPCWSTR lpPathName);
|
||||||
|
static inline BOOL RealSetCurrentDirectoryW(
|
||||||
|
LPCWSTR lpPathName)
|
||||||
|
{
|
||||||
|
return SetCurrentDirectoryW(lpPathName);
|
||||||
|
}
|
||||||
|
#if !defined(WINFSP_TESTS_NO_HOOKS)
|
||||||
|
#define CreateFileW HookCreateFileW
|
||||||
|
#define CloseHandle HookCloseHandle
|
||||||
|
#define SetFileAttributesW HookSetFileAttributesW
|
||||||
|
#define CreateDirectoryW HookCreateDirectoryW
|
||||||
|
#define DeleteFileW HookDeleteFileW
|
||||||
|
#define RemoveDirectoryW HookRemoveDirectoryW
|
||||||
|
#define MoveFileExW HookMoveFileExW
|
||||||
|
#define FindFirstFileW HookFindFirstFileW
|
||||||
|
#define FindFirstStreamW HookFindFirstStreamW
|
||||||
|
#define GetDiskFreeSpaceW HookGetDiskFreeSpaceW
|
||||||
|
#define GetVolumeInformationW HookGetVolumeInformationW
|
||||||
|
#define SetVolumeLabelW HookSetVolumeLabelW
|
||||||
|
#define SetCurrentDirectoryW HookSetCurrentDirectoryW
|
||||||
|
#endif
|
||||||
|
|
||||||
HANDLE WINAPI ResilientCreateFileW(
|
HANDLE WINAPI ResilientCreateFileW(
|
||||||
LPCWSTR lpFileName,
|
LPCWSTR lpFileName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user