[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 /* PRIVATE FUNCTIONS ***********************************************************/
34
35 VOID
36 NTAPI
37 KeStallTest()
38 {
39 ULONG i;
40 LARGE_INTEGER TimeStart, TimeFinish;
41
42 StartTest();
43
44 DPRINT1("Waiting for 30 secs with 50us stalls...\n");
45 KeQuerySystemTime(&TimeStart);
46 for (i = 0; i < (30*1000*20); i++)
47 {
48 KeStallExecutionProcessor(50);
49 }
50 KeQuerySystemTime(&TimeFinish);
51 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
52
53 DPRINT1("Waiting for 30 secs with 1000us stalls...\n");
54 KeQuerySystemTime(&TimeStart);
55 for (i = 0; i < (30*1000); i++)
56 {
57 KeStallExecutionProcessor(1000);
58 }
59 KeQuerySystemTime(&TimeFinish);
60 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
61
62 DPRINT1("Waiting for 30 secs with 1us stalls...\n");
63 KeQuerySystemTime(&TimeStart);
64 for (i = 0; i < (30*1000*1000); i++)
65 {
66 KeStallExecutionProcessor(1);
67 }
68 KeQuerySystemTime(&TimeFinish);
69 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 43
70
71 DPRINT1("Waiting for 30 secs with one huge stall...\n");
72 KeQuerySystemTime(&TimeStart);
73 KeStallExecutionProcessor(30*1000000);
74 KeQuerySystemTime(&TimeFinish);
75 DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
76
77 FinishTest("NTOSKRNL KeStallmanExecution test");
78 }
79
80 /* PUBLIC FUNCTIONS ***********************************************************/
81
82 VOID
83 NtoskrnlKeTests()
84 {
85 KeStallTest();
86 }