mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 21:05:43 +00:00
[KMTESTS:CC] Add some tests regarding small pinning size (< PAGE_SIZE)
CORE-15384
This commit is contained in:
parent
932a812c66
commit
7375173b7f
2 changed files with 84 additions and 3 deletions
|
@ -32,6 +32,7 @@ static PFILE_OBJECT TestFileObject;
|
||||||
static PDEVICE_OBJECT TestDeviceObject;
|
static PDEVICE_OBJECT TestDeviceObject;
|
||||||
static KMT_IRP_HANDLER TestIrpHandler;
|
static KMT_IRP_HANDLER TestIrpHandler;
|
||||||
static KMT_MESSAGE_HANDLER TestMessageHandler;
|
static KMT_MESSAGE_HANDLER TestMessageHandler;
|
||||||
|
static BOOLEAN TestWriteCalled = FALSE;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
TestEntry(
|
TestEntry(
|
||||||
|
@ -52,6 +53,7 @@ TestEntry(
|
||||||
TESTENTRY_NO_READONLY_DEVICE;
|
TESTENTRY_NO_READONLY_DEVICE;
|
||||||
|
|
||||||
KmtRegisterIrpHandler(IRP_MJ_READ, NULL, TestIrpHandler);
|
KmtRegisterIrpHandler(IRP_MJ_READ, NULL, TestIrpHandler);
|
||||||
|
KmtRegisterIrpHandler(IRP_MJ_WRITE, NULL, TestIrpHandler);
|
||||||
KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
|
KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +114,12 @@ static CC_FILE_SIZES FileSizes = {
|
||||||
RTL_CONSTANT_LARGE_INTEGER((LONGLONG)0x4000) // .ValidDataLength
|
RTL_CONSTANT_LARGE_INTEGER((LONGLONG)0x4000) // .ValidDataLength
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static CC_FILE_SIZES SmallFileSizes = {
|
||||||
|
RTL_CONSTANT_LARGE_INTEGER((LONGLONG)512), // .AllocationSize
|
||||||
|
RTL_CONSTANT_LARGE_INTEGER((LONGLONG)496), // .FileSize
|
||||||
|
RTL_CONSTANT_LARGE_INTEGER((LONGLONG)496) // .ValidDataLength
|
||||||
|
};
|
||||||
|
|
||||||
static
|
static
|
||||||
PVOID
|
PVOID
|
||||||
MapAndLockUserBuffer(
|
MapAndLockUserBuffer(
|
||||||
|
@ -387,7 +395,14 @@ PerformTest(
|
||||||
TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
||||||
|
|
||||||
KmtStartSeh();
|
KmtStartSeh();
|
||||||
CcInitializeCacheMap(TestFileObject, &FileSizes, PinAccess, &Callbacks, NULL);
|
if (TestId < 6)
|
||||||
|
{
|
||||||
|
CcInitializeCacheMap(TestFileObject, &FileSizes, PinAccess, &Callbacks, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CcInitializeCacheMap(TestFileObject, &SmallFileSizes, PinAccess, &Callbacks, NULL);
|
||||||
|
}
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
|
||||||
if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap failed\n"))
|
if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap failed\n"))
|
||||||
|
@ -541,6 +556,24 @@ PerformTest(
|
||||||
CcUnpinData(Bcb);
|
CcUnpinData(Bcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (TestId == 6)
|
||||||
|
{
|
||||||
|
Ret = FALSE;
|
||||||
|
Offset.QuadPart = 0;
|
||||||
|
|
||||||
|
KmtStartSeh();
|
||||||
|
Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart, PIN_WAIT, &Bcb, (PVOID *)&Buffer);
|
||||||
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
|
||||||
|
if (!skip(Ret == TRUE, "CcPinRead failed\n"))
|
||||||
|
{
|
||||||
|
ok_bcb(Bcb, PAGE_SIZE * 4, Offset.QuadPart);
|
||||||
|
RtlFillMemory(Buffer, 0xbd, FileSizes.FileSize.LowPart);
|
||||||
|
CcSetDirtyPinnedData(Bcb, NULL);
|
||||||
|
|
||||||
|
CcUnpinData(Bcb);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,12 +608,22 @@ CleanupTest(
|
||||||
TestFileObject->SectionObjectPointer = NULL;
|
TestFileObject->SectionObjectPointer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TestTestId == 6)
|
||||||
|
{
|
||||||
|
ok_bool_true(TestWriteCalled, "Write was not called!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok_bool_false(TestWriteCalled, "Write was unexpectedly called\n");
|
||||||
|
}
|
||||||
|
|
||||||
ObDereferenceObject(TestFileObject);
|
ObDereferenceObject(TestFileObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestFileObject = NULL;
|
TestFileObject = NULL;
|
||||||
TestDeviceObject = NULL;
|
TestDeviceObject = NULL;
|
||||||
TestTestId = -1;
|
TestTestId = -1;
|
||||||
|
TestWriteCalled = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -631,7 +674,8 @@ TestIrpHandler(
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
|
DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
|
||||||
ASSERT(IoStack->MajorFunction == IRP_MJ_READ);
|
ASSERT(IoStack->MajorFunction == IRP_MJ_READ ||
|
||||||
|
IoStack->MajorFunction == IRP_MJ_WRITE);
|
||||||
|
|
||||||
FsRtlEnterFileSystem();
|
FsRtlEnterFileSystem();
|
||||||
|
|
||||||
|
@ -677,6 +721,42 @@ TestIrpHandler(
|
||||||
|
|
||||||
Irp->IoStatus.Information = Length;
|
Irp->IoStatus.Information = Length;
|
||||||
}
|
}
|
||||||
|
else if (IoStack->MajorFunction == IRP_MJ_WRITE)
|
||||||
|
{
|
||||||
|
PMDL Mdl;
|
||||||
|
ULONG Length;
|
||||||
|
PVOID Buffer;
|
||||||
|
LARGE_INTEGER Offset;
|
||||||
|
|
||||||
|
Offset = IoStack->Parameters.Write.ByteOffset;
|
||||||
|
Length = IoStack->Parameters.Write.Length;
|
||||||
|
|
||||||
|
ok(TestTestId == 6, "Unexpected test id: %d\n", TestTestId);
|
||||||
|
ok_eq_pointer(DeviceObject, TestDeviceObject);
|
||||||
|
ok_eq_pointer(IoStack->FileObject, TestFileObject);
|
||||||
|
|
||||||
|
ok(FlagOn(Irp->Flags, IRP_NOCACHE), "Not coming from Cc\n");
|
||||||
|
|
||||||
|
ok_irql(PASSIVE_LEVEL);
|
||||||
|
ok(Offset.QuadPart == 0, "Offset is not null: %I64i\n", Offset.QuadPart);
|
||||||
|
ok(Length % PAGE_SIZE == 0, "Length is not aligned: %I64i\n", Length);
|
||||||
|
ok(Length == PAGE_SIZE * 4, "Length is not MappedLength-sized: %I64i\n", Length);
|
||||||
|
|
||||||
|
Buffer = MapAndLockUserBuffer(Irp, Length);
|
||||||
|
ok(Buffer != NULL, "Null pointer!\n");
|
||||||
|
|
||||||
|
Mdl = Irp->MdlAddress;
|
||||||
|
ok(Mdl != NULL, "Null pointer for MDL!\n");
|
||||||
|
ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) != 0, "MDL not locked\n");
|
||||||
|
ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
|
||||||
|
ok((Irp->Flags & IRP_PAGING_IO) != 0, "Non paging IO\n");
|
||||||
|
|
||||||
|
ok_bool_false(TestWriteCalled, "Write has been unexpectedly called twice!\n");
|
||||||
|
TestWriteCalled = TRUE;
|
||||||
|
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Information = Length;
|
||||||
|
}
|
||||||
|
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,8 +22,9 @@ START_TEST(CcPinRead)
|
||||||
* 1 test for BCB
|
* 1 test for BCB
|
||||||
* 1 test for pinning access
|
* 1 test for pinning access
|
||||||
* 1 test for length/offset
|
* 1 test for length/offset
|
||||||
|
* 1 test for read/write size
|
||||||
*/
|
*/
|
||||||
for (TestId = 0; TestId < 6; ++TestId)
|
for (TestId = 0; TestId < 7; ++TestId)
|
||||||
{
|
{
|
||||||
Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
|
Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
|
||||||
ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);
|
ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue