From 1db9f2b6778a34fddfa5a5cab499cef73f158a89 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sun, 24 Jan 2016 11:27:38 -0800 Subject: [PATCH] winfsp-tests: getinfo_test --- build/VStudio/testing/winfsp-tests.vcxproj | 1 + .../testing/winfsp-tests.vcxproj.filters | 3 ++ tst/winfsp-tests/fileinfo-test.c | 51 +++++++++++++++++++ tst/winfsp-tests/winfsp-tests.c | 1 + 4 files changed, 56 insertions(+) create mode 100644 tst/winfsp-tests/fileinfo-test.c diff --git a/build/VStudio/testing/winfsp-tests.vcxproj b/build/VStudio/testing/winfsp-tests.vcxproj index 46c5fd37..abfdc6b8 100644 --- a/build/VStudio/testing/winfsp-tests.vcxproj +++ b/build/VStudio/testing/winfsp-tests.vcxproj @@ -181,6 +181,7 @@ TurnOffAllWarnings + diff --git a/build/VStudio/testing/winfsp-tests.vcxproj.filters b/build/VStudio/testing/winfsp-tests.vcxproj.filters index b70b6055..035d49e8 100644 --- a/build/VStudio/testing/winfsp-tests.vcxproj.filters +++ b/build/VStudio/testing/winfsp-tests.vcxproj.filters @@ -34,6 +34,9 @@ Source + + Source + diff --git a/tst/winfsp-tests/fileinfo-test.c b/tst/winfsp-tests/fileinfo-test.c new file mode 100644 index 00000000..7e5eb7c6 --- /dev/null +++ b/tst/winfsp-tests/fileinfo-test.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include "memfs.h" + +void *memfs_start(ULONG Flags); +void memfs_stop(void *data); +PWSTR memfs_volumename(void *data); + +extern int NtfsTests; +extern int WinFspDiskTests; +extern int WinFspNetTests; + +void getinfo_dotest(ULONG Flags, PWSTR Prefix) +{ + void *memfs = memfs_start(Flags); + + HANDLE Handle; + WCHAR FilePath[MAX_PATH]; + + StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\file0", + 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 | FILE_FLAG_DELETE_ON_CLOSE, 0); + ASSERT(INVALID_HANDLE_VALUE != Handle); + CloseHandle(Handle); + + memfs_stop(memfs); +} + +void getinfo_test(void) +{ + if (NtfsTests) + { + WCHAR DirBuf[MAX_PATH] = L"\\\\?\\"; + GetCurrentDirectoryW(MAX_PATH - 4, DirBuf + 4); + getinfo_dotest(-1, DirBuf); + } + if (WinFspDiskTests) + getinfo_dotest(MemfsDisk, 0); + if (WinFspNetTests) + getinfo_dotest(MemfsNet, L"\\\\memfs\\share"); +} + +void getinfo_tests(void) +{ + TEST(getinfo_test); +} diff --git a/tst/winfsp-tests/winfsp-tests.c b/tst/winfsp-tests/winfsp-tests.c index 53271cc5..383b5ff6 100644 --- a/tst/winfsp-tests/winfsp-tests.c +++ b/tst/winfsp-tests/winfsp-tests.c @@ -11,6 +11,7 @@ int main(int argc, char *argv[]) TESTSUITE(timeout_tests); TESTSUITE(memfs_tests); TESTSUITE(create_tests); + TESTSUITE(getinfo_tests); tlib_run_tests(argc, argv); return 0;