[FUSION_WINETEST] Sync with Wine Staging 2.16. CORE-13762
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 17 Sep 2017 12:34:03 +0000 (12:34 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 17 Sep 2017 12:34:03 +0000 (12:34 +0000)
svn path=/trunk/; revision=75870

rostests/winetests/fusion/asmenum.c
rostests/winetests/fusion/asmname.c

index e51ef99..49caca5 100644 (file)
@@ -225,79 +225,80 @@ static void test_CreateAssemblyEnum(void)
 typedef struct _tagASMNAME
 {
     struct list entry;
-    LPSTR data;
+    char data[1];
 } ASMNAME;
 
-static BOOL enum_gac_assemblies(struct list *assemblies, int depth, LPSTR path)
+static void enum_gac_assembly_dirs(struct list *assemblies, const char *parent, char path[MAX_PATH])
 {
+    static const char format[] = "%s, Version=%s, Culture=%s, PublicKeyToken=%s";
     WIN32_FIND_DATAA ffd;
-    CHAR buf[MAX_PATH];
-    CHAR disp[MAX_PATH];
     ASMNAME *name;
     HANDLE hfind;
-    LPSTR ptr;
-
-    static CHAR parent[MAX_PATH];
+    int len;
+    char *ptr, *end = path + strlen( path );
 
-    sprintf(buf, "%s\\*", path);
-    hfind = FindFirstFileA(buf, &ffd);
-    if (hfind == INVALID_HANDLE_VALUE)
-        return FALSE;
+    lstrcpynA( end, "\\*", path + MAX_PATH - end );
+    hfind = FindFirstFileA(path, &ffd);
+    if (hfind == INVALID_HANDLE_VALUE) return;
+    end++;
 
     do
     {
-        if (!lstrcmpA(ffd.cFileName, ".") || !lstrcmpA(ffd.cFileName, ".."))
-            continue;
+        char culture[MAX_PATH];
+
+        if (!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
 
-        if (depth == 0)
+        *end = 0;
+        /* Directories with no dll or exe will not be enumerated */
+        snprintf(end, path + MAX_PATH - end, "%s\\%s.dll", ffd.cFileName, parent);
+        if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES)
         {
-            lstrcpyA(parent, ffd.cFileName);
+            snprintf(end, path + MAX_PATH - end, "%s\\%s.exe", ffd.cFileName, parent);
+            if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) continue;
         }
-        else if (depth == 1)
+
+        if (!(ptr = strchr(ffd.cFileName, '_'))) continue;
+        *ptr++ = 0;
+
+        if (*ptr != '_')
         {
-            char culture[MAX_PATH];
-            char dll[MAX_PATH], exe[MAX_PATH];
+            lstrcpyA(culture, ptr);
+            *strchr(culture, '_') = 0;
+        }
+        else
+            lstrcpyA(culture, "neutral");
 
-            /* Directories with no dll or exe will not be enumerated */
-            sprintf(dll, "%s\\%s\\%s.dll", path, ffd.cFileName, parent);
-            sprintf(exe, "%s\\%s\\%s.exe", path, ffd.cFileName, parent);
-            if (GetFileAttributesA(dll) == INVALID_FILE_ATTRIBUTES &&
-                GetFileAttributesA(exe) == INVALID_FILE_ATTRIBUTES)
-                continue;
+        ptr = strchr(ptr, '_');
+        ptr++;
+        len = sizeof(format) + strlen(parent) + strlen(ffd.cFileName) + strlen(culture) + strlen(ptr);
 
-            ptr = strstr(ffd.cFileName, "_");
-            *ptr = '\0';
-            ptr++;
+        name = HeapAlloc(GetProcessHeap(), 0, offsetof( ASMNAME, data[len] ));
+        sprintf( name->data, format, parent, ffd.cFileName, culture, ptr);
+        list_add_tail(assemblies, &name->entry);
+    } while (FindNextFileA(hfind, &ffd) != 0);
 
-            if (*ptr != '_')
-            {
-                lstrcpyA(culture, ptr);
-                *strstr(culture, "_") = '\0';
-            }
-            else
-                lstrcpyA(culture, "neutral");
-
-            ptr = strchr(ptr, '_');
-            ptr++;
-            sprintf(buf, ", Version=%s, Culture=%s, PublicKeyToken=%s",
-                    ffd.cFileName, culture, ptr);
-            lstrcpyA(disp, parent);
-            lstrcatA(disp, buf);
-
-            name = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME));
-            name->data = HeapAlloc(GetProcessHeap(), 0, lstrlenA(disp) + 1);
-            lstrcpyA(name->data, disp);
-            list_add_tail(assemblies, &name->entry);
-
-            continue;
-        }
+    FindClose(hfind);
+}
 
-        sprintf(buf, "%s\\%s", path, ffd.cFileName);
-        enum_gac_assemblies(assemblies, depth + 1, buf);
+static void enum_gac_assemblies(struct list *assemblies, char path[MAX_PATH])
+{
+    WIN32_FIND_DATAA ffd;
+    HANDLE hfind;
+    char *end = path + strlen( path );
+
+    lstrcpynA( end, "\\*", path + MAX_PATH - end );
+    hfind = FindFirstFileA(path, &ffd);
+    if (hfind == INVALID_HANDLE_VALUE) return;
+    end++;
+
+    do
+    {
+        if (!strcmp(ffd.cFileName, ".") || !strcmp(ffd.cFileName, "..")) continue;
+        lstrcpynA( end, ffd.cFileName, path + MAX_PATH - end );
+        enum_gac_assembly_dirs( assemblies, ffd.cFileName, path );
     } while (FindNextFileA(hfind, &ffd) != 0);
 
     FindClose(hfind);
-    return TRUE;
 }
 
 static void test_enumerate(void)
@@ -319,18 +320,18 @@ static void test_enumerate(void)
 
     to_multibyte(path, buf);
     lstrcatA(path, "_32");
-    enum_gac_assemblies(&assemblies, 0, path);
+    enum_gac_assemblies(&assemblies, path);
 
     to_multibyte(path, buf);
     lstrcatA(path, "_64");
-    enum_gac_assemblies(&assemblies, 0, path);
+    enum_gac_assemblies(&assemblies, path);
 
     to_multibyte(path, buf);
     lstrcatA(path, "_MSIL");
-    enum_gac_assemblies(&assemblies, 0, path);
+    enum_gac_assemblies(&assemblies, path);
 
     to_multibyte(path, buf);
-    enum_gac_assemblies(&assemblies, 0, path);
+    enum_gac_assemblies(&assemblies, path);
 
     asmenum = NULL;
     hr = pCreateAssemblyEnum(&asmenum, NULL, NULL, ASM_CACHE_GAC, NULL);
@@ -353,7 +354,6 @@ static void test_enumerate(void)
                 found = TRUE;
 
                 list_remove(&asmname->entry);
-                HeapFree(GetProcessHeap(), 0, asmname->data);
                 HeapFree(GetProcessHeap(), 0, asmname);
                 break;
             }
@@ -377,7 +377,6 @@ static void test_enumerate(void)
         ok(FALSE, "Assembly not enumerated: %s\n", asmname->data);
 
         list_remove(&asmname->entry);
-        HeapFree(GetProcessHeap(), 0, asmname->data);
         HeapFree(GetProcessHeap(), 0, asmname);
     }
 
index 7269df0..ee4fbc4 100644 (file)
@@ -360,16 +360,14 @@ static void test_assembly_name_props_line(IAssemblyName *name,
     DWORD i, size;
     WCHAR expect[MAX_PATH];
     WCHAR str[MAX_PATH];
-    CHAR val[MAX_PATH];
 
     for (i = 0; i < ASM_NAME_MAX_PARAMS; i++)
     {
         to_widechar(expect, vals[i].val);
 
         size = MAX_PATH;
-        ZeroMemory(str, MAX_PATH);
+        memset( str, 0xcc, sizeof(str) );
         hr = IAssemblyName_GetProperty(name, i, str, &size);
-        to_multibyte(val, str);
 
         ok(hr == vals[i].hr ||
            broken(i >= ASM_NAME_CONFIG_MASK && hr == E_INVALIDARG) || /* .NET 1.1 */
@@ -377,11 +375,15 @@ static void test_assembly_name_props_line(IAssemblyName *name,
            "%d: prop %d: Expected %08x, got %08x\n", line, i, vals[i].hr, hr);
         if (hr != E_INVALIDARG)
         {
-            if (i == ASM_NAME_PUBLIC_KEY_TOKEN)
-                ok(!memcmp(vals[i].val, str, size), "Expected a correct ASM_NAME_PUBLIC_KEY_TOKEN\n");
-            else
-                ok(!lstrcmpA(vals[i].val, val), "%d: prop %d: Expected \"%s\", got \"%s\"\n", line, i, vals[i].val, val);
             ok(size == vals[i].size, "%d: prop %d: Expected %d, got %d\n", line, i, vals[i].size, size);
+            if (size && size != MAX_PATH)
+            {
+                if (i != ASM_NAME_NAME && i != ASM_NAME_CULTURE)
+                    ok( !memcmp( vals[i].val, str, size ), "%d: prop %d: wrong value\n", line, i );
+                else
+                    ok( !lstrcmpW( expect, str ), "%d: prop %d: Expected %s, got %s\n",
+                        line, i, wine_dbgstr_w(expect), wine_dbgstr_w(str) );
+            }
         }
     }
 }