https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b28f538d209c09caff216a...
commit b28f538d209c09caff216a621a4c292a6933e9ad Author: Pierre Schweitzer pierre@reactos.org AuthorDate: Sat Sep 1 15:22:41 2018 +0200 Commit: Pierre Schweitzer pierre@reactos.org CommitDate: Sat Sep 1 15:22:41 2018 +0200
[KMTESTS:CC] Add tests for PIN_EXCLUSIVE --- modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c index 9b1d214d16..ecaceb38fb 100644 --- a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c @@ -190,6 +190,53 @@ PinInAnotherThread(IN PVOID Context) CcUnpinData(Bcb); }
+ KmtStartSeh(); + Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, PIN_EXCLUSIVE, &Bcb, (PVOID *)&Buffer); + KmtEndSeh(STATUS_SUCCESS); + + if (!skip(Ret == TRUE, "CcPinRead failed\n")) + { + ok_eq_pointer(Bcb, TestContext->Bcb); + ok_eq_pointer(Buffer, TestContext->Buffer); + + CcUnpinData(Bcb); + } + + return; +} + +static +VOID +NTAPI +PinInAnotherThreadExclusive(IN PVOID Context) +{ + BOOLEAN Ret; + PULONG Buffer; + PVOID Bcb; + LARGE_INTEGER Offset; + PTEST_CONTEXT TestContext; + + ok(TestFileObject != NULL, "Called in invalid context!\n"); + ok_eq_ulong(TestTestId, 3); + + TestContext = Context; + ok(TestContext != NULL, "Called in invalid context!\n"); + ok(TestContext->Bcb != NULL, "Called in invalid context!\n"); + ok(TestContext->Buffer != NULL, "Called in invalid context!\n"); + ok(TestContext->Length != 0, "Called in invalid context!\n"); + + Ret = FALSE; + Offset.QuadPart = 0x1000; + KmtStartSeh(); + Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, PIN_EXCLUSIVE, &Bcb, (PVOID *)&Buffer); + KmtEndSeh(STATUS_SUCCESS); + ok(Ret == FALSE, "CcPinRead succeed\n"); + + if (Ret) + { + CcUnpinData(Bcb); + } + return; }
@@ -299,6 +346,21 @@ PerformTest( CcUnpinData(TestContext->Bcb); }
+ KmtStartSeh(); + Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT | PIN_EXCLUSIVE, &TestContext->Bcb, &TestContext->Buffer); + KmtEndSeh(STATUS_SUCCESS); + + if (!skip(Ret == TRUE, "CcPinRead failed\n")) + { + PKTHREAD ThreadHandle; + + TestContext->Length = FileSizes.FileSize.QuadPart - Offset.QuadPart; + ThreadHandle = KmtStartThread(PinInAnotherThreadExclusive, TestContext); + KmtFinishThread(ThreadHandle, NULL); + + CcUnpinData(TestContext->Bcb); + } + ExFreePool(TestContext); } }