- By default enable all tests. 0 failures in Windows XP SP3.
[reactos.git] / rostests / drivers / kmtest / kmtest.c
1 /*
2 * Kernel Mode regression Test
3 * Driver Core
4 *
5 * Copyright 2004 Filip Navara <xnavara@volny.cz>
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 "kmtest.h"
27
28 LONG successes;
29 LONG failures;
30 tls_data glob_data;
31
32 /* PRIVATE FUNCTIONS ***********************************************************/
33 VOID
34 StartTest()
35 {
36 successes = 0;
37 failures = 0;
38 }
39
40 VOID
41 FinishTest(LPSTR TestName)
42 {
43 DbgPrint("Test %s finished with %d succeses and %d failures\n", TestName, successes, failures);
44 }
45
46 void kmtest_set_location(const char* file, int line)
47 {
48 glob_data.current_file=strrchr(file,'/');
49 if (glob_data.current_file==NULL)
50 glob_data.current_file=strrchr(file,'\\');
51 if (glob_data.current_file==NULL)
52 glob_data.current_file=file;
53 else
54 glob_data.current_file++;
55 glob_data.current_line=line;
56 }
57
58 /*
59 * Checks condition.
60 * Parameters:
61 * - condition - condition to check;
62 * - msg test description;
63 * - file - test application source code file name of the check
64 * - line - test application source code file line number of the check
65 * Return:
66 * 0 if condition does not have the expected value, 1 otherwise
67 */
68 int kmtest_ok(int condition, const char *msg, ... )
69 {
70 va_list valist;
71
72 if (!condition)
73 {
74 if (msg[0])
75 {
76 char string[1024];
77 va_start(valist, msg);
78 vsprintf(string, msg, valist);
79 DbgPrint( "%s:%d: Test failed: %s\n",
80 glob_data.current_file, glob_data.current_line, string );
81 va_end(valist);
82 }
83 else
84 {
85 DbgPrint( "%s:%d: Test failed\n",
86 glob_data.current_file, glob_data.current_line );
87 }
88 InterlockedIncrement(&failures);
89 return 0;
90 }
91 else
92 {/*
93 if (report_success)
94 fprintf( stdout, "%s:%d: Test succeeded\n",
95 glob_data.current_file, glob_data.current_line);*/
96 InterlockedIncrement(&successes);
97 }
98 return 1;
99 }
100
101 /* PUBLIC FUNCTIONS ***********************************************************/
102
103 /*
104 * Test Declarations
105 */
106 VOID NtoskrnlIoTests();
107 VOID NtoskrnlObTest();
108 VOID NtoskrnlExecutiveTests();
109 VOID NtoskrnlPoolsTest();
110
111 /*
112 * KmtestUnload
113 */
114 VOID
115 NTAPI
116 KmtestUnload(IN PDRIVER_OBJECT DriverObject)
117 {
118 /* Nothing to do here */
119 }
120
121 /*
122 * DriverEntry
123 */
124 NTSTATUS
125 NTAPI
126 DriverEntry(PDRIVER_OBJECT DriverObject,
127 PUNICODE_STRING RegistryPath)
128 {
129 DbgPrint("\n===============================================\nKernel Mode Regression Test driver starting...\n");
130
131 /* Set necessary routines */
132 DriverObject->DriverUnload = KmtestUnload;
133
134 NtoskrnlExecutiveTests();
135 NtoskrnlIoTests();
136 NtoskrnlObTest();
137 NtoskrnlPoolsTest();
138
139 return STATUS_SUCCESS;
140 }