3 const char szFileHeader
[] = "<html><head><style>\ntd.red {color:red}\ntd.green{color:green}\n</style>\n</head>\n<body>\n<head>\n";
4 const char szTableHeader
[] = "<table width = '800'><tr><th align='left'>Function</th><th align='left'>Status</th><th align='left'>Tests (all/passed/failed)</th><th align='left'>Regressions</th></tr>";
5 const char szFileFooter
[] = "</table></body></html>";
8 OutputUsage(LPWSTR pszName
)
10 printf("\nUsage:\n\n");
11 printf("%ls.exe <TestName> - perform individual test\n", pszName
);
12 printf("%ls.exe all - perform all tests\n", pszName
);
13 printf("%ls.exe status - create api status file\n", pszName
);
14 printf("%ls.exe -r ... - perform regression testing\n", pszName
);
19 WriteFileHeader(UINT hFile
, LPWSTR pszModule
)
23 write(hFile
, szFileHeader
, strlen(szFileHeader
));
24 sprintf(szHeader
, "<H1>Test results for %ls</H1>", pszModule
);
25 write(hFile
, szHeader
, strlen(szHeader
));
26 write(hFile
, szTableHeader
, strlen(szTableHeader
));
31 WriteRow(UINT hFile
, LPWSTR pszFunction
, PTESTINFO pti
)
35 sprintf(szLine
, "<tr><td>%ls</td>", pszFunction
);
37 switch(pti
->nApiStatus
)
39 case APISTATUS_NOT_FOUND
:
40 strcat(szLine
, "<td class='red'>not found</td>");
42 case APISTATUS_UNIMPLEMENTED
:
43 strcat(szLine
, "<td class='red'>unimplemented</td>");
45 case APISTATUS_ASSERTION_FAILED
:
46 strcat(szLine
, "<td class='red'>assertion failed</td>");
48 case APISTATUS_REGRESSION
:
49 strcat(szLine
, "<td class='red'>Regression!</td>");
51 case APISTATUS_NORMAL
:
52 strcat(szLine
, "<td class='green'>Implemented</td>");
56 sprintf(szLine
+ strlen(szLine
), "<td>%d / %d / %d</td><td>%d</td></tr>\n",
57 pti
->passed
+pti
->failed
, pti
->passed
, pti
->failed
, pti
->rfailed
);
59 write(hFile
, szLine
, strlen(szLine
));
64 TestMain(LPWSTR pszName
, LPWSTR pszModule
)
69 INT opassed
, ofailed
, orfailed
;
76 opassed
= ofailed
= orfailed
= 0;
78 argv
= CommandLineToArgvW(GetCommandLineW(), &argc
);
87 for (i
= 1; i
< argc
; i
++)
89 if (wcsicmp(argv
[i
], L
"-r") == 0)
93 else if (wcsicmp(argv
[i
], L
"all") == 0)
97 else if (wcsicmp(argv
[i
], L
"status") == 0)
107 char szOutputFile
[MAX_PATH
];
108 wsprintf(szOutputFile
, "%ls.html", pszName
);
109 hFile
= open(szOutputFile
, O_CREAT
| O_TRUNC
| O_RDWR
, 00700);
112 printf("Could not create output file.\n");
115 WriteFileHeader(hFile
, pszModule
);
118 for (i
= 0; i
< NumTests(); i
++)
120 for (j
= 1; j
< argc
; j
++)
122 if (bAll
|| wcsicmp(argv
[j
], TestList
[i
].Test
) == 0)
127 if (!IsFunctionPresent(TestList
[i
].Test
))
129 printf("Function %ls was not found!\n", TestList
[i
].Test
);
130 ti
.nApiStatus
= APISTATUS_NOT_FOUND
;
134 printf("Executing test: %ls\n", TestList
[i
].Test
);
135 ti
.nApiStatus
= TestList
[i
].Proc(&ti
);
136 opassed
+= ti
.passed
;
137 ofailed
+= ti
.failed
;
138 orfailed
+= ti
.rfailed
;
139 printf(" tests: %d, passed: %d, failed: %d\n\n", ti
.passed
+ti
.failed
, ti
.passed
, ti
.failed
);
144 ti
.nApiStatus
= APISTATUS_REGRESSION
;
145 WriteRow(hFile
, TestList
[i
].Test
, &ti
);
152 printf("Overall:\n");
153 printf(" tests: %d, passed: %d, failed: %d\n\n", opassed
+ofailed
, opassed
, ofailed
);
156 printf(" regressions: %d\n", orfailed
);
164 write(hFile
, szFileFooter
, strlen(szFileFooter
));