mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	tst: winfsp-tests: delete_standby_test
This commit is contained in:
		| @@ -605,6 +605,109 @@ void delete_mmap_test(void) | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void delete_standby_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | ||||
| { | ||||
|     void *memfs = memfs_start_ex(Flags, FileInfoTimeout); | ||||
|  | ||||
|     HANDLE Handle, Mapping0, Mapping1; | ||||
|     PUINT8 MappedView0, MappedView1; | ||||
|     BOOL Success; | ||||
|     WCHAR Dir1Path[MAX_PATH]; | ||||
|     WCHAR File0Path[MAX_PATH]; | ||||
|     WCHAR File1Path[MAX_PATH]; | ||||
|     SYSTEM_INFO SystemInfo; | ||||
|     unsigned seed = (unsigned)time(0); | ||||
|  | ||||
|     GetSystemInfo(&SystemInfo); | ||||
|  | ||||
|     StringCbPrintfW(Dir1Path, sizeof Dir1Path, L"%s%s\\dir1", | ||||
|         Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); | ||||
|  | ||||
|     StringCbPrintfW(File0Path, sizeof File0Path, L"%s%s\\dir1\\file0", | ||||
|         Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); | ||||
|  | ||||
|     StringCbPrintfW(File1Path, sizeof File1Path, L"%s%s\\dir1\\file1", | ||||
|         Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); | ||||
|  | ||||
|     Success = CreateDirectoryW(Dir1Path, 0); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     srand(seed); | ||||
|  | ||||
|     Handle = CreateFileW(File0Path, | ||||
|         GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, | ||||
|         CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); | ||||
|     ASSERT(INVALID_HANDLE_VALUE != Handle); | ||||
|     Mapping0 = CreateFileMappingW(Handle, 0, PAGE_READWRITE, | ||||
|         0, 16 * SystemInfo.dwAllocationGranularity, 0); | ||||
|     ASSERT(0 != Mapping0); | ||||
|     Success = CloseHandle(Handle); | ||||
|     ASSERT(Success); | ||||
|     MappedView0 = MapViewOfFile(Mapping0, FILE_MAP_ALL_ACCESS, 0, 0, 0); | ||||
|     ASSERT(0 != MappedView0); | ||||
|     for (PUINT8 P = MappedView0, EndP = P + 16 * SystemInfo.dwAllocationGranularity; EndP > P; P++) | ||||
|         *P = rand() & 0xff; | ||||
|     Success = UnmapViewOfFile(MappedView0); | ||||
|     ASSERT(Success); | ||||
|     Success = CloseHandle(Mapping0); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     Handle = CreateFileW(File1Path, | ||||
|         GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, | ||||
|         CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); | ||||
|     ASSERT(INVALID_HANDLE_VALUE != Handle); | ||||
|     Mapping1 = CreateFileMappingW(Handle, 0, PAGE_READWRITE, | ||||
|         0, 16 * SystemInfo.dwAllocationGranularity, 0); | ||||
|     ASSERT(0 != Mapping1); | ||||
|     Success = CloseHandle(Handle); | ||||
|     ASSERT(Success); | ||||
|     MappedView1 = MapViewOfFile(Mapping1, FILE_MAP_ALL_ACCESS, 0, 0, 0); | ||||
|     ASSERT(0 != MappedView1); | ||||
|     for (PUINT8 P = MappedView1, EndP = P + 16 * SystemInfo.dwAllocationGranularity; EndP > P; P++) | ||||
|         *P = rand() & 0xff; | ||||
|     Success = UnmapViewOfFile(MappedView1); | ||||
|     ASSERT(Success); | ||||
|     Success = CloseHandle(Mapping1); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     Success = DeleteFileW(File0Path); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     Success = DeleteFileW(File1Path); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     Success = RemoveDirectoryW(Dir1Path); | ||||
|     ASSERT(Success); | ||||
|  | ||||
|     Success = RemoveDirectoryW(Dir1Path); | ||||
|     ASSERT(!Success); | ||||
|     ASSERT(ERROR_FILE_NOT_FOUND == GetLastError()); | ||||
|  | ||||
|     memfs_stop(memfs); | ||||
| } | ||||
|  | ||||
| void delete_standby_test(void) | ||||
| { | ||||
|     if (NtfsTests) | ||||
|     { | ||||
|         WCHAR DirBuf[MAX_PATH]; | ||||
|         GetTestDirectory(DirBuf); | ||||
|         delete_standby_dotest(-1, DirBuf, 0); | ||||
|     } | ||||
|     if (WinFspDiskTests) | ||||
|     { | ||||
|         delete_standby_dotest(MemfsDisk, 0, 0); | ||||
|         delete_standby_dotest(MemfsDisk, 0, 1000); | ||||
|         delete_standby_dotest(MemfsDisk, 0, INFINITE); | ||||
|     } | ||||
|     if (WinFspNetTests) | ||||
|     { | ||||
|         delete_standby_dotest(MemfsNet, L"\\\\memfs\\share", 0); | ||||
|         delete_standby_dotest(MemfsNet, L"\\\\memfs\\share", 1000); | ||||
|         delete_standby_dotest(MemfsDisk, 0, INFINITE); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void rename_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | ||||
| { | ||||
|     void *memfs = memfs_start_ex(Flags, FileInfoTimeout); | ||||
| @@ -1576,6 +1679,7 @@ void info_tests(void) | ||||
|     TEST(delete_pending_test); | ||||
|     if (!OptShareName) | ||||
|         TEST(delete_mmap_test); | ||||
|     TEST(delete_standby_test); | ||||
|     TEST(rename_test); | ||||
|     TEST(rename_open_test); | ||||
|     TEST(rename_caseins_test); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user