kernel32/tests: Check if CreateProcess() resets STARTUPINFO/PROCESS_INFORMATION.

Our test framework depends on CreateProcess() initializing the
hProcess field in case of a failure.  The process tests depend on it
not modifying the STARTUPINFO fields.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2020-02-24 05:04:00 +01:00 committed by Alexandre Julliard
parent 1d8ee10064
commit 8adca32727
1 changed files with 21 additions and 5 deletions

View File

@ -895,10 +895,31 @@ static void test_CommandLine(void)
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
/* failure case */
strcpy(buffer, "\"t:\\NotADir\\NotAFile.exe\"");
memset(&info, 0xa, sizeof(info));
ok(!CreateProcessA(buffer, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess unexpectedly succeeded\n");
/* Check that the effective STARTUPINFOA parameters are not modified */
ok(startup.cb == sizeof(startup), "unexpected cb %d\n", startup.cb);
ok(startup.lpDesktop == NULL, "lpDesktop is not NULL\n");
ok(startup.lpTitle == NULL, "lpTitle is not NULL\n");
ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04x\n", startup.dwFlags);
ok(startup.wShowWindow == SW_SHOWNORMAL, "unexpected wShowWindow %d\n", startup.wShowWindow);
ok(!info.hProcess, "unexpected hProcess %p\n", info.hProcess);
ok(!info.hThread, "unexpected hThread %p\n", info.hThread);
ok(!info.dwProcessId, "unexpected dwProcessId %04x\n", info.dwProcessId);
ok(!info.dwThreadId, "unexpected dwThreadId %04x\n", info.dwThreadId);
/* the basics */
get_file_name(resfile);
sprintf(buffer, "\"%s\" process dump \"%s\" \"C:\\Program Files\\my nice app.exe\" \"\"\"\"", selfname, resfile);
ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
/* Check that the effective STARTUPINFOA parameters are not modified */
ok(startup.cb == sizeof(startup), "unexpected cb %d\n", startup.cb);
ok(startup.lpDesktop == NULL, "lpDesktop is not NULL\n");
ok(startup.lpTitle == NULL, "lpTitle is not NULL\n");
ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04x\n", startup.dwFlags);
ok(startup.wShowWindow == SW_SHOWNORMAL, "unexpected wShowWindow %d\n", startup.wShowWindow);
/* wait for child to terminate */
ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
/* child process has changed result file, so let profile functions know about it */
@ -914,11 +935,6 @@ static void test_CommandLine(void)
release_memory();
DeleteFileA(resfile);
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
/* test main()'s quotes handling */
get_file_name(resfile);
sprintf(buffer, "\"%s\" process dump \"%s\" \"a\\\"b\\\\\" c\\\" d", selfname, resfile);