mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[KMTESTS:CC] Add more tests for CcPinMappedData()
This commit is contained in:
parent
a5172b4699
commit
f3ea47d94d
2 changed files with 82 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue