Make dlls-kernel-tests-console.c work on Windows 95. (And XP.)

Jakob Eriksson jakov at vmlinux.org
Sat Apr 24 17:17:41 CDT 2004



This patch makes "kernel32_crosstest.exe console" work without a hitch 
on both Windows XP and Windows 95.


regards,
Jakob


-------------- next part --------------
Index: console.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/console.c,v
retrieving revision 1.4
diff -u -r1.4 console.c
--- console.c	26 Jan 2004 20:23:25 -0000	1.4
+++ console.c	24 Apr 2004 22:12:19 -0000
@@ -18,10 +18,31 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/*
+ * TODO - merge test_win9x_based() with file.c
+ */
+
 #include "wine/test.h"
 #include <windows.h>
 #include <stdio.h>
 
+static int test_win9x_based()
+{
+    OSVERSIONINFOEX ver;
+	                                                                              
+    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    ok( GetVersionEx ((OSVERSIONINFO *) &ver), " --- Can't get OS version.\n" );
+    if ((4 == ver.dwMajorVersion && 0 == ver.dwMinorVersion && 1381 == ver.dwBuildNumber)
+         || ver.dwMajorVersion >= 5)
+    {
+        return 0;
+    }
+    return 1;
+}
+
+static int win9x_based;
+
+
 /* DEFAULT_ATTRIB is used for all initial filling of the console.
  * all modifications are made with TEST_ATTRIB so that we could check
  * what has to be modified or not
@@ -137,9 +158,10 @@
 {
     COORD		c;
     DWORD		len, mode;
-    const char*		mytest = "abcd\nf\tg";
-    const int	mylen = strlen(mytest);
+    char*		mytest;
+    int                 mylen;
     int			p;
+    int                 ret;
 
     ok(GetConsoleMode(hCon, &mode) && SetConsoleMode(hCon, mode & ~(ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT)),
        "clearing wrap at EOL & processed output\n");
@@ -148,7 +170,18 @@
     c.X = sbSize.X - 3; c.Y = 0;
     ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
 
-    ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
+    if (win9x_based)
+    {
+        mytest = "123";
+    }
+    else
+    {
+        mytest = "abcd\nf\tg";
+    }
+    mylen = strlen(mytest);
+
+    ret = WriteConsole(hCon, mytest, mylen, &len, NULL);
+    ok(ret != 0 && len == mylen, "Couldn't write, ret = %d, len = %ld\n", ret, len);
     c.Y = 0;
     for (p = mylen - 3; p < mylen; p++)
     {
@@ -161,7 +194,8 @@
 
     p = sbSize.X - 3 + mylen % 3;
     c.X = p; c.Y = 0;
-    okCURSOR(hCon, c);
+    if (!win9x_based)
+        okCURSOR(hCon, c);
 
     /* write line, wrapping disabled, strings end on end of line */
     c.X = sbSize.X - mylen; c.Y = 0;
@@ -176,11 +210,13 @@
     }
 
     c.X = 0; c.Y = 1;
-    okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
+    if (!win9x_based)
+        okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
 
     p = sbSize.X - mylen;
     c.X = p; c.Y = 0;
-    okCURSOR(hCon, c);
+    if (!win9x_based)
+        okCURSOR(hCon, c);
 }
 
 static void testWriteNotWrappedProcessed(HANDLE hCon, COORD sbSize)
@@ -281,6 +317,7 @@
         c.X = sbSize.X - 9 + p;
         okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
     }
+
     c.X = sbSize.X - 9 + mylen;
     okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
     c.X = 0; c.Y = 1;
@@ -290,12 +327,19 @@
     c.X = sbSize.X - 3; c.Y = 0;
     ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
 
-    ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "WriteConsole\n");
+    if (win9x_based)
+        return;
+
+    ok(WriteConsole(hCon, mytest, mylen, &len, NULL) != 0 && len == mylen, "len=%ld\n", len);
+
     c.Y = 0;
     for (p = 0; p < 3; p++)
     {
         c.X = sbSize.X - 3 + p;
-        okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
+	if (!win9x_based)
+        {
+            okCHAR(hCon, c, mytest[p], TEST_ATTRIB);
+        }
     }
 
     c.Y = 1;
@@ -542,6 +586,8 @@
     HANDLE hConIn, hConOut;
     BOOL ret;
     CONSOLE_SCREEN_BUFFER_INFO	sbi;
+
+    win9x_based = test_win9x_based();
 
     /* be sure we have a clean console (and that's our own)
      * FIXME: this will make the test fail (currently) if we don't run


More information about the wine-patches mailing list