2 * Unit test suite for CreateProcess function.
4 * Copyright 2002 Eric Pouech
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/test.h"
31 static char base[MAX_PATH];
32 static char selfname[MAX_PATH];
33 static char resfile[MAX_PATH];
38 /* as some environment variables get very long on Unix, we only test for
41 #define MAX_LISTED_ENV_VAR 128
43 /* ---------------- portable memory allocation thingie */
45 static char memory[1024*32];
46 static char* memory_index = memory;
48 static char* grab_memory(size_t len)
50 char* ret = memory_index;
54 assert(memory_index <= memory + sizeof(memory));
58 static void release_memory(void)
60 memory_index = memory;
63 /* ---------------- simplistic tool to encode/decode strings (to hide \ " ' and such) */
65 static char* encodeA(const char* str)
71 len = strlen(str) + 1;
72 ptr = grab_memory(len * 2 + 1);
73 for (i = 0; i < len; i++)
74 sprintf(&ptr[i * 2], "%02x", (unsigned char)str[i]);
79 static char* encodeW(const WCHAR* str)
85 len = lstrlenW(str) + 1;
86 ptr = grab_memory(len * 4 + 1);
88 for (i = 0; i < len; i++)
89 sprintf(&ptr[i * 4], "%04x", (unsigned int)(unsigned short)str[i]);
94 static unsigned decode_char(char c)
96 if (c >= '0' && c <= '9') return c - '0';
97 if (c >= 'a' && c <= 'f') return c - 'a' + 10;
98 assert(c >= 'A' && c <= 'F');
102 static char* decodeA(const char* str)
107 len = strlen(str) / 2;
108 if (!len--) return NULL;
109 ptr = grab_memory(len + 1);
110 for (i = 0; i < len; i++)
111 ptr[i] = (decode_char(str[2 * i]) << 4) | decode_char(str[2 * i + 1]);
117 /* This will be needed to decode Unicode strings saved by the child process
118 * when we test Unicode functions.
120 static WCHAR* decodeW(const char* str)
126 len = strlen(str) / 4;
127 if (!len--) return NULL;
128 ptr = (WCHAR*)grab_memory(len * 2 + 1);
129 for (i = 0; i < len; i++)
130 ptr[i] = (decode_char(str[4 * i]) << 12) |
131 (decode_char(str[4 * i + 1]) << 8) |
132 (decode_char(str[4 * i + 2]) << 4) |
133 (decode_char(str[4 * i + 3]) << 0);
139 /******************************************************************
142 * generates basic information like:
143 * base: absolute path to curr dir
144 * selfname: the way to reinvoke ourselves
146 static int init(void)
148 myARGC = winetest_get_mainargs( &myARGV );
149 if (!GetCurrentDirectoryA(sizeof(base), base)) return 0;
150 strcpy(selfname, myARGV[0]);
154 /******************************************************************
157 * generates an absolute file_name for temporary file
160 static void get_file_name(char* buf)
165 GetTempPathA(sizeof(path), path);
166 GetTempFileNameA(path, "wt", 0, buf);
169 /******************************************************************
170 * static void childPrintf
173 static void childPrintf(HANDLE h, const char* fmt, ...)
179 va_start(valist, fmt);
180 vsprintf(buffer, fmt, valist);
182 WriteFile(h, buffer, strlen(buffer), &w, NULL);
186 /******************************************************************
189 * output most of the information in the child process
191 static void doChild(const char* file, const char* option)
199 WCHAR bufW[MAX_PATH];
200 HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
202 if (hFile == INVALID_HANDLE_VALUE) return;
204 /* output of startup info (Ansi) */
205 GetStartupInfoA(&siA);
207 "[StartupInfoA]\ncb=%08ld\nlpDesktop=%s\nlpTitle=%s\n"
208 "dwX=%lu\ndwY=%lu\ndwXSize=%lu\ndwYSize=%lu\n"
209 "dwXCountChars=%lu\ndwYCountChars=%lu\ndwFillAttribute=%lu\n"
210 "dwFlags=%lu\nwShowWindow=%u\n"
211 "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
212 siA.cb, encodeA(siA.lpDesktop), encodeA(siA.lpTitle),
213 siA.dwX, siA.dwY, siA.dwXSize, siA.dwYSize,
214 siA.dwXCountChars, siA.dwYCountChars, siA.dwFillAttribute,
215 siA.dwFlags, siA.wShowWindow,
216 (DWORD)siA.hStdInput, (DWORD)siA.hStdOutput, (DWORD)siA.hStdError);
218 /* since GetStartupInfoW is only implemented in win2k,
219 * zero out before calling so we can notice the difference
221 memset(&siW, 0, sizeof(siW));
222 GetStartupInfoW(&siW);
224 "[StartupInfoW]\ncb=%08ld\nlpDesktop=%s\nlpTitle=%s\n"
225 "dwX=%lu\ndwY=%lu\ndwXSize=%lu\ndwYSize=%lu\n"
226 "dwXCountChars=%lu\ndwYCountChars=%lu\ndwFillAttribute=%lu\n"
227 "dwFlags=%lu\nwShowWindow=%u\n"
228 "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
229 siW.cb, encodeW(siW.lpDesktop), encodeW(siW.lpTitle),
230 siW.dwX, siW.dwY, siW.dwXSize, siW.dwYSize,
231 siW.dwXCountChars, siW.dwYCountChars, siW.dwFillAttribute,
232 siW.dwFlags, siW.wShowWindow,
233 (DWORD)siW.hStdInput, (DWORD)siW.hStdOutput, (DWORD)siW.hStdError);
236 childPrintf(hFile, "[Arguments]\nargcA=%d\n", myARGC);
237 for (i = 0; i < myARGC; i++)
239 childPrintf(hFile, "argvA%d=%s\n", i, encodeA(myARGV[i]));
241 childPrintf(hFile, "CommandLineA=%s\n", encodeA(GetCommandLineA()));
247 /* this is part of shell32... and should be tested there */
248 argvW = CommandLineToArgvW(GetCommandLineW(), &argcW);
249 for (i = 0; i < argcW; i++)
251 childPrintf(hFile, "argvW%d=%s\n", i, encodeW(argvW[i]));
254 childPrintf(hFile, "CommandLineW=%s\n\n", encodeW(GetCommandLineW()));
256 /* output of environment (Ansi) */
257 ptrA = GetEnvironmentStringsA();
260 char env_var[MAX_LISTED_ENV_VAR];
262 childPrintf(hFile, "[EnvironmentA]\n");
266 strncpy(env_var, ptrA, MAX_LISTED_ENV_VAR - 1);
267 env_var[MAX_LISTED_ENV_VAR - 1] = '\0';
268 childPrintf(hFile, "env%d=%s\n", i, encodeA(env_var));
270 ptrA += strlen(ptrA) + 1;
272 childPrintf(hFile, "len=%d\n\n", i);
275 /* output of environment (Unicode) */
276 ptrW = GetEnvironmentStringsW();
279 WCHAR env_var[MAX_LISTED_ENV_VAR];
281 childPrintf(hFile, "[EnvironmentW]\n");
285 lstrcpynW(env_var, ptrW, MAX_LISTED_ENV_VAR - 1);
286 env_var[MAX_LISTED_ENV_VAR - 1] = '\0';
287 childPrintf(hFile, "env%d=%s\n", i, encodeW(ptrW));
289 ptrW += lstrlenW(ptrW) + 1;
291 childPrintf(hFile, "len=%d\n\n", i);
294 childPrintf(hFile, "[Misc]\n");
295 if (GetCurrentDirectoryA(sizeof(bufA), bufA))
296 childPrintf(hFile, "CurrDirA=%s\n", encodeA(bufA));
297 if (GetCurrentDirectoryW(sizeof(bufW) / sizeof(bufW[0]), bufW))
298 childPrintf(hFile, "CurrDirW=%s\n", encodeW(bufW));
299 childPrintf(hFile, "\n");
301 if (option && strcmp(option, "console") == 0)
303 CONSOLE_SCREEN_BUFFER_INFO sbi;
304 HANDLE hConIn = GetStdHandle(STD_INPUT_HANDLE);
305 HANDLE hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
306 DWORD modeIn, modeOut;
308 childPrintf(hFile, "[Console]\n");
309 if (GetConsoleScreenBufferInfo(hConOut, &sbi))
311 childPrintf(hFile, "SizeX=%d\nSizeY=%d\nCursorX=%d\nCursorY=%d\nAttributes=%d\n",
312 sbi.dwSize.X, sbi.dwSize.Y, sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y, sbi.wAttributes);
313 childPrintf(hFile, "winLeft=%d\nwinTop=%d\nwinRight=%d\nwinBottom=%d\n",
314 sbi.srWindow.Left, sbi.srWindow.Top, sbi.srWindow.Right, sbi.srWindow.Bottom);
315 childPrintf(hFile, "maxWinWidth=%d\nmaxWinHeight=%d\n",
316 sbi.dwMaximumWindowSize.X, sbi.dwMaximumWindowSize.Y);
318 childPrintf(hFile, "InputCP=%d\nOutputCP=%d\n",
319 GetConsoleCP(), GetConsoleOutputCP());
320 if (GetConsoleMode(hConIn, &modeIn))
321 childPrintf(hFile, "InputMode=%ld\n", modeIn);
322 if (GetConsoleMode(hConOut, &modeOut))
323 childPrintf(hFile, "OutputMode=%ld\n", modeOut);
325 /* now that we have written all relevant information, let's change it */
326 ok(SetConsoleCP(1252), "Setting CP");
327 ok(SetConsoleOutputCP(1252), "Setting SB CP");
328 ok(SetConsoleMode(hConIn, modeIn ^ 1), "Setting mode (%ld)", GetLastError());
329 ok(SetConsoleMode(hConOut, modeOut ^ 1), "Setting mode (%ld)", GetLastError());
330 sbi.dwCursorPosition.X ^= 1;
331 sbi.dwCursorPosition.Y ^= 1;
332 ok(SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition), "Setting cursor position (%ld)", GetLastError());
334 if (option && strcmp(option, "stdhandle") == 0)
336 HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
337 HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
339 if (hStdIn != INVALID_HANDLE_VALUE || hStdOut != INVALID_HANDLE_VALUE)
344 ok(ReadFile(hStdIn, buf, sizeof(buf), &r, NULL) && r > 0, "Reading message from input pipe");
345 childPrintf(hFile, "[StdHandle]\nmsg=%s\n\n", encodeA(buf));
346 ok(WriteFile(hStdOut, buf, r, &w, NULL) && w == r, "Writting message to output pipe");
353 static char* getChildString(const char* sect, const char* key)
358 GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), resfile);
359 if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
360 assert(!(strlen(buf) & 1));
365 /* FIXME: this may be moved to the wtmain.c file, because it may be needed by
366 * others... (windows uses stricmp while Un*x uses strcasecmp...)
368 static int wtstrcasecmp(const char* p1, const char* p2)
373 while (c1 == c2 && c1)
375 c1 = *p1++; c2 = *p2++;
378 c1 = toupper(c1); c2 = toupper(c2);
384 static int strCmp(const char* s1, const char* s2, BOOL sensitive)
386 if (!s1 && !s2) return 0;
389 return (sensitive) ? strcmp(s1, s2) : wtstrcasecmp(s1, s2);
392 #define okChildString(sect, key, expect) \
394 char* result = getChildString((sect), (key)); \
395 ok(strCmp(result, expect, 1) == 0, "%s:%s expected '%s', got '%s'", (sect), (key), (expect)?(expect):"(null)", result); \
398 #define okChildIString(sect, key, expect) \
400 char* result = getChildString(sect, key); \
401 ok(strCmp(result, expect, 0) == 0, "%s:%s expected '%s', got '%s'", sect, key, expect, result); \
404 /* using !expect insures that the test will fail if the sect/key isn't present
407 #define okChildInt(sect, key, expect) \
409 UINT result = GetPrivateProfileIntA((sect), (key), !(expect), resfile); \
410 ok(result == expect, "%s:%s expected %d, but got %d", (sect), (key), (int)(expect), result); \
413 static void test_Startup(void)
415 char buffer[MAX_PATH];
416 PROCESS_INFORMATION info;
417 STARTUPINFOA startup,si;
419 /* let's start simplistic */
420 memset(&startup, 0, sizeof(startup));
421 startup.cb = sizeof(startup);
422 startup.dwFlags = STARTF_USESHOWWINDOW;
423 startup.wShowWindow = SW_SHOWNORMAL;
425 get_file_name(resfile);
426 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
427 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
428 /* wait for child to terminate */
429 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
430 /* child process has changed result file, so let profile functions know about it */
431 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
433 GetStartupInfoA(&si);
434 okChildInt("StartupInfoA", "cb", startup.cb);
435 okChildString("StartupInfoA", "lpDesktop", si.lpDesktop);
436 okChildString("StartupInfoA", "lpTitle", si.lpTitle);
437 okChildInt("StartupInfoA", "dwX", startup.dwX);
438 okChildInt("StartupInfoA", "dwY", startup.dwY);
439 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
440 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
441 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
442 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
443 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
444 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
445 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
447 assert(DeleteFileA(resfile) != 0);
449 /* not so simplistic now */
450 memset(&startup, 0, sizeof(startup));
451 startup.cb = sizeof(startup);
452 startup.dwFlags = STARTF_USESHOWWINDOW;
453 startup.wShowWindow = SW_SHOWNORMAL;
454 startup.lpTitle = "I'm the title string";
455 startup.lpDesktop = "I'm the desktop string";
456 startup.dwXCountChars = 0x12121212;
457 startup.dwYCountChars = 0x23232323;
458 startup.dwX = 0x34343434;
459 startup.dwY = 0x45454545;
460 startup.dwXSize = 0x56565656;
461 startup.dwYSize = 0x67676767;
462 startup.dwFillAttribute = 0xA55A;
464 get_file_name(resfile);
465 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
466 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
467 /* wait for child to terminate */
468 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
469 /* child process has changed result file, so let profile functions know about it */
470 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
472 okChildInt("StartupInfoA", "cb", startup.cb);
473 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
474 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
475 okChildInt("StartupInfoA", "dwX", startup.dwX);
476 okChildInt("StartupInfoA", "dwY", startup.dwY);
477 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
478 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
479 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
480 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
481 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
482 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
483 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
485 assert(DeleteFileA(resfile) != 0);
487 /* not so simplistic now */
488 memset(&startup, 0, sizeof(startup));
489 startup.cb = sizeof(startup);
490 startup.dwFlags = STARTF_USESHOWWINDOW;
491 startup.wShowWindow = SW_SHOWNORMAL;
492 startup.lpTitle = "I'm the title string";
493 startup.lpDesktop = NULL;
494 startup.dwXCountChars = 0x12121212;
495 startup.dwYCountChars = 0x23232323;
496 startup.dwX = 0x34343434;
497 startup.dwY = 0x45454545;
498 startup.dwXSize = 0x56565656;
499 startup.dwYSize = 0x67676767;
500 startup.dwFillAttribute = 0xA55A;
502 get_file_name(resfile);
503 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
504 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
505 /* wait for child to terminate */
506 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
507 /* child process has changed result file, so let profile functions know about it */
508 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
510 okChildInt("StartupInfoA", "cb", startup.cb);
511 okChildString("StartupInfoA", "lpDesktop", si.lpDesktop);
512 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
513 okChildInt("StartupInfoA", "dwX", startup.dwX);
514 okChildInt("StartupInfoA", "dwY", startup.dwY);
515 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
516 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
517 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
518 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
519 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
520 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
521 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
523 assert(DeleteFileA(resfile) != 0);
525 /* not so simplistic now */
526 memset(&startup, 0, sizeof(startup));
527 startup.cb = sizeof(startup);
528 startup.dwFlags = STARTF_USESHOWWINDOW;
529 startup.wShowWindow = SW_SHOWNORMAL;
530 startup.lpTitle = "I'm the title string";
531 startup.lpDesktop = "";
532 startup.dwXCountChars = 0x12121212;
533 startup.dwYCountChars = 0x23232323;
534 startup.dwX = 0x34343434;
535 startup.dwY = 0x45454545;
536 startup.dwXSize = 0x56565656;
537 startup.dwYSize = 0x67676767;
538 startup.dwFillAttribute = 0xA55A;
540 get_file_name(resfile);
541 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
542 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
543 /* wait for child to terminate */
544 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
545 /* child process has changed result file, so let profile functions know about it */
546 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
548 okChildInt("StartupInfoA", "cb", startup.cb);
549 todo_wine okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
550 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
551 okChildInt("StartupInfoA", "dwX", startup.dwX);
552 okChildInt("StartupInfoA", "dwY", startup.dwY);
553 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
554 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
555 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
556 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
557 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
558 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
559 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
561 assert(DeleteFileA(resfile) != 0);
563 /* not so simplistic now */
564 memset(&startup, 0, sizeof(startup));
565 startup.cb = sizeof(startup);
566 startup.dwFlags = STARTF_USESHOWWINDOW;
567 startup.wShowWindow = SW_SHOWNORMAL;
568 startup.lpTitle = NULL;
569 startup.lpDesktop = "I'm the desktop string";
570 startup.dwXCountChars = 0x12121212;
571 startup.dwYCountChars = 0x23232323;
572 startup.dwX = 0x34343434;
573 startup.dwY = 0x45454545;
574 startup.dwXSize = 0x56565656;
575 startup.dwYSize = 0x67676767;
576 startup.dwFillAttribute = 0xA55A;
578 get_file_name(resfile);
579 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
580 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
581 /* wait for child to terminate */
582 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
583 /* child process has changed result file, so let profile functions know about it */
584 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
586 okChildInt("StartupInfoA", "cb", startup.cb);
587 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
588 okChildString("StartupInfoA", "lpTitle", si.lpTitle);
589 okChildInt("StartupInfoA", "dwX", startup.dwX);
590 okChildInt("StartupInfoA", "dwY", startup.dwY);
591 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
592 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
593 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
594 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
595 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
596 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
597 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
599 assert(DeleteFileA(resfile) != 0);
601 /* not so simplistic now */
602 memset(&startup, 0, sizeof(startup));
603 startup.cb = sizeof(startup);
604 startup.dwFlags = STARTF_USESHOWWINDOW;
605 startup.wShowWindow = SW_SHOWNORMAL;
606 startup.lpTitle = "";
607 startup.lpDesktop = "I'm the desktop string";
608 startup.dwXCountChars = 0x12121212;
609 startup.dwYCountChars = 0x23232323;
610 startup.dwX = 0x34343434;
611 startup.dwY = 0x45454545;
612 startup.dwXSize = 0x56565656;
613 startup.dwYSize = 0x67676767;
614 startup.dwFillAttribute = 0xA55A;
616 get_file_name(resfile);
617 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
618 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
619 /* wait for child to terminate */
620 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
621 /* child process has changed result file, so let profile functions know about it */
622 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
624 okChildInt("StartupInfoA", "cb", startup.cb);
625 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
626 todo_wine okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
627 okChildInt("StartupInfoA", "dwX", startup.dwX);
628 okChildInt("StartupInfoA", "dwY", startup.dwY);
629 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
630 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
631 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
632 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
633 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
634 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
635 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
637 assert(DeleteFileA(resfile) != 0);
639 /* not so simplistic now */
640 memset(&startup, 0, sizeof(startup));
641 startup.cb = sizeof(startup);
642 startup.dwFlags = STARTF_USESHOWWINDOW;
643 startup.wShowWindow = SW_SHOWNORMAL;
644 startup.lpTitle = "";
645 startup.lpDesktop = "";
646 startup.dwXCountChars = 0x12121212;
647 startup.dwYCountChars = 0x23232323;
648 startup.dwX = 0x34343434;
649 startup.dwY = 0x45454545;
650 startup.dwXSize = 0x56565656;
651 startup.dwYSize = 0x67676767;
652 startup.dwFillAttribute = 0xA55A;
654 get_file_name(resfile);
655 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
656 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
657 /* wait for child to terminate */
658 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
659 /* child process has changed result file, so let profile functions know about it */
660 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
662 okChildInt("StartupInfoA", "cb", startup.cb);
663 todo_wine okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
664 todo_wine okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
665 okChildInt("StartupInfoA", "dwX", startup.dwX);
666 okChildInt("StartupInfoA", "dwY", startup.dwY);
667 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
668 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
669 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
670 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
671 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
672 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
673 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
675 assert(DeleteFileA(resfile) != 0);
677 /* TODO: test for A/W and W/A and W/W */
680 static void test_CommandLine(void)
682 char buffer[MAX_PATH];
683 PROCESS_INFORMATION info;
684 STARTUPINFOA startup;
686 memset(&startup, 0, sizeof(startup));
687 startup.cb = sizeof(startup);
688 startup.dwFlags = STARTF_USESHOWWINDOW;
689 startup.wShowWindow = SW_SHOWNORMAL;
692 get_file_name(resfile);
693 sprintf(buffer, "%s tests/process.c %s \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);
694 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
695 /* wait for child to terminate */
696 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
697 /* child process has changed result file, so let profile functions know about it */
698 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
700 okChildInt("Arguments", "argcA", 4);
701 okChildString("Arguments", "argvA3", "C:\\Program Files\\my nice app.exe");
702 okChildString("Arguments", "argvA4", NULL);
703 okChildString("Arguments", "CommandLineA", buffer);
705 assert(DeleteFileA(resfile) != 0);
707 memset(&startup, 0, sizeof(startup));
708 startup.cb = sizeof(startup);
709 startup.dwFlags = STARTF_USESHOWWINDOW;
710 startup.wShowWindow = SW_SHOWNORMAL;
713 get_file_name(resfile);
714 sprintf(buffer, "%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", selfname, resfile);
715 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
716 /* wait for child to terminate */
717 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
718 /* child process has changed result file, so let profile functions know about it */
719 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
721 okChildInt("Arguments", "argcA", 6);
722 okChildString("Arguments", "argvA3", "a\"b\\");
723 okChildString("Arguments", "argvA4", "c\"");
724 okChildString("Arguments", "argvA5", "d");
725 okChildString("Arguments", "argvA6", NULL);
726 okChildString("Arguments", "CommandLineA", buffer);
728 assert(DeleteFileA(resfile) != 0);
731 static void test_Directory(void)
733 char buffer[MAX_PATH];
734 PROCESS_INFORMATION info;
735 STARTUPINFOA startup;
736 char windir[MAX_PATH];
738 memset(&startup, 0, sizeof(startup));
739 startup.cb = sizeof(startup);
740 startup.dwFlags = STARTF_USESHOWWINDOW;
741 startup.wShowWindow = SW_SHOWNORMAL;
744 get_file_name(resfile);
745 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
746 GetWindowsDirectoryA( windir, sizeof(windir) );
747 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, windir, &startup, &info), "CreateProcess");
748 /* wait for child to terminate */
749 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
750 /* child process has changed result file, so let profile functions know about it */
751 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
753 okChildIString("Misc", "CurrDirA", windir);
755 assert(DeleteFileA(resfile) != 0);
758 static BOOL is_str_env_drive_dir(const char* str)
760 return str[0] == '=' && str[1] >= 'A' && str[1] <= 'Z' && str[2] == ':' &&
761 str[3] == '=' && str[4] == str[1];
764 /* compared expected child's environment (in gesA) from actual
765 * environment our child got
767 static void cmpEnvironment(const char* gesA)
775 clen = GetPrivateProfileIntA("EnvironmentA", "len", 0, resfile);
777 /* now look each parent env in child */
778 if ((ptrA = gesA) != NULL)
782 for (i = 0; i < clen; i++)
784 sprintf(key, "env%d", i);
785 res = getChildString("EnvironmentA", key);
786 if (strncmp(ptrA, res, MAX_LISTED_ENV_VAR - 1) == 0)
790 ok(found, "Parent-env string %s isn't in child process", ptrA);
792 ptrA += strlen(ptrA) + 1;
796 /* and each child env in parent */
797 for (i = 0; i < clen; i++)
799 sprintf(key, "env%d", i);
800 res = getChildString("EnvironmentA", key);
801 if ((ptrA = gesA) != NULL)
805 if (strncmp(res, ptrA, MAX_LISTED_ENV_VAR - 1) == 0)
807 ptrA += strlen(ptrA) + 1;
809 if (!*ptrA) ptrA = NULL;
812 if (!is_str_env_drive_dir(res))
814 found = ptrA != NULL;
815 ok(found, "Child-env string %s isn't in parent process", res);
817 /* else => should also test we get the right per drive default directory here... */
821 static void test_Environment(void)
823 char buffer[MAX_PATH];
824 PROCESS_INFORMATION info;
825 STARTUPINFOA startup;
826 char child_env[4096];
830 memset(&startup, 0, sizeof(startup));
831 startup.cb = sizeof(startup);
832 startup.dwFlags = STARTF_USESHOWWINDOW;
833 startup.wShowWindow = SW_SHOWNORMAL;
836 get_file_name(resfile);
837 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
838 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");
839 /* wait for child to terminate */
840 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
841 /* child process has changed result file, so let profile functions know about it */
842 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
844 cmpEnvironment(GetEnvironmentStringsA());
846 assert(DeleteFileA(resfile) != 0);
848 memset(&startup, 0, sizeof(startup));
849 startup.cb = sizeof(startup);
850 startup.dwFlags = STARTF_USESHOWWINDOW;
851 startup.wShowWindow = SW_SHOWNORMAL;
854 get_file_name(resfile);
855 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
857 sprintf(ptr, "=%c:=%s", 'C', "C:\\FOO\\BAR");
858 ptr += strlen(ptr) + 1;
859 strcpy(ptr, "PATH=C:\\WINDOWS;C:\\WINDOWS\\SYSTEM;C:\\MY\\OWN\\DIR");
860 ptr += strlen(ptr) + 1;
861 strcpy(ptr, "FOO=BAR");
862 ptr += strlen(ptr) + 1;
863 strcpy(ptr, "BAR=FOOBAR");
864 ptr += strlen(ptr) + 1;
865 /* copy all existing variables except:
867 * - PATH (already set above)
868 * - the directory definitions (=[A-Z]:=)
870 for (env = GetEnvironmentStringsA(); *env; env += strlen(env) + 1)
872 if (strncmp(env, "PATH=", 5) != 0 &&
873 strncmp(env, "WINELOADER=", 11) != 0 &&
874 !is_str_env_drive_dir(env))
877 ptr += strlen(ptr) + 1;
881 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, child_env, NULL, &startup, &info), "CreateProcess");
882 /* wait for child to terminate */
883 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
884 /* child process has changed result file, so let profile functions know about it */
885 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
887 cmpEnvironment(child_env);
890 assert(DeleteFileA(resfile) != 0);
893 static void test_SuspendFlag(void)
895 char buffer[MAX_PATH];
896 PROCESS_INFORMATION info;
897 STARTUPINFOA startup;
900 /* let's start simplistic */
901 memset(&startup, 0, sizeof(startup));
902 startup.cb = sizeof(startup);
903 startup.dwFlags = STARTF_USESHOWWINDOW;
904 startup.wShowWindow = SW_SHOWNORMAL;
906 get_file_name(resfile);
907 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
908 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startup, &info), "CreateProcess");
910 ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running");
912 ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running");
913 ok(ResumeThread(info.hThread) == 1, "Resuming thread");
915 /* wait for child to terminate */
916 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
917 /* child process has changed result file, so let profile functions know about it */
918 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
920 okChildInt("StartupInfoA", "cb", startup.cb);
921 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
922 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
923 okChildInt("StartupInfoA", "dwX", startup.dwX);
924 okChildInt("StartupInfoA", "dwY", startup.dwY);
925 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
926 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
927 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
928 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
929 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
930 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
931 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
933 assert(DeleteFileA(resfile) != 0);
936 static void test_DebuggingFlag(void)
938 char buffer[MAX_PATH];
939 PROCESS_INFORMATION info;
940 STARTUPINFOA startup;
944 /* let's start simplistic */
945 memset(&startup, 0, sizeof(startup));
946 startup.cb = sizeof(startup);
947 startup.dwFlags = STARTF_USESHOWWINDOW;
948 startup.wShowWindow = SW_SHOWNORMAL;
950 get_file_name(resfile);
951 sprintf(buffer, "%s tests/process.c %s", selfname, resfile);
952 ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info), "CreateProcess");
954 /* get all startup events up to the entry point break exception */
957 ok(WaitForDebugEvent(&de, INFINITE), "reading debug event");
958 ContinueDebugEvent(de.dwProcessId, de.dwThreadId, DBG_CONTINUE);
959 if (de.dwDebugEventCode != EXCEPTION_DEBUG_EVENT) dbg++;
960 } while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
962 ok(dbg, "I have seen a debug event");
963 /* wait for child to terminate */
964 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
965 /* child process has changed result file, so let profile functions know about it */
966 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
968 okChildInt("StartupInfoA", "cb", startup.cb);
969 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
970 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
971 okChildInt("StartupInfoA", "dwX", startup.dwX);
972 okChildInt("StartupInfoA", "dwY", startup.dwY);
973 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
974 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
975 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
976 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
977 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
978 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
979 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
981 assert(DeleteFileA(resfile) != 0);
984 static void test_Console(void)
986 char buffer[MAX_PATH];
987 PROCESS_INFORMATION info;
988 STARTUPINFOA startup;
989 SECURITY_ATTRIBUTES sa;
990 CONSOLE_SCREEN_BUFFER_INFO sbi, sbiC;
991 DWORD modeIn, modeOut, modeInC, modeOutC;
992 DWORD cpIn, cpOut, cpInC, cpOutC;
994 HANDLE hChildIn, hChildInInh, hChildOut, hChildOutInh, hParentIn, hParentOut;
995 const char* msg = "This is a std-handle inheritance test.";
998 memset(&startup, 0, sizeof(startup));
999 startup.cb = sizeof(startup);
1000 startup.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
1001 startup.wShowWindow = SW_SHOWNORMAL;
1003 sa.nLength = sizeof(sa);
1004 sa.lpSecurityDescriptor = NULL;
1005 sa.bInheritHandle = TRUE;
1007 startup.hStdInput = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1008 startup.hStdOutput = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1010 /* first, we need to be sure we're attached to a console */
1011 if (startup.hStdInput == INVALID_HANDLE_VALUE || startup.hStdOutput == INVALID_HANDLE_VALUE)
1013 /* we're not attached to a console, let's do it */
1015 startup.hStdInput = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1016 startup.hStdOutput = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1018 /* now verify everything's ok */
1019 ok(startup.hStdInput != INVALID_HANDLE_VALUE, "Opening ConIn");
1020 ok(startup.hStdOutput != INVALID_HANDLE_VALUE, "Opening ConOut");
1021 startup.hStdError = startup.hStdOutput;
1023 ok(GetConsoleScreenBufferInfo(startup.hStdOutput, &sbi), "Getting sb info");
1024 ok(GetConsoleMode(startup.hStdInput, &modeIn) &&
1025 GetConsoleMode(startup.hStdOutput, &modeOut), "Getting console modes");
1026 cpIn = GetConsoleCP();
1027 cpOut = GetConsoleOutputCP();
1029 get_file_name(resfile);
1030 sprintf(buffer, "%s tests/process.c %s console", selfname, resfile);
1031 ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess");
1033 /* wait for child to terminate */
1034 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
1035 /* child process has changed result file, so let profile functions know about it */
1036 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
1038 /* now get the modification the child has made, and resets parents expected values */
1039 ok(GetConsoleScreenBufferInfo(startup.hStdOutput, &sbiC), "Getting sb info");
1040 ok(GetConsoleMode(startup.hStdInput, &modeInC) &&
1041 GetConsoleMode(startup.hStdOutput, &modeOutC), "Getting console modes");
1043 SetConsoleMode(startup.hStdInput, modeIn);
1044 SetConsoleMode(startup.hStdOutput, modeOut);
1046 cpInC = GetConsoleCP();
1047 cpOutC = GetConsoleOutputCP();
1049 SetConsoleOutputCP(cpOut);
1051 okChildInt("StartupInfoA", "cb", startup.cb);
1052 okChildString("StartupInfoA", "lpDesktop", startup.lpDesktop);
1053 okChildString("StartupInfoA", "lpTitle", startup.lpTitle);
1054 okChildInt("StartupInfoA", "dwX", startup.dwX);
1055 okChildInt("StartupInfoA", "dwY", startup.dwY);
1056 okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
1057 okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
1058 okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
1059 okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
1060 okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
1061 okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
1062 okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
1064 /* check child correctly inherited the console */
1065 okChildInt("StartupInfoA", "hStdInput", (DWORD)startup.hStdInput);
1066 okChildInt("StartupInfoA", "hStdOutput", (DWORD)startup.hStdOutput);
1067 okChildInt("StartupInfoA", "hStdError", (DWORD)startup.hStdError);
1068 okChildInt("Console", "SizeX", sbi.dwSize.X);
1069 okChildInt("Console", "SizeY", sbi.dwSize.Y);
1070 okChildInt("Console", "CursorX", sbi.dwCursorPosition.X);
1071 okChildInt("Console", "CursorY", sbi.dwCursorPosition.Y);
1072 okChildInt("Console", "Attributes", sbi.wAttributes);
1073 okChildInt("Console", "winLeft", sbi.srWindow.Left);
1074 okChildInt("Console", "winTop", sbi.srWindow.Top);
1075 okChildInt("Console", "winRight", sbi.srWindow.Right);
1076 okChildInt("Console", "winBottom", sbi.srWindow.Bottom);
1077 okChildInt("Console", "maxWinWidth", sbi.dwMaximumWindowSize.X);
1078 okChildInt("Console", "maxWinHeight", sbi.dwMaximumWindowSize.Y);
1079 okChildInt("Console", "InputCP", cpIn);
1080 okChildInt("Console", "OutputCP", cpOut);
1081 okChildInt("Console", "InputMode", modeIn);
1082 okChildInt("Console", "OutputMode", modeOut);
1084 todo_wine ok(cpInC == 1252, "Wrong console CP (expected 1252 got %ld/%ld)", cpInC, cpIn);
1085 todo_wine ok(cpOutC == 1252, "Wrong console-SB CP (expected 1252 got %ld/%ld)", cpOutC, cpOut);
1086 ok(modeInC == (modeIn ^ 1), "Wrong console mode");
1087 ok(modeOutC == (modeOut ^ 1), "Wrong console-SB mode");
1088 ok(sbiC.dwCursorPosition.X == (sbi.dwCursorPosition.X ^ 1), "Wrong cursor position");
1089 ok(sbiC.dwCursorPosition.Y == (sbi.dwCursorPosition.Y ^ 1), "Wrong cursor position");
1092 assert(DeleteFileA(resfile) != 0);
1094 ok(CreatePipe(&hParentIn, &hChildOut, NULL, 0), "Creating parent-input pipe");
1095 ok(DuplicateHandle(GetCurrentProcess(), hChildOut, GetCurrentProcess(),
1096 &hChildOutInh, 0, TRUE, DUPLICATE_SAME_ACCESS),
1097 "Duplicating as inheritable child-output pipe");
1098 CloseHandle(hChildOut);
1100 ok(CreatePipe(&hChildIn, &hParentOut, NULL, 0), "Creating parent-output pipe");
1101 ok(DuplicateHandle(GetCurrentProcess(), hChildIn, GetCurrentProcess(),
1102 &hChildInInh, 0, TRUE, DUPLICATE_SAME_ACCESS),
1103 "Duplicating as inheritable child-input pipe");
1104 CloseHandle(hChildIn);
1106 memset(&startup, 0, sizeof(startup));
1107 startup.cb = sizeof(startup);
1108 startup.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
1109 startup.wShowWindow = SW_SHOWNORMAL;
1110 startup.hStdInput = hChildInInh;
1111 startup.hStdOutput = hChildOutInh;
1112 startup.hStdError = hChildOutInh;
1114 get_file_name(resfile);
1115 sprintf(buffer, "%s tests/process.c %s stdhandle", selfname, resfile);
1116 ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &startup, &info), "CreateProcess");
1117 ok(CloseHandle(hChildInInh), "Closing handle");
1118 ok(CloseHandle(hChildOutInh), "Closing handle");
1120 msg_len = strlen(msg) + 1;
1121 ok(WriteFile(hParentOut, msg, msg_len, &w, NULL), "Writting to child");
1122 ok(w == msg_len, "Should have written %u bytes, actually wrote %lu", msg_len, w);
1123 memset(buffer, 0, sizeof(buffer));
1124 ok(ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL), "Reading from child");
1125 ok(strcmp(buffer, msg) == 0, "Should have received '%s'", msg);
1127 /* wait for child to terminate */
1128 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");
1129 /* child process has changed result file, so let profile functions know about it */
1130 WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
1132 okChildString("StdHandle", "msg", msg);
1135 assert(DeleteFileA(resfile) != 0);
1141 ok(b, "Basic init of CreateProcess test");
1146 doChild(myARGV[2], (myARGC == 3) ? NULL : myARGV[3]);
1154 test_DebuggingFlag();
1156 /* things that can be tested:
1157 * lookup: check the way program to be executed is searched
1158 * handles: check the handle inheritance stuff (+sec options)
1159 * console: check if console creation parameters work