From 39635013ab770c24584a3d8fbea9ad19d2fa182b Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 4 Jun 2006 18:27:48 +0000 Subject: [PATCH] Add a little more tests for Mdl testing, only 1 failes in ReactOS currently svn path=/trunk/; revision=22217 --- reactos/drivers/test/kmtest/ntos_io.c | 38 +++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/test/kmtest/ntos_io.c b/reactos/drivers/test/kmtest/ntos_io.c index e9c12aebe69..6e0abfce9a2 100644 --- a/reactos/drivers/test/kmtest/ntos_io.c +++ b/reactos/drivers/test/kmtest/ntos_io.c @@ -1,6 +1,6 @@ /* * NTOSKRNL Io Regressions KM-Test - * ReactOS Device Interface functions implementation + * ReactOS Kernel Mode Regression Testing framework * * Copyright 2006 Aleksey Bragin * @@ -30,15 +30,49 @@ VOID FASTCALL NtoskrnlIoMdlTest() { PMDL Mdl; + PIRP Irp; + PVOID VirtualAddress; + ULONG MdlSize = 2*4096+184; // 2 pages and some random value StartTest(); // Try to alloc 2Gb MDL Mdl = IoAllocateMdl(NULL, 2048UL*0x100000, FALSE, FALSE, NULL); - ok(Mdl == NULL, "IoAllocateMdl should fail allocation of 2Gb or more, but got Mdl=0x%X", (UINT)Mdl); + ok(Mdl == NULL, + "IoAllocateMdl should fail allocation of 2Gb or more, but got Mdl=0x%X", + (UINT)Mdl); + if (Mdl) IoFreeMdl(Mdl); + // Now create a valid MDL + VirtualAddress = ExAllocatePool(NonPagedPool, MdlSize); + Mdl = IoAllocateMdl(VirtualAddress, MdlSize, FALSE, FALSE, NULL); + ok(Mdl != NULL, "Mdl allocation failed"); + // Check fields of the allocated struct + ok(Mdl->Next == NULL, "Mdl->Next should be NULL, but is 0x%X", + (UINT)Mdl->Next); + ok(Mdl->ByteCount == MdlSize, + "Mdl->ByteCount should be equal to MdlSize, but is 0x%X", + (UINT)Mdl->ByteCount); + // TODO: Check other fields of MDL struct + + IoFreeMdl(Mdl); + // Allocate now with pointer to an Irp + Irp = IoAllocateIrp(1, FALSE); + ok(Irp != NULL, "IRP allocation failed"); + Mdl = IoAllocateMdl(VirtualAddress, MdlSize, FALSE, FALSE, Irp); + ok(Mdl != NULL, "Mdl allocation failed"); + ok(Irp->MdlAddress == Mdl, "Irp->MdlAddress should be 0x%X, but is 0x%X", + (UINT)Mdl, (UINT)Irp->MdlAddress); + + IoFreeMdl(Mdl); + + // TODO: Check a case when SecondaryBuffer == TRUE + + IoFreeIrp(Irp); + ExFreePool(VirtualAddress); + FinishTest("NTOSKRNL Io Mdl"); }