mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
[KMTESTS:CC]
Complete the tests for Cc: not only check for alignment, but also check that expected data are returned. Thanks to Thomas for his help on this :-). CORE-11003 svn path=/trunk/; revision=72165
This commit is contained in:
parent
7849fac958
commit
22f90f2210
2 changed files with 66 additions and 9 deletions
|
@ -118,17 +118,34 @@ static CACHE_MANAGER_CALLBACKS Callbacks = {
|
||||||
|
|
||||||
static
|
static
|
||||||
PVOID
|
PVOID
|
||||||
MapUserBuffer(
|
MapAndLockUserBuffer(
|
||||||
_In_ _Out_ PIRP Irp)
|
_In_ _Out_ PIRP Irp,
|
||||||
|
_In_ ULONG BufferLength)
|
||||||
{
|
{
|
||||||
|
PMDL Mdl;
|
||||||
|
|
||||||
if (Irp->MdlAddress == NULL)
|
if (Irp->MdlAddress == NULL)
|
||||||
{
|
{
|
||||||
return Irp->UserBuffer;
|
Mdl = IoAllocateMdl(Irp->UserBuffer, BufferLength, FALSE, FALSE, Irp);
|
||||||
}
|
if (Mdl == NULL)
|
||||||
else
|
{
|
||||||
{
|
return NULL;
|
||||||
return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
|
}
|
||||||
|
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoWriteAccess);
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
IoFreeMdl(Mdl);
|
||||||
|
Irp->MdlAddress = NULL;
|
||||||
|
_SEH2_YIELD(return NULL);
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +201,7 @@ TestIrpHandler(
|
||||||
Fcb->Header.FileSize.QuadPart = 512;
|
Fcb->Header.FileSize.QuadPart = 512;
|
||||||
Fcb->Header.ValidDataLength.QuadPart = 512;
|
Fcb->Header.ValidDataLength.QuadPart = 512;
|
||||||
}
|
}
|
||||||
Fcb->Header.IsFastIoPossible = FALSE;
|
Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
|
||||||
IoStack->FileObject->FsContext = Fcb;
|
IoStack->FileObject->FsContext = Fcb;
|
||||||
IoStack->FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
IoStack->FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
|
||||||
|
|
||||||
|
@ -214,7 +231,7 @@ TestIrpHandler(
|
||||||
ok(Offset.QuadPart % 512 != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
|
ok(Offset.QuadPart % 512 != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
|
||||||
ok(Length % 512 != 0, "Length is aligned: %I64i\n", Length);
|
ok(Length % 512 != 0, "Length is aligned: %I64i\n", Length);
|
||||||
|
|
||||||
Buffer = MapUserBuffer(Irp);
|
Buffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
ok(Buffer != NULL, "Null pointer!\n");
|
ok(Buffer != NULL, "Null pointer!\n");
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
|
@ -230,13 +247,34 @@ TestIrpHandler(
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
if (Offset.QuadPart <= 1000LL && Offset.QuadPart + Length > 1000LL)
|
||||||
|
{
|
||||||
|
ok_eq_hex(*(PUSHORT)((ULONG_PTR)Buffer + (ULONG_PTR)(1000LL - Offset.QuadPart)), 0xFFFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok_eq_hex(*(PUSHORT)Buffer, 0xBABA);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ok(Offset.QuadPart % 512 == 0, "Offset is not aligned: %I64i\n", Offset.QuadPart);
|
ok(Offset.QuadPart % 512 == 0, "Offset is not aligned: %I64i\n", Offset.QuadPart);
|
||||||
ok(Length % 512 == 0, "Length is not aligned: %I64i\n", Length);
|
ok(Length % 512 == 0, "Length is not aligned: %I64i\n", Length);
|
||||||
|
|
||||||
|
ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
|
||||||
|
Buffer = MapAndLockUserBuffer(Irp, Length);
|
||||||
|
ok(Buffer != NULL, "Null pointer!\n");
|
||||||
|
RtlFillMemory(Buffer, Length, 0xBA);
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
if (Offset.QuadPart <= 1000LL && Offset.QuadPart + Length > 1000LL)
|
||||||
|
{
|
||||||
|
*(PUSHORT)((ULONG_PTR)Buffer + (ULONG_PTR)(1000LL - Offset.QuadPart)) = 0xFFFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
|
|
@ -28,10 +28,19 @@ START_TEST(CcCopyRead)
|
||||||
ByteOffset.QuadPart = 3;
|
ByteOffset.QuadPart = 3;
|
||||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3, &ByteOffset, NULL);
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
|
||||||
|
|
||||||
ByteOffset.QuadPart = 514;
|
ByteOffset.QuadPart = 514;
|
||||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514, &ByteOffset, NULL);
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[242], 0xBABA);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[243], 0xFFFF);
|
||||||
|
|
||||||
|
ByteOffset.QuadPart = 1000;
|
||||||
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 2, &ByteOffset, NULL);
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[0], 0xFFFF);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[1], 0xBABA);
|
||||||
|
|
||||||
NtClose(Handle);
|
NtClose(Handle);
|
||||||
|
|
||||||
|
@ -42,14 +51,24 @@ START_TEST(CcCopyRead)
|
||||||
ByteOffset.QuadPart = 3;
|
ByteOffset.QuadPart = 3;
|
||||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3, &ByteOffset, NULL);
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
|
||||||
|
|
||||||
ByteOffset.QuadPart = 514;
|
ByteOffset.QuadPart = 514;
|
||||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514, &ByteOffset, NULL);
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[242], 0xBABA);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[243], 0xFFFF);
|
||||||
|
|
||||||
ByteOffset.QuadPart = 300000;
|
ByteOffset.QuadPart = 300000;
|
||||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 10, &ByteOffset, NULL);
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 10, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
|
||||||
|
|
||||||
|
ByteOffset.QuadPart = 1000;
|
||||||
|
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 2, &ByteOffset, NULL);
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[0], 0xFFFF);
|
||||||
|
ok_eq_hex(((USHORT *)Buffer)[1], 0xBABA);
|
||||||
|
|
||||||
NtClose(Handle);
|
NtClose(Handle);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue