wininet: Moved WORKREQ_HTTPENDREQUESTW out of WORKREQUEST.
[wine.git] / programs / winetest / main.c
blob427b6b47acacf8bd0ad183bcb2659298b1036b37
1 /*
2 * Wine Conformance Test EXE
4 * Copyright 2003, 2004 Jakob Eriksson (for Solid Form Sweden AB)
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2003 Ferenc Wagner
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * This program is dedicated to Anna Lindh,
23 * Swedish Minister of Foreign Affairs.
24 * Anna was murdered September 11, 2003.
28 #include "config.h"
29 #include "wine/port.h"
31 #define COBJMACROS
32 #include <stdio.h>
33 #include <assert.h>
34 #include <windows.h>
35 #include <mshtml.h>
37 #include "winetest.h"
38 #include "resource.h"
40 /* Don't submit the results if more than SKIP_LIMIT tests have been skipped */
41 #define SKIP_LIMIT 10
43 /* Don't submit the results if more than FAILURES_LIMIT tests have failed */
44 #define FAILURES_LIMIT 50
46 struct wine_test
48 char *name;
49 int subtest_count;
50 char **subtests;
51 char *exename;
52 char *maindllpath;
55 char *tag = NULL;
56 char *description = NULL;
57 char *url = NULL;
58 char *email = NULL;
59 BOOL aborting = FALSE;
60 static struct wine_test *wine_tests;
61 static int nr_of_files, nr_of_tests, nr_of_skips;
62 static int nr_native_dlls;
63 static const char whitespace[] = " \t\r\n";
64 static const char testexe[] = "_test.exe";
65 static char build_id[64];
66 static BOOL is_wow64;
67 static int failures;
69 /* filters for running only specific tests */
70 static char *filters[64];
71 static unsigned int nb_filters = 0;
72 static BOOL exclude_tests = FALSE;
74 /* Needed to check for .NET dlls */
75 static HMODULE hmscoree;
76 static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE *);
78 /* For SxS DLLs e.g. msvcr90 */
79 static HANDLE (WINAPI *pCreateActCtxA)(PACTCTXA);
80 static BOOL (WINAPI *pActivateActCtx)(HANDLE, ULONG_PTR *);
81 static BOOL (WINAPI *pDeactivateActCtx)(DWORD, ULONG_PTR);
82 static void (WINAPI *pReleaseActCtx)(HANDLE);
84 /* To store the current PATH setting (related to .NET only provided dlls) */
85 static char *curpath;
87 /* check if test is being filtered out */
88 static BOOL test_filtered_out( LPCSTR module, LPCSTR testname )
90 char *p, dllname[MAX_PATH];
91 unsigned int i, len;
93 strcpy( dllname, module );
94 CharLowerA( dllname );
95 p = strstr( dllname, testexe );
96 if (p) *p = 0;
97 len = strlen(dllname);
99 if (!nb_filters) return exclude_tests;
100 for (i = 0; i < nb_filters; i++)
102 if (!strncmp( dllname, filters[i], len ))
104 if (!filters[i][len]) return exclude_tests;
105 if (filters[i][len] != ':') continue;
106 if (testname && !strcmp( testname, &filters[i][len+1] )) return exclude_tests;
107 if (!testname && !exclude_tests) return FALSE;
110 return !exclude_tests;
113 static char * get_file_version(char * file_name)
115 static char version[32];
116 DWORD size;
117 DWORD handle;
119 size = GetFileVersionInfoSizeA(file_name, &handle);
120 if (size) {
121 char * data = heap_alloc(size);
122 if (data) {
123 if (GetFileVersionInfoA(file_name, handle, size, data)) {
124 static char backslash[] = "\\";
125 VS_FIXEDFILEINFO *pFixedVersionInfo;
126 UINT len;
127 if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) {
128 sprintf(version, "%d.%d.%d.%d",
129 pFixedVersionInfo->dwFileVersionMS >> 16,
130 pFixedVersionInfo->dwFileVersionMS & 0xffff,
131 pFixedVersionInfo->dwFileVersionLS >> 16,
132 pFixedVersionInfo->dwFileVersionLS & 0xffff);
133 } else
134 sprintf(version, "version not available");
135 } else
136 sprintf(version, "unknown");
137 heap_free(data);
138 } else
139 sprintf(version, "failed");
140 } else
141 sprintf(version, "version not available");
143 return version;
146 static int running_under_wine (void)
148 HMODULE module = GetModuleHandleA("ntdll.dll");
150 if (!module) return 0;
151 return (GetProcAddress(module, "wine_server_call") != NULL);
154 static int check_mount_mgr(void)
156 HANDLE handle = CreateFileA( "\\\\.\\MountPointManager", GENERIC_READ,
157 FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
158 if (handle == INVALID_HANDLE_VALUE) return FALSE;
159 CloseHandle( handle );
160 return TRUE;
163 static int check_wow64_registry(void)
165 char buffer[MAX_PATH];
166 DWORD type, size = MAX_PATH;
167 HKEY hkey;
168 BOOL ret;
170 if (!is_wow64) return TRUE;
171 if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey ))
172 return FALSE;
173 ret = !RegQueryValueExA( hkey, "ProgramFilesDir (x86)", NULL, &type, (BYTE *)buffer, &size );
174 RegCloseKey( hkey );
175 return ret;
178 static int check_display_driver(void)
180 HWND hwnd = CreateWindowA( "STATIC", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
181 0, 0, GetModuleHandleA(0), 0 );
182 if (!hwnd) return FALSE;
183 DestroyWindow( hwnd );
184 return TRUE;
187 static int running_on_visible_desktop (void)
189 HWND desktop;
190 HMODULE huser32 = GetModuleHandleA("user32.dll");
191 HWINSTA (WINAPI *pGetProcessWindowStation)(void);
192 BOOL (WINAPI *pGetUserObjectInformationA)(HANDLE,INT,LPVOID,DWORD,LPDWORD);
194 pGetProcessWindowStation = (void *)GetProcAddress(huser32, "GetProcessWindowStation");
195 pGetUserObjectInformationA = (void *)GetProcAddress(huser32, "GetUserObjectInformationA");
197 desktop = GetDesktopWindow();
198 if (!GetWindowLongPtrW(desktop, GWLP_WNDPROC)) /* Win9x */
199 return IsWindowVisible(desktop);
201 if (pGetProcessWindowStation && pGetUserObjectInformationA)
203 DWORD len;
204 HWINSTA wstation;
205 USEROBJECTFLAGS uoflags;
207 wstation = (HWINSTA)pGetProcessWindowStation();
208 assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len));
209 return (uoflags.dwFlags & WSF_VISIBLE) != 0;
211 return IsWindowVisible(desktop);
214 static int running_as_admin (void)
216 PSID administrators = NULL;
217 SID_IDENTIFIER_AUTHORITY nt_authority = { SECURITY_NT_AUTHORITY };
218 HANDLE token;
219 DWORD groups_size;
220 PTOKEN_GROUPS groups;
221 DWORD group_index;
223 /* Create a well-known SID for the Administrators group. */
224 if (! AllocateAndInitializeSid(&nt_authority, 2, SECURITY_BUILTIN_DOMAIN_RID,
225 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
226 &administrators))
227 return -1;
229 /* Get the process token */
230 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
232 FreeSid(administrators);
233 return -1;
236 /* Get the group info from the token */
237 groups_size = 0;
238 GetTokenInformation(token, TokenGroups, NULL, 0, &groups_size);
239 groups = heap_alloc(groups_size);
240 if (groups == NULL)
242 CloseHandle(token);
243 FreeSid(administrators);
244 return -1;
246 if (! GetTokenInformation(token, TokenGroups, groups, groups_size, &groups_size))
248 heap_free(groups);
249 CloseHandle(token);
250 FreeSid(administrators);
251 return -1;
253 CloseHandle(token);
255 /* Now check if the token groups include the Administrators group */
256 for (group_index = 0; group_index < groups->GroupCount; group_index++)
258 if (EqualSid(groups->Groups[group_index].Sid, administrators))
260 heap_free(groups);
261 FreeSid(administrators);
262 return 1;
266 /* If we end up here we didn't find the Administrators group */
267 heap_free(groups);
268 FreeSid(administrators);
269 return 0;
272 static int running_elevated (void)
274 HANDLE token;
275 TOKEN_ELEVATION elevation_info;
276 DWORD size;
278 /* Get the process token */
279 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
280 return -1;
282 /* Get the elevation info from the token */
283 if (! GetTokenInformation(token, TokenElevation, &elevation_info,
284 sizeof(TOKEN_ELEVATION), &size))
286 CloseHandle(token);
287 return -1;
289 CloseHandle(token);
291 return elevation_info.TokenIsElevated;
294 /* check for native dll when running under wine */
295 static BOOL is_native_dll( HMODULE module )
297 static const char fakedll_signature[] = "Wine placeholder DLL";
298 const IMAGE_DOS_HEADER *dos;
300 if (!running_under_wine()) return FALSE;
301 if (!((ULONG_PTR)module & 1)) return FALSE; /* not loaded as datafile */
302 /* builtin dlls can't be loaded as datafile, so we must have native or fake dll */
303 dos = (const IMAGE_DOS_HEADER *)((const char *)module - 1);
304 if (dos->e_magic != IMAGE_DOS_SIGNATURE) return FALSE;
305 if (dos->e_lfanew >= sizeof(*dos) + sizeof(fakedll_signature) &&
306 !memcmp( dos + 1, fakedll_signature, sizeof(fakedll_signature) )) return FALSE;
307 return TRUE;
310 static void print_version (void)
312 #ifdef __i386__
313 static const char platform[] = "i386";
314 #elif defined(__x86_64__)
315 static const char platform[] = "x86_64";
316 #elif defined(__sparc__)
317 static const char platform[] = "sparc";
318 #elif defined(__powerpc__)
319 static const char platform[] = "powerpc";
320 #elif defined(__arm__)
321 static const char platform[] = "arm";
322 #elif defined(__aarch64__)
323 static const char platform[] = "arm64";
324 #else
325 # error CPU unknown
326 #endif
327 OSVERSIONINFOEXA ver;
328 BOOL ext;
329 int is_win2k3_r2, is_admin, is_elevated;
330 const char *(CDECL *wine_get_build_id)(void);
331 void (CDECL *wine_get_host_version)( const char **sysname, const char **release );
332 BOOL (WINAPI *pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *);
334 ver.dwOSVersionInfoSize = sizeof(ver);
335 if (!(ext = GetVersionExA ((OSVERSIONINFOA *) &ver)))
337 ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
338 if (!GetVersionExA ((OSVERSIONINFOA *) &ver))
339 report (R_FATAL, "Can't get OS version.");
341 xprintf (" Platform=%s%s\n", platform, is_wow64 ? " (WOW64)" : "");
342 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
343 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
344 is_admin = running_as_admin ();
345 if (0 <= is_admin)
347 xprintf (" Account=%s", is_admin ? "admin" : "non-admin");
348 is_elevated = running_elevated ();
349 if (0 <= is_elevated)
350 xprintf(", %s", is_elevated ? "elevated" : "not elevated");
351 xprintf ("\n");
353 xprintf (" Submitter=%s\n", email );
354 if (description)
355 xprintf (" Description=%s\n", description );
356 if (url)
357 xprintf (" URL=%s\n", url );
358 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
359 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
360 ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber,
361 ver.dwPlatformId, ver.szCSDVersion);
363 wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
364 wine_get_host_version = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
365 if (wine_get_build_id) xprintf( " WineBuild=%s\n", wine_get_build_id() );
366 if (wine_get_host_version)
368 const char *sysname, *release;
369 wine_get_host_version( &sysname, &release );
370 xprintf( " Host system=%s\n Host version=%s\n", sysname, release );
372 is_win2k3_r2 = GetSystemMetrics(SM_SERVERR2);
373 if(is_win2k3_r2)
374 xprintf(" R2 build number=%d\n", is_win2k3_r2);
376 if (!ext) return;
378 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
379 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
380 ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask,
381 ver.wProductType, ver.wReserved);
383 pGetProductInfo = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"GetProductInfo");
384 if (pGetProductInfo && !running_under_wine())
386 DWORD prodtype = 0;
388 pGetProductInfo(ver.dwMajorVersion, ver.dwMinorVersion, ver.wServicePackMajor, ver.wServicePackMinor, &prodtype);
389 xprintf(" dwProductInfo=%u\n", prodtype);
393 static void print_language(void)
395 HMODULE hkernel32;
396 LANGID (WINAPI *pGetUserDefaultUILanguage)(void);
397 LANGID (WINAPI *pGetThreadUILanguage)(void);
399 xprintf (" SystemDefaultLCID=%x\n", GetSystemDefaultLCID());
400 xprintf (" UserDefaultLCID=%x\n", GetUserDefaultLCID());
401 xprintf (" ThreadLocale=%x\n", GetThreadLocale());
403 hkernel32 = GetModuleHandleA("kernel32.dll");
404 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
405 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
406 if (pGetUserDefaultUILanguage)
407 xprintf (" UserDefaultUILanguage=%x\n", pGetUserDefaultUILanguage());
408 if (pGetThreadUILanguage)
409 xprintf (" ThreadUILanguage=%x\n", pGetThreadUILanguage());
412 static inline int is_dot_dir(const char* x)
414 return ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))));
417 static void remove_dir (const char *dir)
419 HANDLE hFind;
420 WIN32_FIND_DATAA wfd;
421 char path[MAX_PATH];
422 size_t dirlen = strlen (dir);
424 /* Make sure the directory exists before going further */
425 memcpy (path, dir, dirlen);
426 strcpy (path + dirlen++, "\\*");
427 hFind = FindFirstFileA (path, &wfd);
428 if (hFind == INVALID_HANDLE_VALUE) return;
430 do {
431 char *lp = wfd.cFileName;
433 if (!lp[0]) lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */
434 if (is_dot_dir (lp)) continue;
435 strcpy (path + dirlen, lp);
436 if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
437 remove_dir(path);
438 else if (!DeleteFileA(path))
439 report (R_WARNING, "Can't delete file %s: error %d",
440 path, GetLastError ());
441 } while (FindNextFileA(hFind, &wfd));
442 FindClose (hFind);
443 if (!RemoveDirectoryA(dir))
444 report (R_WARNING, "Can't remove directory %s: error %d",
445 dir, GetLastError ());
448 static const char* get_test_source_file(const char* test, const char* subtest)
450 static const char* special_dirs[][2] = {
451 { 0, 0 }
453 static char buffer[MAX_PATH];
454 int i, len = strlen(test);
456 if (len > 4 && !strcmp( test + len - 4, ".exe" ))
458 len = sprintf(buffer, "programs/%s", test) - 4;
459 buffer[len] = 0;
461 else len = sprintf(buffer, "dlls/%s", test);
463 for (i = 0; special_dirs[i][0]; i++) {
464 if (strcmp(test, special_dirs[i][0]) == 0) {
465 strcpy( buffer, special_dirs[i][1] );
466 len = strlen(buffer);
467 break;
471 sprintf(buffer + len, "/tests/%s.c", subtest);
472 return buffer;
475 static void* extract_rcdata (LPCSTR name, LPCSTR type, DWORD* size)
477 HRSRC rsrc;
478 HGLOBAL hdl;
479 LPVOID addr;
481 if (!(rsrc = FindResourceA(NULL, name, type)) ||
482 !(*size = SizeofResource (0, rsrc)) ||
483 !(hdl = LoadResource (0, rsrc)) ||
484 !(addr = LockResource (hdl)))
485 return NULL;
486 return addr;
489 /* Fills in the name and exename fields */
490 static void
491 extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
493 BYTE* code;
494 DWORD size;
495 char *exepos;
496 HANDLE hfile;
497 DWORD written;
499 code = extract_rcdata (res_name, "TESTRES", &size);
500 if (!code) report (R_FATAL, "Can't find test resource %s: %d",
501 res_name, GetLastError ());
502 test->name = heap_strdup( res_name );
503 test->exename = strmake (NULL, "%s\\%s", dir, test->name);
504 exepos = strstr (test->name, testexe);
505 if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
506 *exepos = 0;
507 test->name = heap_realloc (test->name, exepos - test->name + 1);
508 report (R_STEP, "Extracting: %s", test->name);
510 hfile = CreateFileA(test->exename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
511 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
512 if (hfile == INVALID_HANDLE_VALUE)
513 report (R_FATAL, "Failed to open file %s.", test->exename);
515 if (!WriteFile(hfile, code, size, &written, NULL))
516 report (R_FATAL, "Failed to write file %s.", test->exename);
518 CloseHandle(hfile);
521 static DWORD wait_process( HANDLE process, DWORD timeout )
523 DWORD wait, diff = 0, start = GetTickCount();
524 MSG msg;
526 while (diff < timeout)
528 wait = MsgWaitForMultipleObjects( 1, &process, FALSE, timeout - diff, QS_ALLINPUT );
529 if (wait != WAIT_OBJECT_0 + 1) return wait;
530 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
531 diff = GetTickCount() - start;
533 return WAIT_TIMEOUT;
536 static void append_path( const char *path)
538 char *newpath;
540 newpath = heap_alloc(strlen(curpath) + 1 + strlen(path) + 1);
541 strcpy(newpath, curpath);
542 strcat(newpath, ";");
543 strcat(newpath, path);
544 SetEnvironmentVariableA("PATH", newpath);
546 heap_free(newpath);
549 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
550 stdout to there.
552 Return the exit status, -2 if can't create process or the return
553 value of WaitForSingleObject.
555 static int
556 run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms)
558 STARTUPINFOA si;
559 PROCESS_INFORMATION pi;
560 DWORD wait, status;
562 GetStartupInfoA (&si);
563 si.dwFlags = STARTF_USESTDHANDLES;
564 si.hStdInput = GetStdHandle( STD_INPUT_HANDLE );
565 si.hStdOutput = out_file ? out_file : GetStdHandle( STD_OUTPUT_HANDLE );
566 si.hStdError = out_file ? out_file : GetStdHandle( STD_ERROR_HANDLE );
568 if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE,
569 NULL, tempdir, &si, &pi))
570 return -2;
572 CloseHandle (pi.hThread);
573 status = wait_process( pi.hProcess, ms );
574 switch (status)
576 case WAIT_OBJECT_0:
577 GetExitCodeProcess (pi.hProcess, &status);
578 CloseHandle (pi.hProcess);
579 return status;
580 case WAIT_FAILED:
581 report (R_ERROR, "Wait for '%s' failed: %d", cmd, GetLastError ());
582 break;
583 case WAIT_TIMEOUT:
584 break;
585 default:
586 report (R_ERROR, "Wait returned %d", status);
587 break;
589 if (!TerminateProcess (pi.hProcess, 257))
590 report (R_ERROR, "TerminateProcess failed: %d", GetLastError ());
591 wait = wait_process( pi.hProcess, 5000 );
592 switch (wait)
594 case WAIT_OBJECT_0:
595 break;
596 case WAIT_FAILED:
597 report (R_ERROR, "Wait for termination of '%s' failed: %d", cmd, GetLastError ());
598 break;
599 case WAIT_TIMEOUT:
600 report (R_ERROR, "Can't kill process '%s'", cmd);
601 break;
602 default:
603 report (R_ERROR, "Waiting for termination: %d", wait);
604 break;
606 CloseHandle (pi.hProcess);
607 return status;
610 static DWORD
611 get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name)
613 char *cmd;
614 HANDLE subfile;
615 DWORD err, total;
616 char buffer[8192], *index;
617 static const char header[] = "Valid test names:";
618 int status, allocated;
619 char tmpdir[MAX_PATH], subname[MAX_PATH];
620 SECURITY_ATTRIBUTES sa;
622 test->subtest_count = 0;
624 if (!GetTempPathA( MAX_PATH, tmpdir ) ||
625 !GetTempFileNameA( tmpdir, "sub", 0, subname ))
626 report (R_FATAL, "Can't name subtests file.");
628 /* make handle inheritable */
629 sa.nLength = sizeof(sa);
630 sa.lpSecurityDescriptor = NULL;
631 sa.bInheritHandle = TRUE;
633 subfile = CreateFileA( subname, GENERIC_READ|GENERIC_WRITE,
634 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
635 &sa, CREATE_ALWAYS, 0, NULL );
637 if ((subfile == INVALID_HANDLE_VALUE) &&
638 (GetLastError() == ERROR_INVALID_PARAMETER)) {
639 /* FILE_SHARE_DELETE not supported on win9x */
640 subfile = CreateFileA( subname, GENERIC_READ|GENERIC_WRITE,
641 FILE_SHARE_READ | FILE_SHARE_WRITE,
642 &sa, CREATE_ALWAYS, 0, NULL );
644 if (subfile == INVALID_HANDLE_VALUE) {
645 err = GetLastError();
646 report (R_ERROR, "Can't open subtests output of %s: %u",
647 test->name, GetLastError());
648 goto quit;
651 cmd = strmake (NULL, "%s --list", test->exename);
652 if (test->maindllpath) {
653 /* We need to add the path (to the main dll) to PATH */
654 append_path(test->maindllpath);
656 status = run_ex (cmd, subfile, tempdir, 5000);
657 err = GetLastError();
658 if (test->maindllpath) {
659 /* Restore PATH again */
660 SetEnvironmentVariableA("PATH", curpath);
662 heap_free (cmd);
664 if (status == -2)
666 report (R_ERROR, "Cannot run %s error %u", test->exename, err);
667 CloseHandle( subfile );
668 goto quit;
671 SetFilePointer( subfile, 0, NULL, FILE_BEGIN );
672 ReadFile( subfile, buffer, sizeof(buffer), &total, NULL );
673 CloseHandle( subfile );
674 if (sizeof buffer == total) {
675 report (R_ERROR, "Subtest list of %s too big.",
676 test->name, sizeof buffer);
677 err = ERROR_OUTOFMEMORY;
678 goto quit;
680 buffer[total] = 0;
682 index = strstr (buffer, header);
683 if (!index) {
684 report (R_ERROR, "Can't parse subtests output of %s",
685 test->name);
686 err = ERROR_INTERNAL_ERROR;
687 goto quit;
689 index += sizeof header;
691 allocated = 10;
692 test->subtests = heap_alloc (allocated * sizeof(char*));
693 index = strtok (index, whitespace);
694 while (index) {
695 if (test->subtest_count == allocated) {
696 allocated *= 2;
697 test->subtests = heap_realloc (test->subtests,
698 allocated * sizeof(char*));
700 test->subtests[test->subtest_count++] = heap_strdup(index);
701 index = strtok (NULL, whitespace);
703 test->subtests = heap_realloc (test->subtests,
704 test->subtest_count * sizeof(char*));
705 err = 0;
707 quit:
708 if (!DeleteFileA (subname))
709 report (R_WARNING, "Can't delete file '%s': %u", subname, GetLastError());
710 return err;
713 static void
714 run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const char *tempdir)
716 const char* file = get_test_source_file(test->name, subtest);
718 if (test_filtered_out( test->name, subtest ))
720 report (R_STEP, "Skipping: %s:%s", test->name, subtest);
721 xprintf ("%s:%s skipped %s -\n", test->name, subtest, file);
722 nr_of_skips++;
724 else
726 int status;
727 char *cmd = strmake (NULL, "%s %s", test->exename, subtest);
728 report (R_STEP, "Running: %s:%s", test->name, subtest);
729 xprintf ("%s:%s start %s -\n", test->name, subtest, file);
730 status = run_ex (cmd, out_file, tempdir, 120000);
731 heap_free (cmd);
732 xprintf ("%s:%s done (%d)\n", test->name, subtest, status);
733 if (status) failures++;
735 if (failures) report (R_STATUS, "Running tests - %u failures", failures);
738 static BOOL CALLBACK
739 EnumTestFileProc (HMODULE hModule, LPCSTR lpszType,
740 LPSTR lpszName, LONG_PTR lParam)
742 if (!test_filtered_out( lpszName, NULL )) (*(int*)lParam)++;
743 return TRUE;
746 static const struct clsid_mapping
748 const char *name;
749 CLSID clsid;
750 } clsid_list[] =
752 {"oledb32", {0xc8b522d1, 0x5cf3, 0x11ce, {0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d}}},
753 {NULL, {0, 0, 0, {0,0,0,0,0,0,0,0}}}
757 static BOOL get_main_clsid(const char *name, CLSID *clsid)
759 const struct clsid_mapping *mapping;
761 for(mapping = clsid_list; mapping->name; mapping++)
763 if(!strcasecmp(name, mapping->name))
765 *clsid = mapping->clsid;
766 return TRUE;
769 return FALSE;
772 static HMODULE load_com_dll(const char *name, char **path, char *filename)
774 HMODULE dll = NULL;
775 HKEY hkey;
776 char keyname[100];
777 char dllname[MAX_PATH];
778 char *p;
779 CLSID clsid;
781 if(!get_main_clsid(name, &clsid)) return NULL;
783 sprintf(keyname, "CLSID\\{%08x-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
784 clsid.Data1, clsid.Data2, clsid.Data3, clsid.Data4[0], clsid.Data4[1],
785 clsid.Data4[2], clsid.Data4[3], clsid.Data4[4], clsid.Data4[5],
786 clsid.Data4[6], clsid.Data4[7]);
788 if(RegOpenKeyA(HKEY_CLASSES_ROOT, keyname, &hkey) == ERROR_SUCCESS)
790 LONG size = sizeof(dllname);
791 if(RegQueryValueA(hkey, NULL, dllname, &size) == ERROR_SUCCESS)
793 if ((dll = LoadLibraryExA(dllname, NULL, LOAD_LIBRARY_AS_DATAFILE)))
795 strcpy( filename, dllname );
796 p = strrchr(dllname, '\\');
797 if (p) *p = 0;
798 *path = heap_strdup( dllname );
801 RegCloseKey(hkey);
804 return dll;
807 static void get_dll_path(HMODULE dll, char **path, char *filename)
809 char dllpath[MAX_PATH];
811 GetModuleFileNameA(dll, dllpath, MAX_PATH);
812 strcpy(filename, dllpath);
813 *strrchr(dllpath, '\\') = '\0';
814 *path = heap_strdup( dllpath );
817 static BOOL CALLBACK
818 extract_test_proc (HMODULE hModule, LPCSTR lpszType, LPSTR lpszName, LONG_PTR lParam)
820 const char *tempdir = (const char *)lParam;
821 char dllname[MAX_PATH];
822 char filename[MAX_PATH];
823 WCHAR dllnameW[MAX_PATH];
824 HMODULE dll;
825 DWORD err;
826 HANDLE actctx;
827 ULONG_PTR cookie;
829 if (aborting) return TRUE;
831 /* Check if the main dll is present on this system */
832 CharLowerA(lpszName);
833 strcpy(dllname, lpszName);
834 *strstr(dllname, testexe) = 0;
836 if (test_filtered_out( lpszName, NULL ))
838 nr_of_skips++;
839 xprintf (" %s=skipped\n", dllname);
840 return TRUE;
842 extract_test (&wine_tests[nr_of_files], tempdir, lpszName);
844 if (pCreateActCtxA != NULL && pActivateActCtx != NULL &&
845 pDeactivateActCtx != NULL && pReleaseActCtx != NULL)
847 ACTCTXA actctxinfo;
848 memset(&actctxinfo, 0, sizeof(ACTCTXA));
849 actctxinfo.cbSize = sizeof(ACTCTXA);
850 actctxinfo.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
851 actctxinfo.lpSource = wine_tests[nr_of_files].exename;
852 actctxinfo.lpResourceName = (LPSTR)CREATEPROCESS_MANIFEST_RESOURCE_ID;
853 actctx = pCreateActCtxA(&actctxinfo);
854 if (actctx != INVALID_HANDLE_VALUE &&
855 ! pActivateActCtx(actctx, &cookie))
857 pReleaseActCtx(actctx);
858 actctx = INVALID_HANDLE_VALUE;
860 } else actctx = INVALID_HANDLE_VALUE;
862 wine_tests[nr_of_files].maindllpath = NULL;
863 strcpy(filename, dllname);
864 dll = LoadLibraryExA(dllname, NULL, LOAD_LIBRARY_AS_DATAFILE);
866 if (!dll) dll = load_com_dll(dllname, &wine_tests[nr_of_files].maindllpath, filename);
868 if (!dll && pLoadLibraryShim)
870 MultiByteToWideChar(CP_ACP, 0, dllname, -1, dllnameW, MAX_PATH);
871 if (SUCCEEDED( pLoadLibraryShim(dllnameW, NULL, NULL, &dll) ) && dll)
873 get_dll_path(dll, &wine_tests[nr_of_files].maindllpath, filename);
874 FreeLibrary(dll);
875 dll = LoadLibraryExA(filename, NULL, LOAD_LIBRARY_AS_DATAFILE);
877 else dll = 0;
880 if (!dll)
882 xprintf (" %s=dll is missing\n", dllname);
883 if (actctx != INVALID_HANDLE_VALUE)
885 pDeactivateActCtx(0, cookie);
886 pReleaseActCtx(actctx);
888 return TRUE;
890 if (is_native_dll(dll))
892 FreeLibrary(dll);
893 xprintf (" %s=load error Configured as native\n", dllname);
894 nr_native_dlls++;
895 if (actctx != INVALID_HANDLE_VALUE)
897 pDeactivateActCtx(0, cookie);
898 pReleaseActCtx(actctx);
900 return TRUE;
902 FreeLibrary(dll);
904 if (!(err = get_subtests( tempdir, &wine_tests[nr_of_files], lpszName )))
906 xprintf (" %s=%s\n", dllname, get_file_version(filename));
907 nr_of_tests += wine_tests[nr_of_files].subtest_count;
908 nr_of_files++;
910 else
912 xprintf (" %s=load error %u\n", dllname, err);
915 if (actctx != INVALID_HANDLE_VALUE)
917 pDeactivateActCtx(0, cookie);
918 pReleaseActCtx(actctx);
920 return TRUE;
923 static char *
924 run_tests (char *logname, char *outdir)
926 int i;
927 char *strres, *eol, *nextline;
928 DWORD strsize;
929 SECURITY_ATTRIBUTES sa;
930 char tmppath[MAX_PATH], tempdir[MAX_PATH+4];
931 DWORD needed;
932 HMODULE kernel32;
934 /* Get the current PATH only once */
935 needed = GetEnvironmentVariableA("PATH", NULL, 0);
936 curpath = heap_alloc(needed);
937 GetEnvironmentVariableA("PATH", curpath, needed);
939 SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
941 if (!GetTempPathA( MAX_PATH, tmppath ))
942 report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
944 if (!logname) {
945 static char tmpname[MAX_PATH];
946 if (!GetTempFileNameA( tmppath, "res", 0, tmpname ))
947 report (R_FATAL, "Can't name logfile.");
948 logname = tmpname;
950 report (R_OUT, logname);
952 /* make handle inheritable */
953 sa.nLength = sizeof(sa);
954 sa.lpSecurityDescriptor = NULL;
955 sa.bInheritHandle = TRUE;
957 logfile = CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
958 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
959 &sa, CREATE_ALWAYS, 0, NULL );
961 if ((logfile == INVALID_HANDLE_VALUE) &&
962 (GetLastError() == ERROR_INVALID_PARAMETER)) {
963 /* FILE_SHARE_DELETE not supported on win9x */
964 logfile = CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
965 FILE_SHARE_READ | FILE_SHARE_WRITE,
966 &sa, CREATE_ALWAYS, 0, NULL );
968 if (logfile == INVALID_HANDLE_VALUE)
969 report (R_FATAL, "Could not open logfile: %u", GetLastError());
971 /* try stable path for ZoneAlarm */
972 if (!outdir) {
973 strcpy( tempdir, tmppath );
974 strcat( tempdir, "wct" );
976 if (!CreateDirectoryA( tempdir, NULL ))
978 if (!GetTempFileNameA( tmppath, "wct", 0, tempdir ))
979 report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
980 DeleteFileA( tempdir );
981 if (!CreateDirectoryA( tempdir, NULL ))
982 report (R_FATAL, "Could not create directory: %s", tempdir);
985 else
986 strcpy( tempdir, outdir);
988 report (R_DIR, tempdir);
990 xprintf ("Version 4\n");
991 xprintf ("Tests from build %s\n", build_id[0] ? build_id : "-" );
992 xprintf ("Archive: -\n"); /* no longer used */
993 xprintf ("Tag: %s\n", tag);
994 xprintf ("Build info:\n");
995 strres = extract_rcdata ("BUILD_INFO", "STRINGRES", &strsize);
996 while (strres) {
997 eol = memchr (strres, '\n', strsize);
998 if (!eol) {
999 nextline = NULL;
1000 eol = strres + strsize;
1001 } else {
1002 strsize -= eol - strres + 1;
1003 nextline = strsize?eol+1:NULL;
1004 if (eol > strres && *(eol-1) == '\r') eol--;
1006 xprintf (" %.*s\n", eol-strres, strres);
1007 strres = nextline;
1009 xprintf ("Operating system version:\n");
1010 print_version ();
1011 print_language ();
1012 xprintf ("Dll info:\n" );
1014 report (R_STATUS, "Counting tests");
1015 if (!EnumResourceNamesA (NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files))
1016 report (R_FATAL, "Can't enumerate test files: %d",
1017 GetLastError ());
1018 wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0]);
1020 /* Do this only once during extraction (and version checking) */
1021 hmscoree = LoadLibraryA("mscoree.dll");
1022 pLoadLibraryShim = NULL;
1023 if (hmscoree)
1024 pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
1025 kernel32 = GetModuleHandleA("kernel32.dll");
1026 pCreateActCtxA = (void *)GetProcAddress(kernel32, "CreateActCtxA");
1027 pActivateActCtx = (void *)GetProcAddress(kernel32, "ActivateActCtx");
1028 pDeactivateActCtx = (void *)GetProcAddress(kernel32, "DeactivateActCtx");
1029 pReleaseActCtx = (void *)GetProcAddress(kernel32, "ReleaseActCtx");
1031 report (R_STATUS, "Extracting tests");
1032 report (R_PROGRESS, 0, nr_of_files);
1033 nr_of_files = 0;
1034 nr_of_tests = 0;
1035 nr_of_skips = 0;
1036 if (!EnumResourceNamesA (NULL, "TESTRES", extract_test_proc, (LPARAM)tempdir))
1037 report (R_FATAL, "Can't enumerate test files: %d",
1038 GetLastError ());
1040 FreeLibrary(hmscoree);
1042 if (aborting) return logname;
1044 xprintf ("Test output:\n" );
1046 report (R_DELTA, 0, "Extracting: Done");
1048 if (nr_native_dlls)
1049 report( R_WARNING, "Some dlls are configured as native, you won't be able to submit results." );
1051 report (R_STATUS, "Running tests");
1052 report (R_PROGRESS, 1, nr_of_tests);
1053 for (i = 0; i < nr_of_files; i++) {
1054 struct wine_test *test = wine_tests + i;
1055 int j;
1057 if (aborting) break;
1059 if (test->maindllpath) {
1060 /* We need to add the path (to the main dll) to PATH */
1061 append_path(test->maindllpath);
1064 for (j = 0; j < test->subtest_count; j++) {
1065 if (aborting) break;
1066 run_test (test, test->subtests[j], logfile, tempdir);
1069 if (test->maindllpath) {
1070 /* Restore PATH again */
1071 SetEnvironmentVariableA("PATH", curpath);
1074 report (R_DELTA, 0, "Running: Done");
1076 report (R_STATUS, "Cleaning up");
1077 CloseHandle( logfile );
1078 logfile = 0;
1079 if (!outdir)
1080 remove_dir (tempdir);
1081 heap_free(wine_tests);
1082 heap_free(curpath);
1084 return logname;
1087 static BOOL WINAPI ctrl_handler(DWORD ctrl_type)
1089 if (ctrl_type == CTRL_C_EVENT) {
1090 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
1091 return TRUE;
1094 return FALSE;
1098 static BOOL CALLBACK
1099 extract_only_proc (HMODULE hModule, LPCSTR lpszType, LPSTR lpszName, LONG_PTR lParam)
1101 const char *target_dir = (const char *)lParam;
1102 char filename[MAX_PATH];
1104 if (test_filtered_out( lpszName, NULL )) return TRUE;
1106 strcpy(filename, lpszName);
1107 CharLowerA(filename);
1109 extract_test( &wine_tests[nr_of_files], target_dir, filename );
1110 nr_of_files++;
1111 return TRUE;
1114 static void extract_only (const char *target_dir)
1116 BOOL res;
1118 report (R_DIR, target_dir);
1119 res = CreateDirectoryA( target_dir, NULL );
1120 if (!res && GetLastError() != ERROR_ALREADY_EXISTS)
1121 report (R_FATAL, "Could not create directory: %s (%d)", target_dir, GetLastError ());
1123 nr_of_files = 0;
1124 report (R_STATUS, "Counting tests");
1125 if (!EnumResourceNamesA(NULL, "TESTRES", EnumTestFileProc, (LPARAM)&nr_of_files))
1126 report (R_FATAL, "Can't enumerate test files: %d", GetLastError ());
1128 wine_tests = heap_alloc (nr_of_files * sizeof wine_tests[0] );
1130 report (R_STATUS, "Extracting tests");
1131 report (R_PROGRESS, 0, nr_of_files);
1132 nr_of_files = 0;
1133 if (!EnumResourceNamesA(NULL, "TESTRES", extract_only_proc, (LPARAM)target_dir))
1134 report (R_FATAL, "Can't enumerate test files: %d", GetLastError ());
1136 report (R_DELTA, 0, "Extracting: Done");
1139 static void
1140 usage (void)
1142 fprintf (stderr,
1143 "Usage: winetest [OPTION]... [TESTS]\n\n"
1144 " --help print this message and exit\n"
1145 " --version print the build version and exit\n"
1146 " -c console mode, no GUI\n"
1147 " -d DIR Use DIR as temp directory (default: %%TEMP%%\\wct)\n"
1148 " -e preserve the environment\n"
1149 " -h print this message and exit\n"
1150 " -i INFO an optional description of the test platform\n"
1151 " -m MAIL an email address to enable developers to contact you\n"
1152 " -n exclude the specified tests\n"
1153 " -p shutdown when the tests are done\n"
1154 " -q quiet mode, no output at all\n"
1155 " -o FILE put report into FILE, do not submit\n"
1156 " -s FILE submit FILE, do not run tests\n"
1157 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"
1158 " -u URL include TestBot URL in the report\n"
1159 " -x DIR Extract tests to DIR (default: .\\wct) and exit\n");
1162 int main( int argc, char *argv[] )
1164 BOOL (WINAPI *pIsWow64Process)(HANDLE hProcess, PBOOL Wow64Process);
1165 char *logname = NULL, *outdir = NULL;
1166 const char *extract = NULL;
1167 const char *cp, *submit = NULL;
1168 int reset_env = 1;
1169 int poweroff = 0;
1170 int interactive = 1;
1171 int i;
1173 if (!LoadStringA( 0, IDS_BUILD_ID, build_id, sizeof(build_id) )) build_id[0] = 0;
1175 pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
1176 if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
1178 for (i = 1; i < argc && argv[i]; i++)
1180 if (!strcmp(argv[i], "--help")) {
1181 usage ();
1182 exit (0);
1184 else if (!strcmp(argv[i], "--version")) {
1185 printf("%-12.12s\n", build_id[0] ? build_id : "unknown");
1186 exit (0);
1188 else if ((argv[i][0] != '-' && argv[i][0] != '/') || argv[i][2]) {
1189 if (nb_filters == sizeof(filters)/sizeof(filters[0]))
1191 report (R_ERROR, "Too many test filters specified");
1192 exit (2);
1194 filters[nb_filters++] = argv[i];
1196 else switch (argv[i][1]) {
1197 case 'c':
1198 report (R_TEXTMODE);
1199 interactive = 0;
1200 break;
1201 case 'e':
1202 reset_env = 0;
1203 break;
1204 case 'h':
1205 case '?':
1206 usage ();
1207 exit (0);
1208 case 'i':
1209 if (!(description = argv[++i]))
1211 usage();
1212 exit( 2 );
1214 break;
1215 case 'm':
1216 if (!(email = argv[++i]))
1218 usage();
1219 exit( 2 );
1221 break;
1222 case 'n':
1223 exclude_tests = TRUE;
1224 break;
1225 case 'p':
1226 poweroff = 1;
1227 break;
1228 case 'q':
1229 report (R_QUIET);
1230 interactive = 0;
1231 break;
1232 case 's':
1233 if (!(submit = argv[++i]))
1235 usage();
1236 exit( 2 );
1238 if (tag)
1239 report (R_WARNING, "ignoring tag for submission");
1240 send_file (submit);
1241 break;
1242 case 'o':
1243 if (!(logname = argv[++i]))
1245 usage();
1246 exit( 2 );
1248 break;
1249 case 't':
1250 if (!(tag = argv[++i]))
1252 usage();
1253 exit( 2 );
1255 if (strlen (tag) > MAXTAGLEN)
1256 report (R_FATAL, "tag is too long (maximum %d characters)",
1257 MAXTAGLEN);
1258 cp = findbadtagchar (tag);
1259 if (cp) {
1260 report (R_ERROR, "invalid char in tag: %c", *cp);
1261 usage ();
1262 exit (2);
1264 break;
1265 case 'u':
1266 if (!(url = argv[++i]))
1268 usage();
1269 exit( 2 );
1271 break;
1272 case 'x':
1273 report (R_TEXTMODE);
1274 if (!(extract = argv[++i]))
1275 extract = ".\\wct";
1277 extract_only (extract);
1278 break;
1279 case 'd':
1280 outdir = argv[++i];
1281 break;
1282 default:
1283 report (R_ERROR, "invalid option: -%c", argv[i][1]);
1284 usage ();
1285 exit (2);
1288 if (!submit && !extract) {
1289 int is_win9x = (GetVersion() & 0x80000000) != 0;
1291 report (R_STATUS, "Starting up");
1293 if (is_win9x)
1294 report (R_WARNING, "Running on win9x is not supported. You won't be able to submit results.");
1296 if (!running_on_visible_desktop ())
1297 report (R_FATAL, "Tests must be run on a visible desktop");
1299 if (running_under_wine())
1301 if (!check_mount_mgr())
1302 report (R_FATAL, "Mount manager not running, most likely your WINEPREFIX wasn't created correctly.");
1304 if (!check_wow64_registry())
1305 report (R_FATAL, "WoW64 keys missing, most likely your WINEPREFIX wasn't created correctly.");
1307 if (!check_display_driver())
1308 report (R_FATAL, "Unable to create a window, the display driver is not working.");
1311 SetConsoleCtrlHandler(ctrl_handler, TRUE);
1313 if (reset_env)
1315 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
1316 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
1317 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
1318 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
1321 while (!tag) {
1322 if (!interactive)
1323 report (R_FATAL, "Please specify a tag (-t option) if "
1324 "running noninteractive!");
1325 if (guiAskTag () == IDABORT) exit (1);
1327 report (R_TAG);
1329 while (!email) {
1330 if (!interactive)
1331 report (R_FATAL, "Please specify an email address (-m option) to enable developers\n"
1332 " to contact you about your report if necessary.");
1333 if (guiAskEmail () == IDABORT) exit (1);
1336 if (!build_id[0])
1337 report( R_WARNING, "You won't be able to submit results without a valid build id.\n"
1338 "To submit results, winetest needs to be built from a git checkout." );
1340 if (!logname) {
1341 logname = run_tests (NULL, outdir);
1342 if (aborting) {
1343 DeleteFileA(logname);
1344 exit (0);
1346 if (failures > FAILURES_LIMIT)
1347 report( R_WARNING,
1348 "%d tests failed, there's probably something broken with your setup.\n"
1349 "You need to address this before submitting results.", failures );
1351 if (build_id[0] && nr_of_skips <= SKIP_LIMIT && failures <= FAILURES_LIMIT &&
1352 !nr_native_dlls && !is_win9x &&
1353 report (R_ASK, MB_YESNO, "Do you want to submit the test results?") == IDYES)
1354 if (!send_file (logname) && !DeleteFileA(logname))
1355 report (R_WARNING, "Can't remove logfile: %u", GetLastError());
1356 } else run_tests (logname, outdir);
1357 report (R_STATUS, "Finished");
1359 if (poweroff)
1361 HANDLE hToken;
1362 TOKEN_PRIVILEGES npr;
1364 /* enable the shutdown privilege for the current process */
1365 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
1367 LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
1368 npr.PrivilegeCount = 1;
1369 npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
1370 AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
1371 CloseHandle(hToken);
1373 ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);
1375 exit (0);