Fix dlls/kernel/tests/process.c for Win95 and WinXP

Jakob Eriksson jakov at vmlinux.org
Sun Apr 25 16:10:10 CDT 2004


This patch supercedes my previous try.

"kernel32_crosstest.exe process" works for me now on Windows 95 and 
Windows XP.


-------------- next part --------------
Index: process.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/process.c,v
retrieving revision 1.15
diff -u -r1.15 process.c
--- process.c	6 Feb 2004 05:24:34 -0000	1.15
+++ process.c	25 Apr 2004 21:09:14 -0000
@@ -18,6 +18,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/*
+ *  TODO - share test_win9x_based() with file.c and console.c
+ */
+
+
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -30,6 +35,23 @@
 #include "wincon.h"
 #include "winnls.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;
+
+
 static char     base[MAX_PATH];
 static char     selfname[MAX_PATH];
 static char     resfile[MAX_PATH];
@@ -202,6 +224,7 @@
     char                bufA[MAX_PATH];
     WCHAR               bufW[MAX_PATH];
     HANDLE              hFile = CreateFileA(file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    int                 ret;
 
     if (hFile == INVALID_HANDLE_VALUE) return;
 
@@ -327,13 +350,19 @@
             childPrintf(hFile, "OutputMode=%ld\n", modeOut);
 
         /* now that we have written all relevant information, let's change it */
-        ok(SetConsoleCP(1252), "Setting CP\n");
-        ok(SetConsoleOutputCP(1252), "Setting SB CP\n");
+        win9x_based || ok(SetConsoleCP(1252), "Setting CP\n");
+        win9x_based || ok(SetConsoleOutputCP(1252), "Setting SB CP\n");
         ok(SetConsoleMode(hConIn, modeIn ^ 1), "Setting mode (%ld)\n", GetLastError());
         ok(SetConsoleMode(hConOut, modeOut ^ 1), "Setting mode (%ld)\n", GetLastError());
         sbi.dwCursorPosition.X ^= 1;
         sbi.dwCursorPosition.Y ^= 1;
-        ok(SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition), "Setting cursor position (%ld)\n", GetLastError());
+        ret = SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition);
+	if (win9x_based && 0 == ret)
+            ok(ERROR_INVALID_PARAMETER == GetLastError(),
+               "GetLastError() = %ld\n",
+               GetLastError());
+	else
+            ok(ret, "GetLastError() = %ld\n", GetLastError());
     }
     if (option && strcmp(option, "stdhandle") == 0)
     {
@@ -421,6 +450,65 @@
         ok(result == expect, "%s:%s expected %d, but got %d\n", (sect), (key), (int)(expect), result); \
    } while (0)
 
+static const char* test_Startup_strip_args(const char *path)
+{
+    static char no_args[MAX_PATH + 1];
+    int i;
+
+    if (NULL == path)
+    {
+        return NULL;
+    }
+
+    path && strncpy(no_args, path, strlen(path) + 1);
+
+    i = 0;
+    while (no_args[i])
+    {
+        if (' ' == no_args[i])
+        {
+            no_args[i] = '\0';
+
+            return no_args;
+        }
+	i ++;
+    }
+
+    return no_args;
+}
+
+static const char* test_Startup_strip_full_path(const char *path)
+{
+    int len;
+    const char* onlyname;
+
+    if (NULL == path)
+    {
+        return NULL;
+    }
+
+    len = strlen(path);
+
+    if (0 == len)
+    {
+        return path;
+    }
+
+    onlyname = path + len;
+
+    do
+    {
+        onlyname --;
+	len --;
+    }
+    while (len && *onlyname != '\\');
+
+    if (*onlyname)
+        return onlyname + 1;
+
+    return path;
+}
+
 static void test_Startup(void)
 {
     char                buffer[MAX_PATH];
@@ -444,7 +532,17 @@
     GetStartupInfoA(&si);
     okChildInt("StartupInfoA", "cb", startup.cb);
     okChildString("StartupInfoA", "lpDesktop", si.lpDesktop);
-    okChildString("StartupInfoA", "lpTitle", si.lpTitle);
+    do
+    {
+        const char* sect = "StartupInfoA";
+        const char* key = "lpTitle";
+        const char* expect = test_Startup_strip_args(si.lpTitle);
+        const char* result = test_Startup_strip_full_path(getChildString(sect, key));
+        ok(strCmp(result, expect, 1) == 0,
+           "%s:%s expected '%s', got '%s'\n",
+           sect, key, expect ? expect:"(null)", result);
+    }
+    while (0);
     okChildInt("StartupInfoA", "dwX", startup.dwX);
     okChildInt("StartupInfoA", "dwY", startup.dwY);
     okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
@@ -596,7 +694,11 @@
 
     okChildInt("StartupInfoA", "cb", startup.cb);
     okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
-    okChildString("StartupInfoA", "lpTitle", si.lpTitle);
+    ok(NULL == startup.lpTitle,
+       "Neither Windows XP nor Windows 95 fill in startup.lpTitle "
+       "in CreateProcessA,\nso it should still be NULL. Now it is \"%s\"\n",
+       startup.lpTitle);
+    while (0);
     okChildInt("StartupInfoA", "dwX", startup.dwX);
     okChildInt("StartupInfoA", "dwY", startup.dwY);
     okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
@@ -674,8 +776,8 @@
     todo_wine okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
     todo_wine okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
     okChildInt("StartupInfoA", "dwX", startup.dwX);
-    okChildInt("StartupInfoA", "dwY", startup.dwY);
-    okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
+    todo_wine okChildInt("StartupInfoA", "dwY", startup.dwY);
+    todo_wine okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
     okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
     okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
     okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
@@ -929,8 +1031,19 @@
     WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
 
     okChildInt("StartupInfoA", "cb", startup.cb);
-    okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
-    okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
+    if (win9x_based)
+        okChildString("StartupInfoA", "lpDesktop", NULL);
+    else
+        todo_wine okChildString("StartupInfoA", "lpDesktop", "WinSta0\\Default");
+
+    todo_wine
+    {
+        ok(NULL == startup.lpTitle,
+           "Neither Windows XP nor Windows 95 fill in startup.lpTitle "
+           "in CreateProcessA,\nso it should still be NULL. Now it is \"%s\"\n",
+           startup.lpTitle);
+    }
+		                
     okChildInt("StartupInfoA", "dwX", startup.dwX);
     okChildInt("StartupInfoA", "dwY", startup.dwY);
     okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
@@ -977,8 +1090,14 @@
     WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
 
     okChildInt("StartupInfoA", "cb", startup.cb);
-    okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
-    okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
+    if (win9x_based)
+        okChildString("StartupInfoA", "lpDesktop", NULL);
+    else
+        todo_wine okChildString("StartupInfoA", "lpDesktop", "WinSta0\\Default");
+    ok(NULL == startup.lpTitle,
+       "Neither Windows XP nor Windows 95 fill in startup.lpTitle "
+       "in CreateProcessA,\nso it should still be NULL. Now it is \"%s\"\n",
+       startup.lpTitle);
     okChildInt("StartupInfoA", "dwX", startup.dwX);
     okChildInt("StartupInfoA", "dwY", startup.dwY);
     okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
@@ -1026,6 +1145,7 @@
         startup.hStdInput = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
         startup.hStdOutput = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
     }
+    /**/
     /* now verify everything's ok */
     ok(startup.hStdInput != INVALID_HANDLE_VALUE, "Opening ConIn\n");
     ok(startup.hStdOutput != INVALID_HANDLE_VALUE, "Opening ConOut\n");
@@ -1060,8 +1180,14 @@
     SetConsoleOutputCP(cpOut);
 
     okChildInt("StartupInfoA", "cb", startup.cb);
-    okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
-    okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
+    if (win9x_based)
+        okChildString("StartupInfoA", "lpDesktop", NULL);
+    else
+        todo_wine okChildString("StartupInfoA", "lpDesktop", "WinSta0\\Default");
+    ok(NULL == startup.lpTitle,
+       "Neither Windows XP nor Windows 95 fill in startup.lpTitle "
+       "in CreateProcessA,\nso it should still be NULL. Now it is \"%s\"\n",
+       startup.lpTitle);
     okChildInt("StartupInfoA", "dwX", startup.dwX);
     okChildInt("StartupInfoA", "dwY", startup.dwY);
     okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
@@ -1092,11 +1218,16 @@
     okChildInt("Console", "InputMode", modeIn);
     okChildInt("Console", "OutputMode", modeOut);
 
-    todo_wine ok(cpInC == 1252, "Wrong console CP (expected 1252 got %ld/%ld)\n", cpInC, cpIn);
-    todo_wine ok(cpOutC == 1252, "Wrong console-SB CP (expected 1252 got %ld/%ld)\n", cpOutC, cpOut);
+    if (!win9x_based)
+    {
+        todo_wine ok(cpInC == 1252,
+                     "Wrong console CP (expected 1252 got %ld/%ld)\n", cpInC, cpIn);
+        todo_wine ok(cpOutC == 1252,
+                     "Wrong console-SB CP (expected 1252 got %ld/%ld)\n", cpOutC, cpOut);
+    }
     ok(modeInC == (modeIn ^ 1), "Wrong console mode\n");
     ok(modeOutC == (modeOut ^ 1), "Wrong console-SB mode\n");
-    ok(sbiC.dwCursorPosition.X == (sbi.dwCursorPosition.X ^ 1), "Wrong cursor position\n");
+    ok(0 == sbi.dwCursorPosition.X, "sbi.dwCursorPosition.X = %d\n", sbi.dwCursorPosition.X);
     ok(sbiC.dwCursorPosition.Y == (sbi.dwCursorPosition.Y ^ 1), "Wrong cursor position\n");
 
     release_memory();
@@ -1177,6 +1308,8 @@
 
 START_TEST(process)
 {
+    win9x_based = test_win9x_based();
+
     int b = init();
     ok(b, "Basic init of CreateProcess test\n");
     if (!b) return;


More information about the wine-patches mailing list