Author: pschweitzer
Date: Tue Aug 9 12:43:18 2016
New Revision: 72165
URL:
http://svn.reactos.org/svn/reactos?rev=72165&view=rev
Log:
[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
Modified:
trunk/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
trunk/rostests/kmtests/ntos_cc/CcCopyRead_user.c
Modified: trunk/rostests/kmtests/ntos_cc/CcCopyRead_drv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_cc/CcCopyRea…
==============================================================================
--- trunk/rostests/kmtests/ntos_cc/CcCopyRead_drv.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_cc/CcCopyRead_drv.c [iso-8859-1] Tue Aug 9 12:43:18 2016
@@ -118,17 +118,34 @@
static
PVOID
-MapUserBuffer(
- _In_ _Out_ PIRP Irp)
-{
+MapAndLockUserBuffer(
+ _In_ _Out_ PIRP Irp,
+ _In_ ULONG BufferLength)
+{
+ PMDL Mdl;
+
if (Irp->MdlAddress == NULL)
{
- return Irp->UserBuffer;
- }
- else
- {
- return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
- }
+ Mdl = IoAllocateMdl(Irp->UserBuffer, BufferLength, FALSE, FALSE, Irp);
+ if (Mdl == NULL)
+ {
+ return NULL;
+ }
+
+ _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 @@
Fcb->Header.FileSize.QuadPart = 512;
Fcb->Header.ValidDataLength.QuadPart = 512;
}
- Fcb->Header.IsFastIoPossible = FALSE;
+ Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
IoStack->FileObject->FsContext = Fcb;
IoStack->FileObject->SectionObjectPointer =
&Fcb->SectionObjectPointers;
@@ -214,7 +231,7 @@
ok(Offset.QuadPart % 512 != 0, "Offset is aligned: %I64i\n",
Offset.QuadPart);
ok(Length % 512 != 0, "Length is aligned: %I64i\n", Length);
- Buffer = MapUserBuffer(Irp);
+ Buffer = Irp->AssociatedIrp.SystemBuffer;
ok(Buffer != NULL, "Null pointer!\n");
_SEH2_TRY
@@ -230,13 +247,34 @@
_SEH2_END;
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
{
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(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;
+ if (Offset.QuadPart <= 1000LL && Offset.QuadPart + Length >
1000LL)
+ {
+ *(PUSHORT)((ULONG_PTR)Buffer + (ULONG_PTR)(1000LL - Offset.QuadPart)) =
0xFFFF;
+ }
}
if (NT_SUCCESS(Status))
Modified: trunk/rostests/kmtests/ntos_cc/CcCopyRead_user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_cc/CcCopyRea…
==============================================================================
--- trunk/rostests/kmtests/ntos_cc/CcCopyRead_user.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_cc/CcCopyRead_user.c [iso-8859-1] Tue Aug 9 12:43:18
2016
@@ -28,10 +28,19 @@
ByteOffset.QuadPart = 3;
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3,
&ByteOffset, NULL);
ok_eq_hex(Status, STATUS_SUCCESS);
+ ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
ByteOffset.QuadPart = 514;
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514,
&ByteOffset, NULL);
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);
@@ -42,14 +51,24 @@
ByteOffset.QuadPart = 3;
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 3,
&ByteOffset, NULL);
ok_eq_hex(Status, STATUS_SUCCESS);
+ ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
ByteOffset.QuadPart = 514;
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 514,
&ByteOffset, NULL);
ok_eq_hex(Status, STATUS_SUCCESS);
+ ok_eq_hex(((USHORT *)Buffer)[242], 0xBABA);
+ ok_eq_hex(((USHORT *)Buffer)[243], 0xFFFF);
ByteOffset.QuadPart = 300000;
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 10,
&ByteOffset, NULL);
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);