mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
tst: winfsp-tests: --resilient command line option
This commit is contained in:
parent
66d5fe98df
commit
319e5d4ee6
@ -1260,7 +1260,7 @@ static void stream_delete_pending_dotest(ULONG Flags, PWSTR Prefix, ULONG FileIn
|
||||
BOOL Success;
|
||||
WCHAR Dir1Path[MAX_PATH], Dir1StreamPath[MAX_PATH];
|
||||
WCHAR FilePath[MAX_PATH], FileStreamPath[MAX_PATH];
|
||||
FILE_DISPOSITION_INFO DispositionInfo;
|
||||
MY_FILE_DISPOSITION_INFO DispositionInfo;
|
||||
|
||||
StringCbPrintfW(Dir1Path, sizeof Dir1Path, L"%s%s\\dir1",
|
||||
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
|
||||
@ -1304,7 +1304,7 @@ static void stream_delete_pending_dotest(ULONG Flags, PWSTR Prefix, ULONG FileIn
|
||||
DELETE, FILE_SHARE_DELETE, 0,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
ASSERT(INVALID_HANDLE_VALUE != Handle);
|
||||
DispositionInfo.DeleteFile = TRUE;
|
||||
DispositionInfo.Disposition = TRUE;
|
||||
Success = SetFileInformationByHandle(Handle,
|
||||
FileDispositionInfo, &DispositionInfo, sizeof DispositionInfo);
|
||||
ASSERT(Success);
|
||||
@ -1327,7 +1327,7 @@ static void stream_delete_pending_dotest(ULONG Flags, PWSTR Prefix, ULONG FileIn
|
||||
DELETE, FILE_SHARE_DELETE, 0,
|
||||
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
ASSERT(INVALID_HANDLE_VALUE != Handle);
|
||||
DispositionInfo.DeleteFile = TRUE;
|
||||
DispositionInfo.Disposition = TRUE;
|
||||
Success = SetFileInformationByHandle(Handle,
|
||||
FileDispositionInfo, &DispositionInfo, sizeof DispositionInfo);
|
||||
ASSERT(Success);
|
||||
|
@ -17,6 +17,7 @@ int NtfsTests = 0;
|
||||
int WinFspDiskTests = 1;
|
||||
int WinFspNetTests = 1;
|
||||
|
||||
BOOLEAN OptResilient = FALSE;
|
||||
BOOLEAN OptCaseInsensitive = FALSE;
|
||||
BOOLEAN OptCaseRandomize = FALSE;
|
||||
WCHAR OptMountPointBuf[MAX_PATH], *OptMountPoint;
|
||||
@ -201,6 +202,37 @@ HANDLE HookCreateFileW(
|
||||
return h;
|
||||
}
|
||||
|
||||
#undef DeleteFileW
|
||||
BOOL HookDeleteFileW(
|
||||
LPCWSTR lpFileName)
|
||||
{
|
||||
BOOL Success;
|
||||
DWORD LastError;
|
||||
|
||||
Success = DeleteFileW(lpFileName);
|
||||
LastError = GetLastError();
|
||||
if (OptResilient && !Success)
|
||||
{
|
||||
ULONG MaxTries = 10;
|
||||
while (!Success && ERROR_SHARING_VIOLATION == LastError && 0 != MaxTries--)
|
||||
{
|
||||
Sleep(300);
|
||||
Success = DeleteFileW(lpFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG MaxTries = 3;
|
||||
while (INVALID_FILE_ATTRIBUTES != GetFileAttributes(lpFileName) && 0 != MaxTries--)
|
||||
{
|
||||
Sleep(300);
|
||||
}
|
||||
}
|
||||
|
||||
SetLastError(LastError);
|
||||
return Success;
|
||||
}
|
||||
|
||||
static VOID DisableBackupRestorePrivileges(VOID)
|
||||
{
|
||||
union
|
||||
@ -227,7 +259,7 @@ static VOID DisableBackupRestorePrivileges(VOID)
|
||||
CloseHandle(Token);
|
||||
}
|
||||
|
||||
VOID AddNetShareIfNeeded(VOID)
|
||||
static VOID AddNetShareIfNeeded(VOID)
|
||||
{
|
||||
if (!OptShareName)
|
||||
return;
|
||||
@ -247,7 +279,7 @@ VOID AddNetShareIfNeeded(VOID)
|
||||
ABORT("cannot add network share");
|
||||
}
|
||||
|
||||
VOID RemoveNetShareIfNeeded(VOID)
|
||||
static VOID RemoveNetShareIfNeeded(VOID)
|
||||
{
|
||||
if (!OptShareName)
|
||||
return;
|
||||
@ -308,6 +340,11 @@ int main(int argc, char *argv[])
|
||||
WinFspNetTests = 0;
|
||||
rmarg(argv, argc, argi);
|
||||
}
|
||||
else if (0 == strcmp("--resilient", a))
|
||||
{
|
||||
OptResilient = TRUE;
|
||||
rmarg(argv, argc, argi);
|
||||
}
|
||||
else if (0 == strcmp("--case-insensitive", a))
|
||||
{
|
||||
OptCaseInsensitive = TRUE;
|
||||
|
@ -17,13 +17,20 @@ HANDLE HookCreateFileW(
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile);
|
||||
|
||||
VOID AddNetShareIfNeeded(VOID);
|
||||
VOID RemoveNetShareIfNeeded(VOID);
|
||||
#define DeleteFileW HookDeleteFileW
|
||||
BOOL HookDeleteFileW(
|
||||
LPCWSTR lpFileName);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN Disposition;
|
||||
} MY_FILE_DISPOSITION_INFO;
|
||||
|
||||
extern int NtfsTests;
|
||||
extern int WinFspDiskTests;
|
||||
extern int WinFspNetTests;
|
||||
|
||||
extern BOOLEAN OptResilient;
|
||||
extern BOOLEAN OptCaseInsensitive;
|
||||
extern BOOLEAN OptCaseRandomize;
|
||||
extern WCHAR OptMountPointBuf[], *OptMountPoint;
|
||||
|
Loading…
x
Reference in New Issue
Block a user