From e4ffdbb8a7145caf169571eb6e8407b05f443b75 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sun, 15 Jan 2017 11:51:06 +0000 Subject: [PATCH] [NTDLL_APITEST] -Create a copy of the test in testdata and add along three empty files: ntdll_apitest.exe.local, shell32.dll and test.dll. Make the test start the subprocess from testdata to avoid any kind of interference of the .local to all the other tests. The empty dlls are needed there because there is no way to rename the files while adding them to the cab file like we do with NAME_ON_CD and creating them at runtime is not reliable as caching can cause random failures. svn path=/trunk/; revision=73554 --- rostests/apitests/ntdll/CMakeLists.txt | 5 ++ ...RtlDosApplyFileIsolationRedirection_Ustr.c | 64 ++++++++----------- .../apitests/ntdll/ntdll_apitest.exe.local | 0 rostests/apitests/ntdll/shell32.dll | 0 rostests/apitests/ntdll/test.dll | 0 5 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 rostests/apitests/ntdll/ntdll_apitest.exe.local create mode 100644 rostests/apitests/ntdll/shell32.dll create mode 100644 rostests/apitests/ntdll/test.dll diff --git a/rostests/apitests/ntdll/CMakeLists.txt b/rostests/apitests/ntdll/CMakeLists.txt index da8f158e323..dc80b5c436e 100644 --- a/rostests/apitests/ntdll/CMakeLists.txt +++ b/rostests/apitests/ntdll/CMakeLists.txt @@ -64,3 +64,8 @@ if(NOT MSVC) endif() add_rostests_file(TARGET ntdll_apitest) +add_rostests_file(TARGET ntdll_apitest SUBDIR testdata) +# These are empty files +add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/ntdll_apitest.exe.local" SUBDIR testdata) +add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/shell32.dll" SUBDIR testdata) +add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/test.dll" SUBDIR testdata) diff --git a/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c b/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c index e215b6e5301..9a77f042963 100644 --- a/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c +++ b/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c @@ -41,7 +41,6 @@ struct test_data Tests[] = /* But redirecting gdiplus from a different directory doesn't work */ {__LINE__, STATUS_SXS_KEY_NOT_FOUND, L"c:\\GDIPLUS.DLL", NULL}, {__LINE__, STATUS_SXS_KEY_NOT_FOUND, L"c:\\comctl32.DLL", NULL}, -#if 0 /* Redirection based on .local */ {__LINE__, STATUS_SUCCESS, L"test", EXPECT_IN_SAME_DIR}, {__LINE__, STATUS_SUCCESS, L"test.dll", EXPECT_IN_SAME_DIR}, @@ -50,7 +49,6 @@ struct test_data Tests[] = {__LINE__, STATUS_SUCCESS, L"shell32", EXPECT_IN_SAME_DIR}, {__LINE__, STATUS_SUCCESS, L"shell32.dll", EXPECT_IN_SAME_DIR}, {__LINE__, STATUS_SUCCESS, L"c:\\shell32.dll", EXPECT_IN_SAME_DIR} -#endif }; void TestRedirection(void) @@ -125,39 +123,33 @@ void TestRedirection(void) START_TEST(RtlDosApplyFileIsolationRedirection_Ustr) { -#if 0 - WCHAR TestPath[MAX_PATH]; - WCHAR* separator; - STARTUPINFOW si = { sizeof(si) }; - PROCESS_INFORMATION pi; - BOOL created; - HANDLE file; + int argc; + char **test_argv; + argc = winetest_get_mainargs( &test_argv ); + if (argc >= 3) + { + TestRedirection(); + } + else + { + WCHAR TestPath[MAX_PATH]; + WCHAR* separator; + STARTUPINFOW si = { sizeof(si) }; + PROCESS_INFORMATION pi; + BOOL created; - /* Create .local files */ - GetModuleFileNameW(NULL, TestPath, MAX_PATH); - - wcscat(TestPath, L".local"); - file = CreateFileW(TestPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING , NULL); - CloseHandle(file); - separator = wcsrchr(TestPath, L'\\'); - separator++; - wcscpy(separator, L"test.dll"); - file = CreateFileW(TestPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING , NULL); - CloseHandle(file); - wcscpy(separator, L"shell32.dll"); - file = CreateFileW(TestPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING , NULL); - CloseHandle(file); - *separator = 0; -#endif - TestRedirection(); -#if 0 - /*Cleanup*/ - wcscpy(separator, L"test.dll"); - DeleteFileW(TestPath); - wcscpy(separator, L"shell32.dll"); - DeleteFileW(TestPath); - GetModuleFileNameW(NULL, TestPath, MAX_PATH); - wcscat(TestPath, L".local"); - DeleteFileW(TestPath); -#endif + GetModuleFileNameW(NULL, TestPath, MAX_PATH); + separator = wcsrchr(TestPath, L'\\'); + separator++; + wcscpy(separator, L"testdata\\ntdll_apitest.exe RtlDosApplyFileIsolationRedirection_Ustr DoTest"); + + created = CreateProcessW(NULL, TestPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); + ok(created, "Expected CreateProcess to succeed\n"); + if (created) + { + winetest_wait_child_process(pi.hProcess); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + } + } } \ No newline at end of file diff --git a/rostests/apitests/ntdll/ntdll_apitest.exe.local b/rostests/apitests/ntdll/ntdll_apitest.exe.local new file mode 100644 index 00000000000..e69de29bb2d diff --git a/rostests/apitests/ntdll/shell32.dll b/rostests/apitests/ntdll/shell32.dll new file mode 100644 index 00000000000..e69de29bb2d diff --git a/rostests/apitests/ntdll/test.dll b/rostests/apitests/ntdll/test.dll new file mode 100644 index 00000000000..e69de29bb2d