mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: reparse point testing
This commit is contained in:
parent
80e07cead6
commit
28931f4687
@ -193,6 +193,7 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\rdwr-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\rdwr-test.c" />
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\reparse-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c" />
|
||||||
|
@ -61,6 +61,9 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c">
|
<ClCompile Include="..\..\..\tst\winfsp-tests\posix-test.c">
|
||||||
<Filter>Source</Filter>
|
<Filter>Source</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\reparse-test.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
||||||
|
108
tst/winfsp-tests/reparse-test.c
Normal file
108
tst/winfsp-tests/reparse-test.c
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
#include <tlib/testsuite.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include "memfs.h"
|
||||||
|
|
||||||
|
void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout);
|
||||||
|
void *memfs_start(ULONG Flags);
|
||||||
|
void memfs_stop(void *data);
|
||||||
|
PWSTR memfs_volumename(void *data);
|
||||||
|
|
||||||
|
extern int NtfsTests;
|
||||||
|
extern int WinFspDiskTests;
|
||||||
|
extern int WinFspNetTests;
|
||||||
|
|
||||||
|
static const GUID reparse_guid =
|
||||||
|
{ 0x895fc61e, 0x7b91, 0x4677, { 0xba, 0x3e, 0x79, 0x34, 0xed, 0xf2, 0xb7, 0x43 } };
|
||||||
|
|
||||||
|
void reparse_setget_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
|
||||||
|
{
|
||||||
|
void *memfs = memfs_start_ex(Flags, FileInfoTimeout);
|
||||||
|
|
||||||
|
HANDLE Handle;
|
||||||
|
BOOL Success;
|
||||||
|
WCHAR FilePath[MAX_PATH];
|
||||||
|
union
|
||||||
|
{
|
||||||
|
REPARSE_DATA_BUFFER D;
|
||||||
|
REPARSE_GUID_DATA_BUFFER G;
|
||||||
|
UINT8 B[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
|
||||||
|
} ReparseDataBuf;
|
||||||
|
DWORD Bytes;
|
||||||
|
static const char *datstr = "foobar";
|
||||||
|
|
||||||
|
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0",
|
||||||
|
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||||
|
|
||||||
|
Handle = CreateFileW(FilePath,
|
||||||
|
FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
|
0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
ASSERT(INVALID_HANDLE_VALUE != Handle);
|
||||||
|
|
||||||
|
ReparseDataBuf.G.ReparseTag = 0x1234;
|
||||||
|
ReparseDataBuf.G.ReparseDataLength = (USHORT)strlen(datstr);
|
||||||
|
ReparseDataBuf.G.Reserved = 0;
|
||||||
|
memcpy(&ReparseDataBuf.G.ReparseGuid, &reparse_guid, sizeof reparse_guid);
|
||||||
|
memcpy(ReparseDataBuf.G.GenericReparseBuffer.DataBuffer, datstr, strlen(datstr));
|
||||||
|
|
||||||
|
Success = DeviceIoControl(Handle, FSCTL_SET_REPARSE_POINT,
|
||||||
|
&ReparseDataBuf, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE + ReparseDataBuf.G.ReparseDataLength,
|
||||||
|
0, 0,
|
||||||
|
&Bytes, 0);
|
||||||
|
ASSERT(Success);
|
||||||
|
|
||||||
|
Success = DeviceIoControl(Handle, FSCTL_GET_REPARSE_POINT,
|
||||||
|
0, 0,
|
||||||
|
&ReparseDataBuf, sizeof ReparseDataBuf,
|
||||||
|
&Bytes, 0);
|
||||||
|
ASSERT(Success);
|
||||||
|
|
||||||
|
ASSERT(ReparseDataBuf.G.ReparseTag == 0x1234);
|
||||||
|
ASSERT(ReparseDataBuf.G.ReparseDataLength == strlen(datstr) + 1);
|
||||||
|
ASSERT(ReparseDataBuf.G.Reserved == 0);
|
||||||
|
ASSERT(0 == memcmp(&ReparseDataBuf.G.ReparseGuid, &reparse_guid, sizeof reparse_guid));
|
||||||
|
ASSERT(0 == memcmp(ReparseDataBuf.G.GenericReparseBuffer.DataBuffer, datstr, strlen(datstr)));
|
||||||
|
|
||||||
|
Success = DeviceIoControl(Handle, FSCTL_DELETE_REPARSE_POINT,
|
||||||
|
&ReparseDataBuf, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE + ReparseDataBuf.G.ReparseDataLength,
|
||||||
|
0, 0,
|
||||||
|
&Bytes, 0);
|
||||||
|
ASSERT(Success);
|
||||||
|
|
||||||
|
Success = DeviceIoControl(Handle, FSCTL_GET_REPARSE_POINT,
|
||||||
|
0, 0,
|
||||||
|
&ReparseDataBuf, sizeof ReparseDataBuf,
|
||||||
|
&Bytes, 0);
|
||||||
|
ASSERT(!Success);
|
||||||
|
ASSERT(ERROR_NOT_A_REPARSE_POINT == GetLastError());
|
||||||
|
|
||||||
|
CloseHandle(Handle);
|
||||||
|
|
||||||
|
Success = DeleteFileW(FilePath);
|
||||||
|
ASSERT(Success);
|
||||||
|
|
||||||
|
memfs_stop(memfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reparse_setget_test(void)
|
||||||
|
{
|
||||||
|
if (NtfsTests)
|
||||||
|
{
|
||||||
|
WCHAR DirBuf[MAX_PATH] = L"\\\\?\\";
|
||||||
|
GetCurrentDirectoryW(MAX_PATH - 4, DirBuf + 4);
|
||||||
|
reparse_setget_dotest(-1, DirBuf, 0);
|
||||||
|
}
|
||||||
|
if (WinFspDiskTests)
|
||||||
|
{
|
||||||
|
reparse_setget_dotest(MemfsDisk, 0, 0);
|
||||||
|
}
|
||||||
|
if (WinFspNetTests)
|
||||||
|
{
|
||||||
|
reparse_setget_dotest(MemfsNet, L"\\\\memfs\\share", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reparse_tests(void)
|
||||||
|
{
|
||||||
|
TEST(reparse_setget_test);
|
||||||
|
}
|
@ -20,6 +20,7 @@ int main(int argc, char *argv[])
|
|||||||
TESTSUITE(flush_tests);
|
TESTSUITE(flush_tests);
|
||||||
TESTSUITE(lock_tests);
|
TESTSUITE(lock_tests);
|
||||||
TESTSUITE(dirctl_tests);
|
TESTSUITE(dirctl_tests);
|
||||||
|
TESTSUITE(reparse_tests);
|
||||||
|
|
||||||
tlib_run_tests(argc, argv);
|
tlib_run_tests(argc, argv);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user