tst: lock-test: fix mistake in calling GetOverlappedResult when prior operation has returned error

This commit is contained in:
Bill Zissimopoulos 2016-05-20 14:29:55 -07:00
parent 0dba3ffe55
commit ffded63c56
2 changed files with 12 additions and 6 deletions

View File

@ -22,5 +22,5 @@ build_script:
test_script: test_script:
- for %%f in ("build\VStudio\build\%CONFIGURATION%\winfsp-*.msi") do start /wait msiexec /i %%f /qn INSTALLLEVEL=1000 - for %%f in ("build\VStudio\build\%CONFIGURATION%\winfsp-*.msi") do start /wait msiexec /i %%f /qn INSTALLLEVEL=1000
- build\VStudio\build\%CONFIGURATION%\winfsp-tests-x64.exe -lock* - build\VStudio\build\%CONFIGURATION%\winfsp-tests-x64.exe
- build\VStudio\build\%CONFIGURATION%\winfsp-tests-x86.exe -lock* - build\VStudio\build\%CONFIGURATION%\winfsp-tests-x86.exe

View File

@ -276,14 +276,20 @@ static void lock_overlapped_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, U
Success = LockFileEx(Handle, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, Success = LockFileEx(Handle, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0,
BytesPerSector, 0, &Overlapped); BytesPerSector, 0, &Overlapped);
ASSERT(Success || ERROR_IO_PENDING == GetLastError() || ERROR_LOCK_VIOLATION == GetLastError()); ASSERT(Success || ERROR_IO_PENDING == GetLastError() || ERROR_LOCK_VIOLATION == GetLastError());
if (ERROR_LOCK_VIOLATION != GetLastError())
{
Success = GetOverlappedResult(Handle, &Overlapped, &BytesTransferred, TRUE); Success = GetOverlappedResult(Handle, &Overlapped, &BytesTransferred, TRUE);
ASSERT(!Success && ERROR_LOCK_VIOLATION == GetLastError()); ASSERT(!Success && ERROR_LOCK_VIOLATION == GetLastError());
}
Overlapped.Offset = 0; Overlapped.Offset = 0;
Success = WriteFile(Handle, Buffer[0], BytesPerSector, &BytesTransferred, &Overlapped); Success = WriteFile(Handle, Buffer[0], BytesPerSector, &BytesTransferred, &Overlapped);
ASSERT(Success || ERROR_IO_PENDING == GetLastError() || ERROR_LOCK_VIOLATION == GetLastError()); ASSERT(Success || ERROR_IO_PENDING == GetLastError() || ERROR_LOCK_VIOLATION == GetLastError());
if (ERROR_LOCK_VIOLATION != GetLastError())
{
Success = GetOverlappedResult(Handle, &Overlapped, &BytesTransferred, TRUE); Success = GetOverlappedResult(Handle, &Overlapped, &BytesTransferred, TRUE);
ASSERT(!Success && ERROR_LOCK_VIOLATION == GetLastError()); ASSERT(!Success && ERROR_LOCK_VIOLATION == GetLastError());
}
Overlapped.Offset = BytesPerSector / 2; Overlapped.Offset = BytesPerSector / 2;
Success = UnlockFileEx(Handle, 0, BytesPerSector, 0, &Overlapped); Success = UnlockFileEx(Handle, 0, BytesPerSector, 0, &Overlapped);