mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
winfsp-tests: memfs-test, create-test
This commit is contained in:
parent
d9464ba88f
commit
08ba86980d
@ -176,6 +176,8 @@
|
|||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\create-test.c" />
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.cpp" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.cpp" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
||||||
|
@ -28,6 +28,12 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.cpp">
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.cpp">
|
||||||
<Filter>Source</Filter>
|
<Filter>Source</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\create-test.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
||||||
|
29
tst/winfsp-tests/create-test.c
Normal file
29
tst/winfsp-tests/create-test.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
#include <tlib/testsuite.h>
|
||||||
|
#include "memfs.h"
|
||||||
|
|
||||||
|
void *memfs_start(ULONG Flags);
|
||||||
|
void memfs_stop(void *data);
|
||||||
|
|
||||||
|
extern int WinFspDiskTests;
|
||||||
|
extern int WinFspNetTests;
|
||||||
|
|
||||||
|
void create_dotest(ULONG Flags)
|
||||||
|
{
|
||||||
|
void *memfs = memfs_start(Flags);
|
||||||
|
|
||||||
|
memfs_stop(memfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_test(void)
|
||||||
|
{
|
||||||
|
if (WinFspDiskTests)
|
||||||
|
create_dotest(MemfsDisk);
|
||||||
|
if (WinFspNetTests)
|
||||||
|
create_dotest(MemfsNet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_tests(void)
|
||||||
|
{
|
||||||
|
TEST(create_test);
|
||||||
|
}
|
79
tst/winfsp-tests/memfs-test.c
Normal file
79
tst/winfsp-tests/memfs-test.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
#include <tlib/testsuite.h>
|
||||||
|
#include <process.h>
|
||||||
|
#include "memfs.h"
|
||||||
|
|
||||||
|
extern int WinFspDiskTests;
|
||||||
|
extern int WinFspNetTests;
|
||||||
|
|
||||||
|
struct memfs_data
|
||||||
|
{
|
||||||
|
MEMFS *Memfs;
|
||||||
|
HANDLE Thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
static unsigned __stdcall memfs_thread(void *Memfs0)
|
||||||
|
{
|
||||||
|
MEMFS *Memfs = Memfs0;
|
||||||
|
return FspFileSystemLoop(MemfsFileSystem(Memfs));
|
||||||
|
}
|
||||||
|
|
||||||
|
void *memfs_start(ULONG Flags)
|
||||||
|
{
|
||||||
|
struct memfs_data *data;
|
||||||
|
MEMFS *Memfs;
|
||||||
|
HANDLE Thread;
|
||||||
|
NTSTATUS Result;
|
||||||
|
|
||||||
|
data = malloc(sizeof *data);
|
||||||
|
ASSERT(0 != data);
|
||||||
|
|
||||||
|
Result = MemfsCreate(Flags, 1000, 65500, &Memfs);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
ASSERT(0 != Memfs);
|
||||||
|
|
||||||
|
Thread = (HANDLE)_beginthreadex(0, 0, memfs_thread, Memfs, 0, 0);
|
||||||
|
ASSERT(0 != Thread);
|
||||||
|
|
||||||
|
data->Memfs = Memfs;
|
||||||
|
data->Thread = Thread;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void memfs_stop(void *data)
|
||||||
|
{
|
||||||
|
MEMFS *Memfs = ((struct memfs_data *)data)->Memfs;
|
||||||
|
HANDLE Thread = ((struct memfs_data *)data)->Thread;
|
||||||
|
DWORD ExitCode;
|
||||||
|
|
||||||
|
FspFileSystemSetDispatcherResult(MemfsFileSystem(Memfs), STATUS_CANCELLED);
|
||||||
|
|
||||||
|
WaitForSingleObject(Thread, INFINITE);
|
||||||
|
GetExitCodeThread(Thread, &ExitCode);
|
||||||
|
CloseHandle(Thread);
|
||||||
|
|
||||||
|
ASSERT(STATUS_CANCELLED == ExitCode);
|
||||||
|
|
||||||
|
MemfsDelete(Memfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void memfs_dotest(ULONG Flags)
|
||||||
|
{
|
||||||
|
void *memfs = memfs_start(Flags);
|
||||||
|
|
||||||
|
memfs_stop(memfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void memfs_test(void)
|
||||||
|
{
|
||||||
|
if (WinFspDiskTests)
|
||||||
|
memfs_dotest(MemfsDisk);
|
||||||
|
if (WinFspNetTests)
|
||||||
|
memfs_dotest(MemfsNet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void memfs_tests(void)
|
||||||
|
{
|
||||||
|
TEST(memfs_test);
|
||||||
|
}
|
@ -419,3 +419,8 @@ VOID MemfsDelete(MEMFS *Memfs)
|
|||||||
|
|
||||||
free(Memfs);
|
free(Memfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FSP_FILE_SYSTEM *MemfsFileSystem(MEMFS *Memfs)
|
||||||
|
{
|
||||||
|
return Memfs->FileSystem;
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ enum
|
|||||||
NTSTATUS MemfsCreate(ULONG Flags, ULONG MaxFileNodes, ULONG MaxFileSize,
|
NTSTATUS MemfsCreate(ULONG Flags, ULONG MaxFileNodes, ULONG MaxFileSize,
|
||||||
MEMFS **PMemfs);
|
MEMFS **PMemfs);
|
||||||
VOID MemfsDelete(MEMFS *Memfs);
|
VOID MemfsDelete(MEMFS *Memfs);
|
||||||
|
FSP_FILE_SYSTEM *MemfsFileSystem(MEMFS *Memfs);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ int main(int argc, char *argv[])
|
|||||||
TESTSUITE(path_tests);
|
TESTSUITE(path_tests);
|
||||||
TESTSUITE(mount_tests);
|
TESTSUITE(mount_tests);
|
||||||
TESTSUITE(timeout_tests);
|
TESTSUITE(timeout_tests);
|
||||||
|
TESTSUITE(memfs_tests);
|
||||||
|
TESTSUITE(create_tests);
|
||||||
|
|
||||||
tlib_run_tests(argc, argv);
|
tlib_run_tests(argc, argv);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user