[KMTEST]
[reactos.git] / rostests / drivers / kmtest / ntos_ke.c
1 /*
2 * NTOSKRNL Executive Regressions KM-Test
3 * ReactOS Kernel Mode Regression Testing framework
4 *
5 * Copyright 2006 Aleksey Bragin <aleksey@reactos.org>
6 *
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.
11 *
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.
16 *
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.
21 */
22
23 /* INCLUDES *******************************************************************/
24
25 #include <ddk/ntddk.h>
26 #include <ntifs.h>
27 #include <ndk/ntndk.h>
28 #include "kmtest.h"
29
30 #define NDEBUG
31 #include "debug.h"
32
33 /* PUBLIC FUNCTIONS ***********************************************************/
34
35 VOID
36 KeStallTest(HANDLE KeyHandle)
37 {
38 ULONG i;
39 LARGE_INTEGER TimeStart, TimeFinish;
40
41 StartTest();
42
43 DPRINT1("Waiting for 30 secs with 50us stalls...\n");
44 KeQuerySystemTime(&TimeStart);
45 for (i = 0; i < (30*1000*20); i++)
46 {
47 KeStallExecutionProcessor(50);
48 }
49 KeQuerySystemTime(&TimeFinish);
50 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
51
52 DPRINT1("Waiting for 30 secs with 1000us stalls...\n");
53 KeQuerySystemTime(&TimeStart);
54 for (i = 0; i < (30*1000); i++)
55 {
56 KeStallExecutionProcessor(1000);
57 }
58 KeQuerySystemTime(&TimeFinish);
59 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
60
61 DPRINT1("Waiting for 30 secs with 1us stalls...\n");
62 KeQuerySystemTime(&TimeStart);
63 for (i = 0; i < (30*1000*1000); i++)
64 {
65 KeStallExecutionProcessor(1);
66 }
67 KeQuerySystemTime(&TimeFinish);
68 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 43
69
70 DPRINT1("Waiting for 30 secs with one huge stall...\n");
71 KeQuerySystemTime(&TimeStart);
72 KeStallExecutionProcessor(30*1000000);
73 KeQuerySystemTime(&TimeFinish);
74 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
75
76 FinishTest(KeyHandle, L"KeStallmanExecutionTest");
77 }