Author: tkreuzer
Date: Sat Aug  4 20:45:12 2007
New Revision: 28160
URL: 
http://svn.reactos.org/svn/reactos?rev=28160&view=rev
Log:
- implement quick 'n dirty HTML api status output
- change test function return type to INT
- add ASSERT macro
- include some more headers
Modified:
    trunk/rostests/apitests/apitest.c
    trunk/rostests/apitests/apitest.h
    trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c
    trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c
    trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c
    trunk/rostests/apitests/w32knapi/ntgdi/NtGdiArcInternal.c
    trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetBitmapBits.c
    trunk/rostests/apitests/w32knapi/ntgdi/NtGdiSetBitmapBits.c
    trunk/rostests/apitests/w32knapi/ntuser/NtUserCountClipboardFormats.c
    trunk/rostests/apitests/w32knapi/testlist.c
    trunk/rostests/apitests/w32knapi/w32knapi.c
    trunk/rostests/apitests/w32knapi/w32knapi.h
Modified: trunk/rostests/apitests/apitest.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apitest.c?rev=28…
==============================================================================
--- trunk/rostests/apitests/apitest.c (original)
+++ trunk/rostests/apitests/apitest.c Sat Aug  4 20:45:12 2007
@@ -1,24 +1,74 @@
 #include "apitest.h"
+const char szFileHeader[] = "<html><head><style>\ntd.red
{color:red}\ntd.green{color:green}\n</style>\n</head>\n<body>\n<head>\n";
+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>";
+const char szFileFooter[] = "</table></body></html>";
+
 void
-OutputUsage(LPWSTR pszExe)
+OutputUsage(LPWSTR pszName)
 {
        printf("\nUsage:\n\n");
-       printf("%ls <TestName> - perform individual test\n", pszExe);
-       printf("%ls all - perform all tests\n", pszExe);
-       printf("%ls status - create api status file\n", pszExe);
-       printf("%ls -r ... - perform regression testing\n", pszExe);
+       printf("%ls.exe <TestName> - perform individual test\n", pszName);
+       printf("%ls.exe all - perform all tests\n", pszName);
+       printf("%ls.exe status - create api status file\n", pszName);
+       printf("%ls.exe -r ... - perform regression testing\n", pszName);
        printf("\n");
 }
+BOOL
+WriteFileHeader(UINT hFile, LPWSTR pszModule)
+{
+       char szHeader[100];
+
+       write(hFile, szFileHeader, strlen(szFileHeader));
+       sprintf(szHeader, "<H1>Test results for %ls</H1>",
pszModule);
+       write(hFile, szHeader, strlen(szHeader));
+       write(hFile, szTableHeader, strlen(szTableHeader));
+       return TRUE;
+}
+
+BOOL
+WriteRow(UINT hFile, LPWSTR pszFunction, PTESTINFO pti)
+{
+       char szLine[500];
+
+       sprintf(szLine, "<tr><td>%ls</td>", pszFunction);
+
+       switch(pti->nApiStatus)
+       {
+               case APISTATUS_NOT_FOUND:
+                       strcat(szLine, "<td class='red'>not
found</td>");
+                       break;
+               case APISTATUS_UNIMPLEMENTED:
+                       strcat(szLine, "<td
class='red'>unimplemented</td>");
+                       break;
+               case APISTATUS_ASSERTION_FAILED:
+                       strcat(szLine, "<td class='red'>assertion
failed</td>");
+                       break;
+               case APISTATUS_REGRESSION:
+                       strcat(szLine, "<td
class='red'>Regression!</td>");
+                       break;
+               case APISTATUS_NORMAL:
+                       strcat(szLine, "<td
class='green'>Implemented</td>");
+                       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);
+
+       write(hFile, szLine, strlen(szLine));
+       return TRUE;
+}
+
 int
-TestMain(LPWSTR pszExe)
+TestMain(LPWSTR pszName, LPWSTR pszModule)
 {
        INT argc, i, j;
        LPWSTR *argv;
        TESTINFO ti;
        INT opassed, ofailed, orfailed;
        BOOL bAll, bStatus;
+       UINT hFile = 0;
        ti.bRegress = FALSE;
        bAll = FALSE;
@@ -29,7 +79,7 @@
        if (argc < 2)
        {
-               OutputUsage(pszExe);
+               OutputUsage(pszName);
                return 0;
        }
@@ -53,8 +103,16 @@
        if (bStatus)
        {
-               printf("Output of API status is unimplemented.\n");
-               return 0;
+               ti.bRegress = TRUE;
+               char szOutputFile[MAX_PATH];
+               wsprintf(szOutputFile, "%ls.html", pszName);
+               hFile = open(szOutputFile, O_CREAT | O_TRUNC | O_RDWR, 00700);
+               if (hFile == -1)
+               {
+                       printf("Could not create output file.\n");
+                       return 0;
+               }
+               WriteFileHeader(hFile, pszModule);
        }
        for (i = 0; i < NumTests(); i++)
@@ -69,15 +127,22 @@
                                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);
-                                       TestList[i].Proc(&ti);
+                                       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;
+                                       WriteRow(hFile, TestList[i].Test, &ti);
                                }
                                break;
                        }
@@ -94,5 +159,11 @@
        if (ti.bRegress)
                return ti.rfailed;
+       if (bStatus)
+       {
+               write(hFile, szFileFooter, strlen(szFileFooter));
+               close(hFile);
+       }
+
        return ti.failed;
 }
Modified: trunk/rostests/apitests/apitest.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apitest.h?rev=28…
==============================================================================
--- trunk/rostests/apitests/apitest.h (original)
+++ trunk/rostests/apitests/apitest.h Sat Aug  4 20:45:12 2007
@@ -4,11 +4,16 @@
 #define WINVER 0x501
 #include <stdlib.h>
-
 #include <stdarg.h>
 #include <stdio.h>
+#include <fcntl.h>
 #include <windows.h>
+#define APISTATUS_NORMAL 0
+#define APISTATUS_NOT_FOUND 1
+#define APISTATUS_UNIMPLEMENTED 2
+#define APISTATUS_ASSERTION_FAILED 3
+#define APISTATUS_REGRESSION 4
 /* type definitions */
@@ -18,9 +23,10 @@
        INT failed;
        INT rfailed;
        BOOL bRegress;
+       INT nApiStatus;
 } TESTINFO, *PTESTINFO;
-typedef BOOL (*TESTPROC)(PTESTINFO);
+typedef INT (*TESTPROC)(PTESTINFO);
 typedef struct tagTEST
 {
@@ -77,7 +83,14 @@
        }
-int TestMain(LPWSTR pszExe);
+#define ASSERT(x) \
+       if (!(x)) \
+       { \
+                       printf("Assertion failed in %s:%d (%s)\n", __FILE__,
__LINE__, #x);\
+                       return APISTATUS_ASSERTION_FAILED; \
+       }
+
+int TestMain(LPWSTR pszExe, LPWSTR pszModule);
 extern TESTENTRY TestList[];
 INT NumTests(void);
 BOOL IsFunctionPresent(LPWSTR lpszFunction);
Modified: trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntdd/Nt…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c (original)
+++ trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c Sat Aug  4
20:45:12 2007
@@ -10,7 +10,7 @@
        return (HANDLE)Syscall(L"NtGdiDdCreateDirectDrawObject", 1, &hdc);
 }
-BOOL
+INT
 Test_NtGdiDdCreateDirectDrawObject(PTESTINFO pti)
 {
     HDC hdc=CreateDCW(L"Display",NULL,NULL,NULL);
@@ -21,5 +21,5 @@
     DeleteDC(hdc);
-    return TRUE;
+    return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntdd/Nt…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c (original)
+++ trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c Sat Aug  4
20:45:12 2007
@@ -10,10 +10,10 @@
        return (BOOL)Syscall(L"NtGdiDdDeleteDirectDrawObject", 1,
&hDirectDrawLocal);
 }
-BOOL
+INT
 Test_NtGdiDdDeleteDirectDrawObject(PTESTINFO pti)
 {
     TEST(NtGdiDdDeleteDirectDrawObject(NULL) == 0);
-    return TRUE;
+    return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntdd/Nt…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c (original)
+++ trunk/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c Sat Aug  4
20:45:12 2007
@@ -19,9 +19,9 @@
        return (HANDLE)Syscall("NtGdiDdQueryDirectDrawObject", 11,
&hDirectDrawLocal);
 }
 #endif
-BOOL
+INT
 Test_NtGdiDdQueryDirectDrawObject(PTESTINFO pti)
 {
-    return TRUE;
+    return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiArcInternal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/N…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiArcInternal.c (original)
+++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiArcInternal.c Sat Aug  4 20:45:12 2007
@@ -1,6 +1,4 @@
 #include "../w32knapi.h"
-
-typedef int ARCTYPE;
 BOOL
 STDCALL
@@ -19,7 +17,7 @@
        return (BOOL)Syscall(L"NtGdiArcInternal", 10, &arctype);
 }
-BOOL
+INT
 Test_NtGdiArcInternal(PTESTINFO pti)
 {
        HDC hDC = CreateDCW(L"Display",NULL,NULL,NULL);
@@ -53,5 +51,5 @@
        DeleteDC(hDC);
-       return TRUE;
+       return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetBitmapBits.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/N…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetBitmapBits.c (original)
+++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiGetBitmapBits.c Sat Aug  4 20:45:12 2007
@@ -10,7 +10,7 @@
 }
-BOOL
+INT
 Test_NtGdiGetBitmapBits(PTESTINFO pti)
 {
        BYTE Bits[50] = {0,1,2,3,4,5,6,7,8,9};
@@ -70,5 +70,5 @@
        DeleteObject(hBitmap);
-       return TRUE;
+       return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiSetBitmapBits.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/N…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiSetBitmapBits.c (original)
+++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiSetBitmapBits.c Sat Aug  4 20:45:12 2007
@@ -10,7 +10,7 @@
 }
-BOOL
+INT
 Test_NtGdiSetBitmapBits(PTESTINFO pti)
 {
        BYTE Bits[50] = {0,1,2,3,4,5,6,7,8,9};
@@ -70,5 +70,5 @@
        DeleteObject(hBitmap);
-       return TRUE;
+       return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/ntuser/NtUserCountClipboardFormats.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntuser/…
==============================================================================
--- trunk/rostests/apitests/w32knapi/ntuser/NtUserCountClipboardFormats.c (original)
+++ trunk/rostests/apitests/w32knapi/ntuser/NtUserCountClipboardFormats.c Sat Aug  4
20:45:12 2007
@@ -8,11 +8,10 @@
        return Syscall(L"NtUserCountClipboardFormats", 0, &p);
 }
-BOOL
+INT
 Test_NtUserCountClipboardFormats(PTESTINFO pti)
 {
-       TEST(NtUserCountClipboardFormats() < 1000);
-       TEST(TRUE);
-       return TRUE;
+       RTEST(NtUserCountClipboardFormats() < 1000);
+       return APISTATUS_NORMAL;
 }
Modified: trunk/rostests/apitests/w32knapi/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/testlis…
==============================================================================
--- trunk/rostests/apitests/w32knapi/testlist.c (original)
+++ trunk/rostests/apitests/w32knapi/testlist.c Sat Aug  4 20:45:12 2007
@@ -7,25 +7,29 @@
 #include "ntdd/NtGdiDdQueryDirectDrawObject.c"
 #include "ntgdi/NtGdiArcInternal.c"
+//#include "ntgdi/NtGdiDoPalette.c"
+#include "ntgdi/NtGdiGetBitmapBits.c"
 #include "ntgdi/NtGdiSetBitmapBits.c"
-#include "ntgdi/NtGdiGetBitmapBits.c"
+//#include "ntgdi/NtGdiSTROBJ_vEnumStart.c"
 #include "ntuser/NtUserCountClipboardFormats.c"
 /* The List of tests */
 TESTENTRY TestList[] =
 {
-    /* DirectDraw */
+       /* DirectDraw */
        { L"NtGdiDdCreateDirectDrawObject", Test_NtGdiDdCreateDirectDrawObject
},
        { L"NtGdiDdDeleteDirectDrawObject", Test_NtGdiDdDeleteDirectDrawObject
},
        { L"NtGdiDdQueryDirectDrawObject", Test_NtGdiDdQueryDirectDrawObject },
-    /* ntgdi */
+       /* ntgdi */
        { L"NtGdiArcInternal", Test_NtGdiArcInternal },
+//     { L"NtGdiDoPalette", Test_NtGdiDoPalette },
        { L"NtGdiGetBitmapBits", Test_NtGdiGetBitmapBits },
        { L"NtGdiSetBitmapBits", Test_NtGdiSetBitmapBits },
+//     { L"NtGdiSTROBJ_vEnumStart", Test_NtGdiSTROBJ_vEnumStart },
-    /* ntuser */
+       /* ntuser */
        { L"NtUserCountClipboardFormats", Test_NtUserCountClipboardFormats }
 };
Modified: trunk/rostests/apitests/w32knapi/w32knapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/w32knap…
==============================================================================
--- trunk/rostests/apitests/w32knapi/w32knapi.c (original)
+++ trunk/rostests/apitests/w32knapi/w32knapi.c Sat Aug  4 20:45:12 2007
@@ -155,7 +155,7 @@
        printf("\n");
-       TestMain(L"w32knapi.exe");
+       TestMain(L"w32knapi", L"win32k.sys Nt-Api");
        return 0;
 }
Modified: trunk/rostests/apitests/w32knapi/w32knapi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/w32knap…
==============================================================================
--- trunk/rostests/apitests/w32knapi/w32knapi.h (original)
+++ trunk/rostests/apitests/w32knapi/w32knapi.h Sat Aug  4 20:45:12 2007
@@ -2,7 +2,14 @@
 #define _W32KNAPI_H
 #include "../apitest.h"
+
 #include <ddk/winddi.h>
+#include <ddk/ntddk.h>
+
+/* Public Win32K Headers */
+#include <win32k/callback.h>
+#include <win32k/ntusrtyp.h>
+#include <win32k/ntgdityp.h>
 #define OS_UNSUPPORTED 0
 #define OS_REACTOS     1