2 * NTOSKRNL Pools test routines KM-Test
3 * ReactOS Kernel Mode Regression Testing framework
5 * Copyright 2008 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>
27 #include <ndk/ntndk.h>
33 #define TAG_POOLTEST TAG('P','t','s','t')
35 /* PRIVATE FUNCTIONS ***********************************************************/
41 ULONG AllocSize
, i
, AllocNumber
;
46 // Stress-test nonpaged pool
47 for (i
=1; i
<10000; i
++)
49 // make up some increasing, a bit irregular size
58 // start with non-paged pool
59 Ptr
= ExAllocatePoolWithTag(NonPagedPool
, AllocSize
, TAG_POOLTEST
);
61 // it may fail due to no-memory condition
64 // try to fully fill it
65 RtlFillMemory(Ptr
, AllocSize
, 0xAB);
68 ExFreePoolWithTag(Ptr
, TAG_POOLTEST
);
72 for (i
=1; i
<10000; i
++)
74 // make up some increasing, a bit irregular size
83 // start with non-paged pool
84 Ptr
= ExAllocatePoolWithTag(PagedPool
, AllocSize
, TAG_POOLTEST
);
86 // it may fail due to no-memory condition
89 // try to fully fill it
90 RtlFillMemory(Ptr
, AllocSize
, 0xAB);
93 ExFreePoolWithTag(Ptr
, TAG_POOLTEST
);
96 // test super-big allocations
97 /*AllocSize = 2UL * 1024 * 1024 * 1024;
98 Ptr = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
99 ok(Ptr == NULL, "Allocating 2Gb of nonpaged pool should fail\n");
101 Ptr = ExAllocatePoolWithTag(PagedPool, AllocSize, TAG_POOLTEST);
102 ok(Ptr == NULL, "Allocating 2Gb of paged pool should fail\n");*/
104 // now test allocating lots of small/medium blocks
105 AllocNumber
= 100000;
106 Allocs
= ExAllocatePoolWithTag(PagedPool
, sizeof(Allocs
) * AllocNumber
, TAG_POOLTEST
);
109 for (i
=0; i
<AllocNumber
; i
++)
112 Allocs
[i
] = ExAllocatePoolWithTag(NonPagedPool
, AllocSize
, TAG_POOLTEST
);
116 for (i
=0; i
<AllocNumber
; i
++)
118 ExFreePoolWithTag(Allocs
[i
], TAG_POOLTEST
);
122 ExFreePoolWithTag(Allocs
, TAG_POOLTEST
);
125 FinishTest("NTOSKRNL Pools Tests");
128 /* PUBLIC FUNCTIONS ***********************************************************/