2008-06-01 18:06:22 +00:00
|
|
|
#include "apitest.h"
|
|
|
|
|
2008-06-01 18:37:55 +00:00
|
|
|
const char szFileHeader1[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
|
|
|
|
"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
|
|
|
|
"<head>\n"
|
|
|
|
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
|
|
|
|
const char szFileHeader2[] = "<style type=\"text/css\">\n"
|
|
|
|
"body {font-family: sans-serif;}\n"
|
|
|
|
"table {width: 100%;}\n"
|
|
|
|
"th {text-align: left;}\n"
|
|
|
|
"td.red {color: red;}\n"
|
|
|
|
"td.green {color: green;}\n"
|
|
|
|
"</style>\n"
|
|
|
|
"</head>\n"
|
|
|
|
"<body>\n";
|
|
|
|
const char szTableHeader[] = "<table><tr><th>Function</th><th>Status</th><th>Tests (all/passed/failed)</th><th>Regressions</th></tr>";
|
2008-06-01 18:06:22 +00:00
|
|
|
const char szFileFooter[] = "</table></body></html>";
|
|
|
|
|
|
|
|
void
|
|
|
|
OutputUsage(LPWSTR pszName)
|
|
|
|
{
|
|
|
|
printf("\nUsage:\n\n");
|
2008-06-01 18:37:55 +00:00
|
|
|
printf("%ls.exe <TestName> - Perform individual test\n", pszName);
|
|
|
|
printf("%ls.exe all - Perform all tests\n", pszName);
|
|
|
|
printf("%ls.exe tests - List the valid test names\n", pszName);
|
|
|
|
printf("%ls.exe status - Create api status file\n", pszName);
|
|
|
|
printf("%ls.exe -r ... - Perform regression testing\n", pszName);
|
2008-06-01 18:06:22 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFileHeader(HANDLE hFile, LPDWORD lpdwBytesWritten, LPWSTR pszModule)
|
2008-06-01 18:06:22 +00:00
|
|
|
{
|
|
|
|
char szHeader[100];
|
|
|
|
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szFileHeader1, strlen(szFileHeader1), lpdwBytesWritten, NULL);
|
2008-06-01 18:37:55 +00:00
|
|
|
sprintf(szHeader, "<title>%ls Test results</title>", pszModule);
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szHeader, strlen(szHeader), lpdwBytesWritten, NULL);
|
|
|
|
WriteFile(hFile, szFileHeader2, strlen(szFileHeader2), lpdwBytesWritten, NULL);
|
2008-06-01 18:37:55 +00:00
|
|
|
|
|
|
|
sprintf(szHeader, "<h1>Test results for %ls</h1>", pszModule);
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szHeader, strlen(szHeader), lpdwBytesWritten, NULL);
|
2008-06-01 18:37:55 +00:00
|
|
|
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szTableHeader, strlen(szTableHeader), lpdwBytesWritten, NULL);
|
2008-06-01 18:37:55 +00:00
|
|
|
|
2008-06-01 18:06:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteRow(HANDLE hFile, LPDWORD lpdwBytesWritten, LPWSTR pszFunction, PTESTINFO pti)
|
2008-06-01 18:06:22 +00:00
|
|
|
{
|
|
|
|
char szLine[500];
|
|
|
|
|
|
|
|
sprintf(szLine, "<tr><td>%ls</td>", pszFunction);
|
|
|
|
|
|
|
|
switch(pti->nApiStatus)
|
|
|
|
{
|
|
|
|
case APISTATUS_NOT_FOUND:
|
2008-06-01 18:37:55 +00:00
|
|
|
strcat(szLine, "<td class=\"red\">not found</td>");
|
2008-06-01 18:06:22 +00:00
|
|
|
break;
|
|
|
|
case APISTATUS_UNIMPLEMENTED:
|
2008-06-01 18:37:55 +00:00
|
|
|
strcat(szLine, "<td class=\"red\">unimplemented</td>");
|
2008-06-01 18:06:22 +00:00
|
|
|
break;
|
|
|
|
case APISTATUS_ASSERTION_FAILED:
|
2008-06-01 18:37:55 +00:00
|
|
|
strcat(szLine, "<td class=\"red\">assertion failed</td>");
|
2008-06-01 18:06:22 +00:00
|
|
|
break;
|
|
|
|
case APISTATUS_REGRESSION:
|
2008-06-01 18:37:55 +00:00
|
|
|
strcat(szLine, "<td class=\"red\">Regression!</td>");
|
2008-06-01 18:06:22 +00:00
|
|
|
break;
|
|
|
|
case APISTATUS_NORMAL:
|
2008-06-01 18:37:55 +00:00
|
|
|
strcat(szLine, "<td class=\"green\">Implemented</td>");
|
2008-06-01 18:06:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(szLine + strlen(szLine), "<td>%d / %d / %d</td><td>%d</td></tr>\n",
|
|
|
|
pti->passed+pti->failed, pti->passed, pti->failed, pti->rfailed);
|
|
|
|
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szLine, strlen(szLine), lpdwBytesWritten, NULL);
|
|
|
|
|
2008-06-01 18:06:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-12-13 16:52:49 +00:00
|
|
|
static CHAR
|
|
|
|
GetDisplayChar(CHAR c)
|
|
|
|
{
|
|
|
|
if (c < 32) return '.';
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
DumpMem(PVOID pData, ULONG cbSize, ULONG nWidth)
|
|
|
|
{
|
|
|
|
ULONG cLines = (cbSize + nWidth - 1) / nWidth;
|
|
|
|
ULONG cbLastLine = cbSize % nWidth;
|
|
|
|
INT i,j;
|
|
|
|
|
|
|
|
for (i = 0; i <= cLines; i++)
|
|
|
|
{
|
|
|
|
printf("%08lx: ", i*nWidth);
|
|
|
|
for (j = 0; j < (i == cLines? cbLastLine : nWidth); j++)
|
|
|
|
{
|
|
|
|
printf("%02x ", ((BYTE*)pData)[i*nWidth + j]);
|
|
|
|
}
|
|
|
|
printf(" ");
|
|
|
|
for (j = 0; j < (i == cLines? cbLastLine : nWidth); j++)
|
|
|
|
{
|
|
|
|
printf("%c", GetDisplayChar(((CHAR*)pData)[i*nWidth + j]));
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-01 18:06:22 +00:00
|
|
|
int
|
|
|
|
TestMain(LPWSTR pszName, LPWSTR pszModule)
|
|
|
|
{
|
|
|
|
INT argc, i, j;
|
|
|
|
LPWSTR *argv;
|
|
|
|
TESTINFO ti;
|
|
|
|
INT opassed, ofailed, orfailed;
|
|
|
|
BOOL bAll, bStatus;
|
2008-06-01 20:34:12 +00:00
|
|
|
HANDLE hFile = NULL;
|
|
|
|
DWORD dwBytesWritten;
|
2008-06-01 18:06:22 +00:00
|
|
|
|
|
|
|
ti.bRegress = FALSE;
|
|
|
|
bAll = FALSE;
|
|
|
|
bStatus = FALSE;
|
|
|
|
opassed = ofailed = orfailed = 0;
|
|
|
|
|
|
|
|
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
{
|
|
|
|
OutputUsage(pszName);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get options */
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (_wcsicmp(argv[i], L"-r") == 0)
|
|
|
|
{
|
|
|
|
ti.bRegress = TRUE;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(argv[i], L"all") == 0)
|
|
|
|
{
|
|
|
|
bAll = TRUE;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(argv[i], L"status") == 0)
|
|
|
|
{
|
|
|
|
bAll = TRUE;
|
|
|
|
bStatus = TRUE;
|
|
|
|
}
|
2008-06-01 18:37:55 +00:00
|
|
|
else if (_wcsicmp(argv[i], L"tests") == 0)
|
|
|
|
{
|
|
|
|
/* List all the tests and exit */
|
|
|
|
printf("Valid test names:\n\n");
|
|
|
|
|
|
|
|
for (i = 0; i < NumTests(); i++)
|
|
|
|
printf("%ls\n", TestList[i].Test);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bStatus)
|
|
|
|
{
|
2008-06-01 20:34:12 +00:00
|
|
|
WCHAR szOutputFile[MAX_PATH];
|
|
|
|
|
2008-06-01 18:06:22 +00:00
|
|
|
ti.bRegress = TRUE;
|
2008-06-01 20:34:12 +00:00
|
|
|
wcscpy(szOutputFile, pszName);
|
|
|
|
wcscat(szOutputFile, L".html");
|
|
|
|
hFile = CreateFileW(szOutputFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
2008-06-01 18:06:22 +00:00
|
|
|
{
|
|
|
|
printf("Could not create output file.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-01 20:34:12 +00:00
|
|
|
|
|
|
|
WriteFileHeader(hFile, &dwBytesWritten, pszModule);
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NumTests(); i++)
|
|
|
|
{
|
|
|
|
for (j = 1; j < argc; j++)
|
|
|
|
{
|
|
|
|
if (bAll || _wcsicmp(argv[j], TestList[i].Test) == 0)
|
|
|
|
{
|
|
|
|
ti.passed = 0;
|
|
|
|
ti.failed = 0;
|
|
|
|
ti.rfailed = 0;
|
|
|
|
if (!IsFunctionPresent(TestList[i].Test))
|
|
|
|
{
|
|
|
|
printf("Function %ls was not found!\n", TestList[i].Test);
|
|
|
|
ti.nApiStatus = APISTATUS_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Executing test: %ls\n", TestList[i].Test);
|
|
|
|
ti.nApiStatus = TestList[i].Proc(&ti);
|
|
|
|
opassed += ti.passed;
|
|
|
|
ofailed += ti.failed;
|
|
|
|
orfailed += ti.rfailed;
|
|
|
|
printf(" tests: %d, passed: %d, failed: %d\n\n", ti.passed+ti.failed, ti.passed, ti.failed);
|
|
|
|
}
|
|
|
|
if (bStatus)
|
|
|
|
{
|
|
|
|
if (ti.rfailed > 0)
|
|
|
|
ti.nApiStatus = APISTATUS_REGRESSION;
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteRow(hFile, &dwBytesWritten, TestList[i].Test, &ti);
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Overall:\n");
|
|
|
|
printf(" tests: %d, passed: %d, failed: %d\n\n", opassed+ofailed, opassed, ofailed);
|
|
|
|
if (ti.bRegress)
|
|
|
|
{
|
|
|
|
printf(" regressions: %d\n", orfailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bStatus)
|
|
|
|
{
|
2008-06-01 20:34:12 +00:00
|
|
|
WriteFile(hFile, szFileFooter, strlen(szFileFooter), &dwBytesWritten, NULL);
|
|
|
|
CloseHandle(hFile);
|
2008-06-01 18:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ti.bRegress)
|
|
|
|
return ti.rfailed;
|
|
|
|
|
|
|
|
return ti.failed;
|
|
|
|
}
|