48959422ec68f3dd373cc9cd4854c1f4c26f146c
[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
14 #define NDEBUG
15 #include <debug.h>
16
17 LIST_ENTRY AllTests;
18
19 int
20 DriverTest()
21 {
22 /* Dummy */
23 return 0;
24 }
25
26
27 int
28 _regtestsTest()
29 {
30 /* Dummy */
31 return 0;
32 }
33
34
35 VOID
36 InitializeTests()
37 {
38 InitializeListHead(&AllTests);
39 }
40
41 VOID
42 PerformTest(PROS_TEST Test)
43 {
44 char TestName[200];
45 char Buffer[200];
46 int Result;
47
48 memset(TestName, 0, sizeof(TestName));
49 memset(Buffer, 0, sizeof(Buffer));
50
51 if (!((Test->Routine)(TESTCMD_TESTNAME, TestName) == 0))
52 {
53 strcpy(TestName, "Unnamed");
54 }
55
56 #ifdef SEH
57 __try {
58 #endif
59 Result = (Test->Routine)(TESTCMD_RUN, Buffer);
60 #ifdef SEH
61 } __except(EXCEPTION_EXECUTE_HANDLER) {
62 Result = TS_FAILED;
63 strcpy(Buffer, "Failed due to exception");
64 }
65 #endif
66
67 if (Result != TS_OK)
68 {
69 DbgPrint("ROSREGTEST: (%s) Status: Failed (%s)\n", TestName, Buffer);
70 }
71 else
72 {
73 DbgPrint("ROSREGTEST: (%s) Status: Success\n", TestName);
74 }
75 }
76
77 VOID
78 PerformTests()
79 {
80 PLIST_ENTRY CurrentEntry;
81 PLIST_ENTRY NextEntry;
82 PROS_TEST Current;
83
84 CurrentEntry = AllTests.Flink;
85 while (CurrentEntry != &AllTests)
86 {
87 NextEntry = CurrentEntry->Flink;
88 Current = CONTAINING_RECORD(CurrentEntry, ROS_TEST, ListEntry);
89 PerformTest(Current);
90 CurrentEntry = NextEntry;
91 }
92 }
93
94 VOID
95 AddTest(TestRoutine Routine)
96 {
97 PROS_TEST Test;
98
99 Test = (PROS_TEST) AllocateMemory(sizeof(ROS_TEST));
100 if (Test == NULL)
101 {
102 DbgPrint("Out of memory");
103 return;
104 }
105
106 Test->Routine = Routine;
107
108 InsertTailList(&AllTests, &Test->ListEntry);
109 }