From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/msvcrt/tests/environ.c | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
diff --git a/dlls/msvcrt/tests/environ.c b/dlls/msvcrt/tests/environ.c index f14764ea5a0..c0a392f9f9d 100644 --- a/dlls/msvcrt/tests/environ.c +++ b/dlls/msvcrt/tests/environ.c @@ -393,12 +393,75 @@ static void test_environment_manipulation(void) ok( count == env_get_entry_countA( *p_environ ), "Unexpected modification of _environ[]\n" ); }
+static void test_child_env(char** argv) +{ + static char env[4096]; + STARTUPINFOA si = {sizeof(si)}; + PROCESS_INFORMATION pi; + char tmp[1024]; + BOOL ret; + char *ptr; + WCHAR *wptr; + + ptr = env; +#define PUSHA( x, y ) do { if (y) { strcpy( ptr, (x) ); ptr += strlen( x ); *ptr++ = '='; strcpy( ptr, (y) ); ptr += strlen( y ) + 1; } } while (0) +#define PUSHENVA( x ) PUSHA( ( x ), getenv( x )) + PUSHA( "__winetest_child_dog", "bark" ); + PUSHA( "__winetest_child_cat", "meow" ); + PUSHENVA( "WINETEST_COLOR" ); + *ptr = '\0'; +#undef PUSHA +#undef PUSHENVA + + snprintf( tmp, sizeof(tmp), "%s %s create", argv[0], argv[1] ); + ret = CreateProcessA( NULL, tmp, NULL, NULL, FALSE, 0, env, NULL, &si, &pi ); + ok( ret, "Couldn't create child process %s\n", tmp ); + winetest_wait_child_process( pi.hProcess ); + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread); + + wptr = (void *)env; +#define PUSHW( x, y ) do { if (y) { wcscpy( wptr, (x) ); wptr += wcslen( x ); *wptr++ = L'='; wcscpy( wptr, (y) ); wptr += wcslen( y ) + 1; } } while (0) +#define PUSHENVW( x ) PUSHW( ( x ), _wgetenv( x )) + PUSHW( L"__winetest_child_dog", L"bark" ); + PUSHW( L"__winetest_child_cat", L"meow" ); + PUSHW( L"__winetest_child_\u03b1", L"\u03b2" ); /* alpha = beta */ + PUSHENVW( L"WINETEST_COLOR" ); + *wptr = L'\0'; +#undef PUSHW +#undef PUSHENVW + + snprintf( tmp, sizeof(tmp), "%s %s create /unicode", argv[0], argv[1] ); + ret = CreateProcessA( NULL, tmp, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, env, NULL, &si, &pi ); + ok( ret, "Couldn't create child process %s\n", tmp ); + winetest_wait_child_process( pi.hProcess ); + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); +} + START_TEST(environ) { + char **argv; + int argc; + init();
+ argc = winetest_get_mainargs( &argv ); + if (argc >= 3 && !strcmp( argv[2], "create" )) + { + ok( getenv( "__winetest_child_dog" ) && !strcmp( getenv( "__winetest_child_dog" ), "bark" ), + "Couldn't find env var\n" ); + if (argc >= 4) /* with unicode */ + { + ok( _wgetenv( L"__winetest_child_\u03b1" ) && !wcscmp( _wgetenv(L"__winetest_child_\u03b1" ), L"\u03b2" ), + "Couldn't find alpha\n" ); + } + return; + } + test__environ(); test__wenviron(); test_environment_manipulation(); + test_child_env(argv); test_system(); }