From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- programs/winetest/main.c | 69 ++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 17 deletions(-)
diff --git a/programs/winetest/main.c b/programs/winetest/main.c index 1611333bf9f..cadf43864dc 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -84,7 +84,6 @@ static const char * const arch_dirs[2] = #error define support for your CPU #endif ; -static const char *current_arch_dir = arch_dirs[sizeof(void*)==8];
/* filters for running only specific tests */ static char **filters; @@ -1125,21 +1124,33 @@ static void create_multiarch_directories(const char* target_dir) report (R_FATAL, "Could not create directory %s (%d)", tmp, GetLastError()); }
-static BOOL init_image(struct winetest_image *image, const char *target_dir) +static BOOL init_image(struct winetest_image *image, const char *path, const char *target_dir) { char* new;
if (multi_arch) { - new = malloc(strlen(target_dir) + strlen(current_arch_dir) + 1); + const char* alt = arch_dirs[!!path ^ (sizeof(void*) == 8)]; + new = malloc(strlen(target_dir) + strlen(alt) + 1); strcpy(new, target_dir); - strcat(new, current_arch_dir); + strcat(new, alt); } else new = strdup(target_dir);
image->target_dir = new; - image->module = NULL; + if (path) + { + image->module = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); + if (!image->module) + { + report (R_FATAL, "Can't enumerate wow64 alternate test files: %d", + GetLastError ()); + return FALSE; + } + } + else + image->module = NULL; image->nr_of_files = image->nr_of_tests = image->nr_of_skips = 0; report (R_STATUS, "Counting tests"); if (!EnumResourceNamesA (image->module, "TESTRES", EnumTestFileProc, (LPARAM)&image->nr_of_files)) @@ -1149,9 +1160,9 @@ static BOOL init_image(struct winetest_image *image, const char *target_dir) return TRUE; }
-static BOOL load_image(struct winetest_image *image, const char *tempdir) +static BOOL load_image(struct winetest_image *image, const char *path, const char *tempdir) { - if (!init_image(image, tempdir)) return FALSE; + if (!init_image(image, path, tempdir)) return FALSE; report (R_STATUS, "Extracting tests"); report (R_PROGRESS, 0, image->nr_of_files); image->nr_of_files = 0; @@ -1170,7 +1181,7 @@ static void dispose_image(struct winetest_image *image) }
static char * -run_tests (char *logname, char *outdir, int *nr_of_skips) +run_tests (char *logname, char *outdir, char *wow64_alt, int *nr_of_skips) { int i; char *strres, *eol, *nextline; @@ -1179,7 +1190,7 @@ run_tests (char *logname, char *outdir, int *nr_of_skips) BOOL newdir; DWORD needed; HMODULE kernel32; - struct winetest_image image; + struct winetest_image image, image_wow64_alt;
/* Get the current PATH only once */ needed = GetEnvironmentVariableA("PATH", NULL, 0); @@ -1266,7 +1277,9 @@ run_tests (char *logname, char *outdir, int *nr_of_skips) pDeactivateActCtx = (void *)GetProcAddress(kernel32, "DeactivateActCtx"); pReleaseActCtx = (void *)GetProcAddress(kernel32, "ReleaseActCtx");
- load_image(&image, tempdir); + load_image (&image, NULL, tempdir); + if (wow64_alt) + load_image (&image_wow64_alt, wow64_alt, tempdir);
FreeLibrary(hmscoree);
@@ -1283,6 +1296,7 @@ run_tests (char *logname, char *outdir, int *nr_of_skips) report (R_PROGRESS, 1, image.nr_of_tests); for (i = 0; i < image.nr_of_files; i++) { struct wine_test *test = image.wine_tests + i; + char* other = NULL; int j;
if (aborting) break; @@ -1291,7 +1305,18 @@ run_tests (char *logname, char *outdir, int *nr_of_skips) /* We need to add the path (to the main dll) to PATH */ append_path(test->maindllpath); } - + if (wow64_alt) + { + for (j = 0; j < image_wow64_alt.nr_of_files; j++) + { + if (!strcmp(test->name, image_wow64_alt.wine_tests[j].name)) + { + other = image_wow64_alt.wine_tests[j].exename; + break; + } + } + } + SetEnvironmentVariableA( "WINETEST_WOW64_ALT", other ); for (j = 0; j < test->subtest_count; j++) { if (aborting) break; if (!run_test (test, test->subtests[j], logfile, tempdir)) @@ -1312,6 +1337,7 @@ run_tests (char *logname, char *outdir, int *nr_of_skips) remove_dir (tempdir); if (nr_of_skips) *nr_of_skips = image.nr_of_skips; dispose_image(&image); + if (wow64_alt) dispose_image (&image_wow64_alt); free(curpath);
return logname; @@ -1355,7 +1381,7 @@ static void extract_only (const char *target_dir) report (R_FATAL, "Could not create directory: %s (%d)", target_dir, GetLastError ()); create_multiarch_directories( target_dir );
- if (!init_image(&image, target_dir)) return; + if (!init_image(&image, NULL, target_dir)) return;
report (R_STATUS, "Extracting tests"); report (R_PROGRESS, 0, image.nr_of_files); @@ -1389,19 +1415,22 @@ usage (void) " -S URL URL to submit the results to\n" " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n" " -u URL include TestBot URL in the report\n" -" -x DIR Extract tests to DIR (default: .\wct) and exit\n"); +" -x DIR Extract tests to DIR (default: .\wct) and exit\n" +" -w EXE Extend tests with another winetest executable.\n" +" (this exec must be 64bit, while [EXE] exec must be 32bit)\n"); }
int __cdecl main( int argc, char *argv[] ) { BOOL (WINAPI *pIsWow64Process)(HANDLE hProcess, PBOOL Wow64Process); - char *logname = NULL, *outdir = NULL; + char *logname = NULL, *outdir = NULL, *wow64_alt = NULL; const char *extract = NULL; const char *cp, *submit = NULL, *submiturl = NULL; int reset_env = 1; int poweroff = 0; int interactive = 1; int prev_crash_dialog = 0; + DWORD bintype; int i;
InitCommonControls(); @@ -1517,6 +1546,12 @@ int __cdecl main( int argc, char *argv[] ) break; case 'w': multi_arch = 1; + wow64_alt = argv[++i]; + if (sizeof(void*) != 8 || !GetBinaryTypeA(wow64_alt, &bintype) || bintype != SCS_32BIT_BINARY) + { + usage(); + exit(2); + } break; default: report (R_ERROR, "invalid option: -%c", argv[i][1]); @@ -1566,7 +1601,7 @@ int __cdecl main( int argc, char *argv[] )
if (nb_filters && !exclude_tests) { - run_tests( logname, outdir, NULL ); + run_tests( logname, outdir, wow64_alt, NULL ); exit( failures ? 3 : 0 ); }
@@ -1594,7 +1629,7 @@ int __cdecl main( int argc, char *argv[] )
if (!logname) { int nr_of_skips; - logname = run_tests (NULL, outdir, &nr_of_skips); + logname = run_tests (NULL, outdir, wow64_alt, &nr_of_skips); if (aborting) { DeleteFileA(logname); exit (0); @@ -1616,7 +1651,7 @@ int __cdecl main( int argc, char *argv[] ) } else { - run_tests ( logname, outdir, NULL ); + run_tests ( logname, outdir, wow64_alt, NULL ); report (R_STATUS, "Finished - %u failures", failures); } if (prev_crash_dialog) restore_crash_dialog( prev_crash_dialog );