Alexandre Julliard : kernel32/tests: Build the dll path in the create_test_dll helper function.

Alexandre Julliard julliard at winehq.org
Wed Dec 27 14:46:15 CST 2017


Module: wine
Branch: master
Commit: c1487e49383242d81497d88ee2d942d3c39b3436
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c1487e49383242d81497d88ee2d942d3c39b3436

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Dec 27 18:36:34 2017 +0100

kernel32/tests: Build the dll path in the create_test_dll helper function.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/loader.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 0dd37cc..b320af7 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -164,13 +164,18 @@ static const char filler[0x1000];
 static const char section_data[0x10] = "section data";
 
 static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
-                              const IMAGE_NT_HEADERS *nt_header, const char *dll_name )
+                              const IMAGE_NT_HEADERS *nt_header, char dll_name[MAX_PATH] )
 {
+    char temp_path[MAX_PATH];
     DWORD dummy, size, file_align;
     HANDLE hfile;
     BOOL ret;
 
+    GetTempPathA(MAX_PATH, temp_path);
+    GetTempFileNameA(temp_path, "ldr", 0, dll_name);
+
     hfile = CreateFileA(dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0);
+    ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %u\n", dll_name, GetLastError() );
     if (hfile == INVALID_HANDLE_VALUE) return 0;
 
     SetLastError(0xdeadbeef);
@@ -369,18 +374,13 @@ static void query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
 /* helper to test image section mapping */
 static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, int line )
 {
-    char temp_path[MAX_PATH];
     char dll_name[MAX_PATH];
     LARGE_INTEGER size;
     HANDLE file, map;
     NTSTATUS status;
     ULONG file_size;
 
-    GetTempPathA(MAX_PATH, temp_path);
-    GetTempFileNameA(temp_path, "ldr", 0, dll_name);
-
     file_size = create_test_dll( &dos_header, sizeof(dos_header), nt_header, dll_name );
-    ok( file_size, "could not create %s\n", dll_name);
 
     file = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
@@ -549,7 +549,6 @@ static void test_Loader(void)
     DWORD file_size;
     HANDLE h;
     HMODULE hlib, hlib_as_data_file;
-    char temp_path[MAX_PATH];
     char dll_name[MAX_PATH];
     SIZE_T size;
     BOOL ret;
@@ -560,12 +559,8 @@ static void test_Loader(void)
     /* prevent displaying of the "Unable to load this DLL" message box */
     SetErrorMode(SEM_FAILCRITICALERRORS);
 
-    GetTempPathA(MAX_PATH, temp_path);
-
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
     {
-        GetTempFileNameA(temp_path, "ldr", 0, dll_name);
-
         nt_header = nt_header_template;
         nt_header.FileHeader.NumberOfSections = td[i].number_of_sections;
         nt_header.FileHeader.SizeOfOptionalHeader = td[i].size_of_optional_header;
@@ -576,11 +571,6 @@ static void test_Loader(void)
         nt_header.OptionalHeader.SizeOfHeaders = td[i].size_of_headers;
 
         file_size = create_test_dll( &dos_header, td[i].size_of_dos_header, &nt_header, dll_name );
-        if (!file_size)
-        {
-            ok(0, "could not create %s\n", dll_name);
-            break;
-        }
 
         SetLastError(0xdeadbeef);
         hlib = LoadLibraryA(dll_name);




More information about the wine-cvs mailing list