mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-15 16:22:43 -05:00
Merge branch 'pvt-sqlfix2'
This commit is contained in:
@ -319,6 +319,15 @@ void mount_preflight_dotest(PWSTR DeviceName)
|
||||
MountPoint[2] = L'\0';
|
||||
|
||||
GetTestDirectory(DirBuf);
|
||||
/*
|
||||
* Mount points starting with \\?\X: or \\.\X: are now considered MountManager mountpoints.
|
||||
* So skip the \\?\ prefix to avoid this problem.
|
||||
*/
|
||||
if (L'\\' == DirBuf[0] &&
|
||||
L'\\' == DirBuf[1] &&
|
||||
(L'?' == DirBuf[2] || L'.' == DirBuf[2]) &&
|
||||
L'\\' == DirBuf[3])
|
||||
memmove(DirBuf, DirBuf + 4, (wcslen(DirBuf + 4) + 1) * sizeof(WCHAR));
|
||||
|
||||
Drives = GetLogicalDrives();
|
||||
ASSERT(0 != Drives);
|
||||
|
60
tst/winfsp-tests/uuid5-test.c
Normal file
60
tst/winfsp-tests/uuid5-test.c
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file uuid5-test.c
|
||||
*
|
||||
* @copyright 2015-2019 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
*
|
||||
* You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License version 3 as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Licensees holding a valid commercial license may use this software
|
||||
* in accordance with the commercial license agreement provided in
|
||||
* conjunction with the software. The terms and conditions of any such
|
||||
* commercial license agreement shall govern, supersede, and render
|
||||
* ineffective any application of the GPLv3 license to this software,
|
||||
* notwithstanding of any reference thereto in the software or
|
||||
* associated repository.
|
||||
*/
|
||||
|
||||
#include <winfsp/winfsp.h>
|
||||
#include <tlib/testsuite.h>
|
||||
|
||||
#include "winfsp-tests.h"
|
||||
|
||||
#pragma comment(lib, "bcrypt.lib")
|
||||
#include <ku/uuid5.c>
|
||||
|
||||
static void uuid5_test(void)
|
||||
{
|
||||
// 6ba7b810-9dad-11d1-80b4-00c04fd430c8
|
||||
static const GUID GuidNs =
|
||||
{ 0x6ba7b810, 0x9dad, 0x11d1, { 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 } };
|
||||
// 74738ff5-5367-5958-9aee-98fffdcd1876
|
||||
static const GUID Guid0 =
|
||||
{ 0x74738ff5, 0x5367, 0x5958, { 0x9a, 0xee, 0x98, 0xff, 0xfd, 0xcd, 0x18, 0x76 } };
|
||||
// 63b5d721-0b97-5e7a-a550-2f0e589b5478
|
||||
static const GUID Guid1 =
|
||||
{ 0x63b5d721, 0x0b97, 0x5e7a, { 0xa5, 0x50, 0x2f, 0x0e, 0x58, 0x9b, 0x54, 0x78 } };
|
||||
|
||||
NTSTATUS Result;
|
||||
GUID Guid;
|
||||
|
||||
Result = FspUuid5Make(&GuidNs, "www.example.org", 15, &Guid);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
ASSERT(IsEqualGUID(&Guid0, &Guid));
|
||||
|
||||
Result = FspUuid5Make(&FspFsvrtDeviceClassGuid, "hello", 5, &Guid);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
ASSERT(IsEqualGUID(&Guid1, &Guid));
|
||||
}
|
||||
|
||||
void uuid5_tests(void)
|
||||
{
|
||||
if (OptExternal)
|
||||
return;
|
||||
|
||||
TEST(uuid5_test);
|
||||
}
|
234
tst/winfsp-tests/volpath-test.c
Normal file
234
tst/winfsp-tests/volpath-test.c
Normal file
@ -0,0 +1,234 @@
|
||||
/**
|
||||
* @file volpath-test.c
|
||||
*
|
||||
* @copyright 2015-2019 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
*
|
||||
* You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License version 3 as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Licensees holding a valid commercial license may use this software
|
||||
* in accordance with the commercial license agreement provided in
|
||||
* conjunction with the software. The terms and conditions of any such
|
||||
* commercial license agreement shall govern, supersede, and render
|
||||
* ineffective any application of the GPLv3 license to this software,
|
||||
* notwithstanding of any reference thereto in the software or
|
||||
* associated repository.
|
||||
*/
|
||||
|
||||
#include <winfsp/winfsp.h>
|
||||
#include <tlib/testsuite.h>
|
||||
#include <strsafe.h>
|
||||
#include "memfs.h"
|
||||
|
||||
#include "winfsp-tests.h"
|
||||
|
||||
static void volpath_dotest(ULONG Flags, PWSTR Prefix)
|
||||
{
|
||||
void *memfs = memfs_start(Flags);
|
||||
|
||||
HANDLE Handle;
|
||||
BOOLEAN Success, VolumePathNameSuccess[8];
|
||||
WCHAR FilePath[MAX_PATH];
|
||||
WCHAR VolumePathName[MAX_PATH];
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = CreateDirectoryW(FilePath, 0);
|
||||
ASSERT(Success);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Handle = CreateFileW(FilePath,
|
||||
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ASSERT(INVALID_HANDLE_VALUE != Handle);
|
||||
CloseHandle(Handle);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[0] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[1] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[2] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = DeleteFileW(FilePath);
|
||||
ASSERT(Success);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = RemoveDirectoryW(FilePath);
|
||||
ASSERT(Success);
|
||||
|
||||
memfs_stop(memfs);
|
||||
|
||||
ASSERT(VolumePathNameSuccess[0] == VolumePathNameSuccess[1]);
|
||||
ASSERT(VolumePathNameSuccess[1] == VolumePathNameSuccess[2]);
|
||||
}
|
||||
|
||||
static void volpath_test(void)
|
||||
{
|
||||
/*
|
||||
* GetVolumePathName is not reliable on WinFsp file systems
|
||||
* when *not* using the MountManager and therefore disable
|
||||
* this test when using a non-MountManager mount point.
|
||||
*/
|
||||
if (!NtfsTests && !OptMountPoint)
|
||||
return;
|
||||
|
||||
if (WinFspDiskTests)
|
||||
volpath_dotest(MemfsDisk, 0);
|
||||
if (WinFspNetTests)
|
||||
volpath_dotest(MemfsNet, L"\\\\memfs\\share");
|
||||
}
|
||||
|
||||
static void volpath_mount_dotest(ULONG Flags, PWSTR Prefix, PWSTR MountPoint)
|
||||
{
|
||||
void *memfs = memfs_start(Flags);
|
||||
|
||||
NTSTATUS Result;
|
||||
HANDLE Handle;
|
||||
BOOLEAN Success, VolumePathNameSuccess[8];
|
||||
WCHAR FilePath[MAX_PATH];
|
||||
WCHAR VolumePathName[MAX_PATH], VolumeName[MAX_PATH];
|
||||
|
||||
Result = FspFileSystemSetMountPoint(MemfsFileSystem(memfs), MountPoint);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
|
||||
Prefix = FspFileSystemMountPoint(MemfsFileSystem(memfs));
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = CreateDirectoryW(FilePath, 0);
|
||||
ASSERT(Success);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Handle = CreateFileW(FilePath,
|
||||
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ASSERT(INVALID_HANDLE_VALUE != Handle);
|
||||
CloseHandle(Handle);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[0] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
VolumePathNameSuccess[4] = GetVolumeNameForVolumeMountPointW(VolumePathName, VolumeName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[1] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
VolumePathNameSuccess[5] = GetVolumeNameForVolumeMountPointW(VolumePathName, VolumeName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
VolumePathNameSuccess[2] = GetVolumePathNameW(FilePath, VolumePathName, MAX_PATH);
|
||||
VolumePathNameSuccess[6] = GetVolumeNameForVolumeMountPointW(VolumePathName, VolumeName, MAX_PATH);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\file2",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = DeleteFileW(FilePath);
|
||||
ASSERT(Success);
|
||||
|
||||
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
|
||||
Success = RemoveDirectoryW(FilePath);
|
||||
ASSERT(Success);
|
||||
|
||||
FspFileSystemRemoveMountPoint(MemfsFileSystem(memfs));
|
||||
|
||||
memfs_stop(memfs);
|
||||
|
||||
ASSERT(VolumePathNameSuccess[0]);
|
||||
ASSERT(VolumePathNameSuccess[1]);
|
||||
ASSERT(VolumePathNameSuccess[2]);
|
||||
|
||||
if (MemfsNet != Flags)
|
||||
{
|
||||
ASSERT(VolumePathNameSuccess[4]);
|
||||
ASSERT(VolumePathNameSuccess[5]);
|
||||
ASSERT(VolumePathNameSuccess[6]);
|
||||
}
|
||||
}
|
||||
|
||||
static void volpath_mount_test(void)
|
||||
{
|
||||
/*
|
||||
* This test does FspFileSystemSetMountPoint and therefore
|
||||
* cannot be used with --external or --mountpoint.
|
||||
*/
|
||||
if (NtfsTests || OptMountPoint)
|
||||
return;
|
||||
|
||||
if (WinFspDiskTests)
|
||||
{
|
||||
WCHAR MountPoint[7];
|
||||
DWORD Drives;
|
||||
WCHAR Drive;
|
||||
|
||||
MountPoint[0] = L'\\';
|
||||
MountPoint[1] = L'\\';
|
||||
MountPoint[2] = L'.';
|
||||
MountPoint[3] = L'\\';
|
||||
MountPoint[4] = L'C';
|
||||
MountPoint[5] = L':';
|
||||
MountPoint[6] = L'\0';
|
||||
|
||||
Drives = GetLogicalDrives();
|
||||
ASSERT(0 != Drives);
|
||||
|
||||
for (Drive = 'Z'; 'A' <= Drive; Drive--)
|
||||
if (0 == (Drives & (1 << (Drive - 'A'))))
|
||||
break;
|
||||
ASSERT('A' <= Drive);
|
||||
|
||||
MountPoint[4] = Drive;
|
||||
|
||||
//volpath_mount_dotest(MemfsDisk, 0, 0);
|
||||
volpath_mount_dotest(MemfsDisk, 0, MountPoint);
|
||||
}
|
||||
if (WinFspNetTests)
|
||||
{
|
||||
volpath_mount_dotest(MemfsNet, L"\\\\memfs\\share", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void volpath_tests(void)
|
||||
{
|
||||
/*
|
||||
* GetVolumePathName is not reliable on WinFsp file systems
|
||||
* when *not* using the MountManager and therefore disable
|
||||
* this test when using a non-MountManager mount point.
|
||||
*/
|
||||
if (!NtfsTests && !OptMountPoint)
|
||||
TEST(volpath_test);
|
||||
|
||||
/*
|
||||
* This test does FspFileSystemSetMountPoint and therefore
|
||||
* cannot be used with --external or --mountpoint.
|
||||
*/
|
||||
if (!NtfsTests && !OptMountPoint)
|
||||
TEST(volpath_mount_test);
|
||||
}
|
@ -188,6 +188,7 @@ int main(int argc, char *argv[])
|
||||
TESTSUITE(fuse_opt_tests);
|
||||
TESTSUITE(fuse_tests);
|
||||
TESTSUITE(posix_tests);
|
||||
TESTSUITE(uuid5_tests);
|
||||
TESTSUITE(eventlog_tests);
|
||||
TESTSUITE(path_tests);
|
||||
TESTSUITE(dirbuf_tests);
|
||||
@ -211,6 +212,7 @@ int main(int argc, char *argv[])
|
||||
TESTSUITE(stream_tests);
|
||||
TESTSUITE(oplock_tests);
|
||||
TESTSUITE(wsl_tests);
|
||||
TESTSUITE(volpath_tests);
|
||||
|
||||
atexit(exiting);
|
||||
signal(SIGABRT, abort_handler);
|
||||
|
Reference in New Issue
Block a user