patch for -Werror -Wall by jonathan wilson
[reactos.git] / reactos / regtests / shared / regtests.c
1 /*
2 * PROJECT: ReactOS kernel
3 * FILE: regtests/shared/regtests.c
4 * PURPOSE: Regression testing framework
5 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
6 * UPDATE HISTORY:
7 * 06-07-2003 CSH Created
8 */
9 #include <roscfg.h>
10 #define NTOS_MODE_USER
11 #include <ntos.h>
12 #include "regtests.h"
13 #include <string.h>
14
15 #define NDEBUG
16 #include <debug.h>
17
18 LIST_ENTRY AllTests;
19
20 int
21 DriverTest()
22 {
23 /* Dummy */
24 return 0;
25 }
26
27
28 int
29 _regtestsTest()
30 {
31 /* Dummy */
32 return 0;
33 }
34
35
36 VOID
37 InitializeTests()
38 {
39 InitializeListHead(&AllTests);
40 }
41
42 VOID
43 PerformTest(PROS_TEST Test)
44 {
45 char TestName[200];
46 char Buffer[200];
47 int Result;
48
49 memset(TestName, 0, sizeof(TestName));
50 memset(Buffer, 0, sizeof(Buffer));
51
52 if (!((Test->Routine)(TESTCMD_TESTNAME, TestName) == 0))
53 {
54 strcpy(TestName, "Unnamed");
55 }
56
57 #ifdef SEH
58 __try {
59 #endif
60 Result = (Test->Routine)(TESTCMD_RUN, Buffer);
61 #ifdef SEH
62 } __except(EXCEPTION_EXECUTE_HANDLER) {
63 Result = TS_FAILED;
64 strcpy(Buffer, "Failed due to exception");
65 }
66 #endif
67
68 if (Result != TS_OK)
69 {
70 DbgPrint("ROSREGTEST: (%s) Status: Failed (%s)\n", TestName, Buffer);
71 }
72 else
73 {
74 DbgPrint("ROSREGTEST: (%s) Status: Success\n", TestName);
75 }
76 }
77
78 VOID
79 PerformTests()
80 {
81 PLIST_ENTRY CurrentEntry;
82 PLIST_ENTRY NextEntry;
83 PROS_TEST Current;
84
85 CurrentEntry = AllTests.Flink;
86 while (CurrentEntry != &AllTests)
87 {
88 NextEntry = CurrentEntry->Flink;
89 Current = CONTAINING_RECORD(CurrentEntry, ROS_TEST, ListEntry);
90 PerformTest(Current);
91 CurrentEntry = NextEntry;
92 }
93 }
94
95 VOID
96 AddTest(TestRoutine Routine)
97 {
98 PROS_TEST Test;
99
100 Test = (PROS_TEST) AllocateMemory(sizeof(ROS_TEST));
101 if (Test == NULL)
102 {
103 DbgPrint("Out of memory");
104 return;
105 }
106
107 Test->Routine = Routine;
108
109 InsertTailList(&AllTests, &Test->ListEntry);
110 }