2 * NTOSKRNL Io Regressions KM-Test
3 * ReactOS Kernel Mode Regression Testing framework
5 * Copyright 2006 Aleksey Bragin <aleksey@reactos.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; see the file COPYING.LIB.
19 * If not, write to the Free Software Foundation,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 /* INCLUDES *******************************************************************/
25 #include <ddk/ntddk.h>
31 /* PUBLIC FUNCTIONS ***********************************************************/
33 VOID
NtoskrnlIoMdlTest()
38 ULONG MdlSize
= 2*4096+184; // 2 pages and some random value
42 // Try to alloc 2Gb MDL
43 Mdl
= IoAllocateMdl(NULL
, 2048UL*0x100000, FALSE
, FALSE
, NULL
);
46 "IoAllocateMdl should fail allocation of 2Gb or more, but got Mdl=0x%X",
52 // Now create a valid MDL
53 VirtualAddress
= ExAllocatePool(NonPagedPool
, MdlSize
);
54 Mdl
= IoAllocateMdl(VirtualAddress
, MdlSize
, FALSE
, FALSE
, NULL
);
55 ok(Mdl
!= NULL
, "Mdl allocation failed");
56 // Check fields of the allocated struct
57 ok(Mdl
->Next
== NULL
, "Mdl->Next should be NULL, but is 0x%X",
59 ok(Mdl
->ByteCount
== MdlSize
,
60 "Mdl->ByteCount should be equal to MdlSize, but is 0x%X",
61 (UINT
)Mdl
->ByteCount
);
62 // TODO: Check other fields of MDL struct
65 // Allocate now with pointer to an Irp
66 Irp
= IoAllocateIrp(1, FALSE
);
67 ok(Irp
!= NULL
, "IRP allocation failed");
68 Mdl
= IoAllocateMdl(VirtualAddress
, MdlSize
, FALSE
, FALSE
, Irp
);
69 ok(Mdl
!= NULL
, "Mdl allocation failed");
70 ok(Irp
->MdlAddress
== Mdl
, "Irp->MdlAddress should be 0x%X, but is 0x%X",
71 (UINT
)Mdl
, (UINT
)Irp
->MdlAddress
);
75 // TODO: Check a case when SecondaryBuffer == TRUE
78 ExFreePool(VirtualAddress
);
80 FinishTest("NTOSKRNL Io Mdl");