process.c

来自「Wine-20031016」· C语言 代码 · 共 1,201 行 · 第 1/4 页

C
1,201 行
字号
    okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);    okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);    okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);    okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);    release_memory();    assert(DeleteFileA(resfile) != 0);    /* not so simplistic now */    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    startup.lpTitle = "";    startup.lpDesktop = "I'm the desktop string";    startup.dwXCountChars = 0x12121212;    startup.dwYCountChars = 0x23232323;    startup.dwX = 0x34343434;    startup.dwY = 0x45454545;    startup.dwXSize = 0x56565656;    startup.dwYSize = 0x67676767;    startup.dwFillAttribute = 0xA55A;    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s", selfname, resfile);    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);    okChildInt("StartupInfoA", "cb", startup.cb);    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);    okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);    okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);    okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);    okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);    okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);    okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);    release_memory();    assert(DeleteFileA(resfile) != 0);    /* not so simplistic now */    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    startup.lpTitle = "";    startup.lpDesktop = "";    startup.dwXCountChars = 0x12121212;    startup.dwYCountChars = 0x23232323;    startup.dwX = 0x34343434;    startup.dwY = 0x45454545;    startup.dwXSize = 0x56565656;    startup.dwYSize = 0x67676767;    startup.dwFillAttribute = 0xA55A;    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s", selfname, resfile);    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);    okChildInt("StartupInfoA", "cb", startup.cb);    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);    okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);    okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);    okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);    okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);    okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);    okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);    release_memory();    assert(DeleteFileA(resfile) != 0);    /* TODO: test for A/W and W/A and W/W */}static void test_CommandLine(void){    char                buffer[MAX_PATH];    PROCESS_INFORMATION	info;    STARTUPINFOA	startup;    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    /* the basics */    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);    okChildInt("Arguments", "argcA", 4);    okChildString("Arguments", "argvA3", "C:\\Program Files\\my nice app.exe");    okChildString("Arguments", "argvA4", NULL);    okChildString("Arguments", "CommandLineA", buffer);    release_memory();    assert(DeleteFileA(resfile) != 0);    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    /* from Frangois */    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s \"a\\\"b\\\\\" c\\\" d", selfname, resfile);    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);    okChildInt("Arguments", "argcA", 6);    okChildString("Arguments", "argvA3", "a\"b\\");    okChildString("Arguments", "argvA4", "c\"");    okChildString("Arguments", "argvA5", "d");    okChildString("Arguments", "argvA6", NULL);    okChildString("Arguments", "CommandLineA", buffer);    release_memory();    assert(DeleteFileA(resfile) != 0);}static void test_Directory(void){    char                buffer[MAX_PATH];    PROCESS_INFORMATION	info;    STARTUPINFOA	startup;    char windir[MAX_PATH];    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    /* the basics */    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s", selfname, resfile);    GetWindowsDirectoryA( windir, sizeof(windir) );    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, windir, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);    okChildIString("Misc", "CurrDirA", windir);    release_memory();    assert(DeleteFileA(resfile) != 0);}static BOOL is_str_env_drive_dir(const char* str){    return str[0] == '=' && str[1] >= 'A' && str[1] <= 'Z' && str[2] == ':' &&        str[3] == '=' && str[4] == str[1];}/* compared expected child's environment (in gesA) from actual * environment our child got */static void cmpEnvironment(const char* gesA){    int                 i, clen;    const char*         ptrA;    char*               res;    char                key[32];    BOOL                found;    clen = GetPrivateProfileIntA("EnvironmentA", "len", 0, resfile);        /* now look each parent env in child */    if ((ptrA = gesA) != NULL)    {        while (*ptrA)        {            for (i = 0; i < clen; i++)            {                sprintf(key, "env%d", i);                res = getChildString("EnvironmentA", key);                if (strncmp(ptrA, res, MAX_LISTED_ENV_VAR - 1) == 0)                    break;            }            found = i < clen;            ok(found, "Parent-env string %s isn't in child process", ptrA);                        ptrA += strlen(ptrA) + 1;            release_memory();        }    }    /* and each child env in parent */    for (i = 0; i < clen; i++)    {        sprintf(key, "env%d", i);        res = getChildString("EnvironmentA", key);        if ((ptrA = gesA) != NULL)        {            while (*ptrA)            {                if (strncmp(res, ptrA, MAX_LISTED_ENV_VAR - 1) == 0)                    break;                ptrA += strlen(ptrA) + 1;            }            if (!*ptrA) ptrA = NULL;        }        if (!is_str_env_drive_dir(res))        {            found = ptrA != NULL;            ok(found, "Child-env string %s isn't in parent process", res);        }        /* else => should also test we get the right per drive default directory here... */    }}static void test_Environment(void){    char                buffer[MAX_PATH];    PROCESS_INFORMATION	info;    STARTUPINFOA	startup;    char                child_env[4096];    char*               ptr;    char*               env;    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    /* the basics */    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s", selfname, resfile);    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);        cmpEnvironment(GetEnvironmentStringsA());    release_memory();    assert(DeleteFileA(resfile) != 0);    memset(&startup, 0, sizeof(startup));    startup.cb = sizeof(startup);    startup.dwFlags = STARTF_USESHOWWINDOW;    startup.wShowWindow = SW_SHOWNORMAL;    /* the basics */    get_file_name(resfile);    sprintf(buffer, "%s tests/process.c %s", selfname, resfile);    ptr = child_env;    sprintf(ptr, "=%c:=%s", 'C', "C:\\FOO\\BAR");    ptr += strlen(ptr) + 1;    strcpy(ptr, "PATH=C:\\WINDOWS;C:\\WINDOWS\\SYSTEM;C:\\MY\\OWN\\DIR");    ptr += strlen(ptr) + 1;    strcpy(ptr, "FOO=BAR");    ptr += strlen(ptr) + 1;    strcpy(ptr, "BAR=FOOBAR");    ptr += strlen(ptr) + 1;    /* copy all existing variables except:     * - WINELOADER     * - PATH (already set above)     * - the directory definitions (=[A-Z]:=)     */    for (env = GetEnvironmentStringsA(); *env; env += strlen(env) + 1)    {        if (strncmp(env, "PATH=", 5) != 0 &&            strncmp(env, "WINELOADER=", 11) != 0 &&            !is_str_env_drive_dir(env))        {            strcpy(ptr, env);            ptr += strlen(ptr) + 1;        }    }    *ptr = '\0';    ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, child_env, NULL, &startup, &info), "CreateProcess");    /* wait for child to terminate */    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination");    /* child process has changed result file, so let profile functions know about it */    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);        cmpEnvironment(child_env);    release_memory();    assert(DeleteFileA(resfile) != 0);}static  void    test_SuspendFlag(void){

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?