https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f3ea47d94da0f1c2a1559…
commit f3ea47d94da0f1c2a1559a0facb61e9726907bab
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Oct 13 19:24:07 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Oct 13 19:24:29 2018 +0200
[KMTESTS:CC] Add more tests for CcPinMappedData()
---
.../rostests/kmtests/ntos_cc/CcPinMappedData_drv.c | 81 ++++++++++++++++++++++
.../kmtests/ntos_cc/CcPinMappedData_user.c | 2 +-
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c
b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c
index 1a41bf144f..79bbf8168d 100644
--- a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c
@@ -144,6 +144,57 @@ MapAndLockUserBuffer(
return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
}
+static
+VOID
+NTAPI
+PinInAnotherThread(IN PVOID Context)
+{
+ BOOLEAN Ret;
+ PULONG Buffer;
+ PVOID Bcb, PinBcb;
+ LARGE_INTEGER Offset;
+ PTEST_CONTEXT TestContext;
+
+ ok(TestFileObject != NULL, "Called in invalid context!\n");
+ ok_eq_ulong(TestTestId, 4);
+
+ 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 = 0;
+
+ KmtStartSeh();
+ Ret = CcMapData(TestFileObject, &Offset, TestContext->Length, MAP_WAIT,
&Bcb, (PVOID *)&Buffer);
+ KmtEndSeh(STATUS_SUCCESS);
+
+ if (!skip(Ret == TRUE, "CcMapData failed\n"))
+ {
+ ok(Bcb != TestContext->Bcb, "Returned same BCB!\n");
+ ok_eq_pointer(Buffer, TestContext->Buffer);
+
+ Ret = FALSE;
+ PinBcb = Bcb;
+
+ KmtStartSeh();
+ Ret = CcPinMappedData(TestFileObject, &Offset, FileSizes.FileSize.QuadPart -
Offset.QuadPart, 0, &PinBcb);
+ KmtEndSeh(STATUS_SUCCESS);
+
+ if (!skip(Ret == TRUE, "CcPinMappedData failed\n"))
+ {
+ ok(Bcb != PinBcb, "Returned same BCB!\n");
+ ok_eq_pointer(PinBcb, TestContext->Bcb);
+
+ Bcb = PinBcb;
+ }
+
+ CcUnpinData(Bcb);
+ }
+}
+
static
VOID
NTAPI
@@ -383,6 +434,36 @@ PerformTest(
CcUnpinData(Bcb);
}
}
+ else if (TestId == 4)
+ {
+ PTEST_CONTEXT TestContext;
+
+ TestContext = ExAllocatePool(NonPagedPool, sizeof(TEST_CONTEXT));
+ if (!skip(TestContext != NULL, "ExAllocatePool failed\n"))
+ {
+ Ret = FALSE;
+ Offset.QuadPart = 0;
+ KmtStartSeh();
+ Ret = CcPinRead(TestFileObject, &Offset,
FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &TestContext->Bcb, (PVOID
*)&TestContext->Buffer);
+ KmtEndSeh(STATUS_SUCCESS);
+
+ if (!skip(Ret == TRUE, "CcPinRead failed\n"))
+ {
+ PKTHREAD ThreadHandle;
+
+ ok(*(PUSHORT)TestContext->Bcb == 0x2FD, "Not a BCB:
%x\n", *(PUSHORT)TestContext->Bcb);
+ ok_eq_ulong(TestContext->Buffer[0x3000 / sizeof(ULONG)],
0xDEADBABE);
+
+ TestContext->Length = FileSizes.FileSize.QuadPart -
Offset.QuadPart;
+ ThreadHandle = KmtStartThread(PinInAnotherThread,
TestContext);
+ KmtFinishThread(ThreadHandle, NULL);
+
+ CcUnpinData(TestContext->Bcb);
+ }
+
+ ExFreePool(TestContext);
+ }
+ }
}
}
}
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c
b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c
index 21fe904bb9..e0fdcfda15 100644
--- a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c
+++ b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c
@@ -19,7 +19,7 @@ START_TEST(CcPinMappedData)
KmtOpenDriver();
/* 1 basic test */
- for (TestId = 0; TestId < 4; ++TestId)
+ for (TestId = 0; TestId < 5; ++TestId)
{
Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);