2004-03-09 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / regtests / regtests / regtests.c
1 /*
2 * PROJECT: ReactOS kernel
3 * FILE: regtests/regtests/regtests.c
4 * PURPOSE: Regression testing host
5 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
6 * UPDATE HISTORY:
7 * 06-07-2003 CSH Created
8 */
9 #define NTOS_MODE_USER
10 #include <stdio.h>
11 #include <ntos.h>
12 #include "regtests.h"
13
14 #define OUPUT_MODE_DbgPrint 0
15 #define OUPUT_MODE_OutputDebugString 1
16 #define OUPUT_MODE_printf 2
17
18 static int OutputMode = 0;
19
20 static void OutputRoutine(char *Buffer)
21 {
22 if (OutputMode == OUPUT_MODE_DbgPrint)
23 {
24 DbgPrint(Buffer);
25 }
26 else if (OutputMode == OUPUT_MODE_OutputDebugString)
27 {
28 OutputDebugString(Buffer);
29 }
30 else if (OutputMode == OUPUT_MODE_printf)
31 {
32 printf(Buffer);
33 }
34 }
35
36 static VOID
37 RunTestDriver(LPSTR FileName, LPSTR TestName)
38 {
39 TestDriverMain Main;
40 HMODULE hModule;
41
42 hModule = LoadLibrary(FileName);
43 if (hModule != NULL)
44 {
45 Main = (TestDriverMain) GetProcAddress(hModule, "RegTestMain");
46 if (Main != NULL)
47 {
48 (Main)(OutputRoutine, TestName);
49 }
50 FreeLibrary(hModule);
51 }
52 }
53
54 int
55 main(int argc, char* argv[])
56 {
57 LPSTR testname = NULL;
58 int i;
59
60 if (argc > 1)
61 {
62 i = 1;
63 if (argv[i][0] == '-')
64 {
65 switch (argv[i][1])
66 {
67 case 'd':
68 OutputMode = OUPUT_MODE_DbgPrint;
69 break;
70 case 'o':
71 OutputMode = OUPUT_MODE_OutputDebugString;
72 break;
73 case 'p':
74 OutputMode = OUPUT_MODE_printf;
75 break;
76 default:
77 printf("Usage: regtests [-dop] [testname]");
78 return 0;
79 }
80 i++;
81 }
82
83 testname = argv[i];
84 }
85
86 RunTestDriver("win32base.dll", testname);
87 RunTestDriver("kmrtint.dll", testname);
88 return 0;
89 }