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.
39 /* Don't submit the results if more than SKIP_LIMIT tests have been skipped */
42 /* Don't submit the results if more than FAILURES_LIMIT tests have failed */
43 #define FAILURES_LIMIT 50
55 char *description
= NULL
;
58 BOOL aborting
= FALSE
;
59 static struct wine_test
*wine_tests
;
60 static int nr_of_files
, nr_of_tests
, nr_of_skips
;
61 static int nr_native_dlls
;
62 static const char whitespace
[] = " \t\r\n";
63 static const char testexe
[] = "_test.exe";
64 static char build_id
[64];
68 /* filters for running only specific tests */
69 static char *filters
[64];
70 static unsigned int nb_filters
= 0;
71 static BOOL exclude_tests
= FALSE
;
73 /* Needed to check for .NET dlls */
74 static HMODULE hmscoree
;
75 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR
, LPCWSTR
, LPVOID
, HMODULE
*);
77 /* For SxS DLLs e.g. msvcr90 */
78 static HANDLE (WINAPI
*pCreateActCtxA
)(PACTCTXA
);
79 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
, ULONG_PTR
*);
80 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
, ULONG_PTR
);
81 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
83 /* To store the current PATH setting (related to .NET only provided dlls) */
86 /* check if test is being filtered out */
87 static BOOL
test_filtered_out( LPCSTR module
, LPCSTR testname
)
89 char *p
, dllname
[MAX_PATH
];
92 strcpy( dllname
, module
);
93 CharLowerA( dllname
);
94 p
= strstr( dllname
, testexe
);
96 len
= strlen(dllname
);
98 if (!nb_filters
) return exclude_tests
;
99 for (i
= 0; i
< nb_filters
; i
++)
101 if (!strncmp( dllname
, filters
[i
], len
))
103 if (!filters
[i
][len
]) return exclude_tests
;
104 if (filters
[i
][len
] != ':') continue;
105 if (testname
&& !strcmp( testname
, &filters
[i
][len
+1] )) return exclude_tests
;
106 if (!testname
&& !exclude_tests
) return FALSE
;
109 return !exclude_tests
;
112 static char * get_file_version(char * file_name
)
114 static char version
[32];
118 size
= GetFileVersionInfoSizeA(file_name
, &handle
);
120 char * data
= heap_alloc(size
);
122 if (GetFileVersionInfoA(file_name
, handle
, size
, data
)) {
123 static const char backslash
[] = "\\";
124 VS_FIXEDFILEINFO
*pFixedVersionInfo
;
126 if (VerQueryValueA(data
, backslash
, (LPVOID
*)&pFixedVersionInfo
, &len
)) {
127 sprintf(version
, "%d.%d.%d.%d",
128 pFixedVersionInfo
->dwFileVersionMS
>> 16,
129 pFixedVersionInfo
->dwFileVersionMS
& 0xffff,
130 pFixedVersionInfo
->dwFileVersionLS
>> 16,
131 pFixedVersionInfo
->dwFileVersionLS
& 0xffff);
133 sprintf(version
, "version not found");
135 sprintf(version
, "version error %u", GetLastError());
138 sprintf(version
, "version error %u", ERROR_OUTOFMEMORY
);
139 } else if (GetLastError() == ERROR_FILE_NOT_FOUND
)
140 sprintf(version
, "dll is missing");
142 sprintf(version
, "version not present %u", GetLastError());
147 static BOOL
running_under_wine (void)
149 HMODULE module
= GetModuleHandleA("ntdll.dll");
151 if (!module
) return FALSE
;
152 return (GetProcAddress(module
, "wine_server_call") != NULL
);
155 static BOOL
check_mount_mgr(void)
157 HANDLE handle
= CreateFileA( "\\\\.\\MountPointManager", GENERIC_READ
,
158 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
159 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
160 CloseHandle( handle
);
164 static BOOL
check_wow64_registry(void)
166 char buffer
[MAX_PATH
];
167 DWORD type
, size
= MAX_PATH
;
171 if (!is_wow64
) return TRUE
;
172 if (RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
174 ret
= !RegQueryValueExA( hkey
, "ProgramFilesDir (x86)", NULL
, &type
, (BYTE
*)buffer
, &size
);
179 static BOOL
check_display_driver(void)
181 HWND hwnd
= CreateWindowA( "STATIC", "", WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0,
182 0, 0, GetModuleHandleA(0), 0 );
183 if (!hwnd
) return FALSE
;
184 DestroyWindow( hwnd
);
188 static BOOL
running_on_visible_desktop (void)
191 HMODULE huser32
= GetModuleHandleA("user32.dll");
192 HWINSTA (WINAPI
*pGetProcessWindowStation
)(void);
193 BOOL (WINAPI
*pGetUserObjectInformationA
)(HANDLE
,INT
,LPVOID
,DWORD
,LPDWORD
);
195 pGetProcessWindowStation
= (void *)GetProcAddress(huser32
, "GetProcessWindowStation");
196 pGetUserObjectInformationA
= (void *)GetProcAddress(huser32
, "GetUserObjectInformationA");
198 desktop
= GetDesktopWindow();
199 if (!GetWindowLongPtrW(desktop
, GWLP_WNDPROC
)) /* Win9x */
200 return IsWindowVisible(desktop
);
202 if (pGetProcessWindowStation
&& pGetUserObjectInformationA
)
206 USEROBJECTFLAGS uoflags
;
208 wstation
= pGetProcessWindowStation();
209 assert(pGetUserObjectInformationA(wstation
, UOI_FLAGS
, &uoflags
, sizeof(uoflags
), &len
));
210 return (uoflags
.dwFlags
& WSF_VISIBLE
) != 0;
212 return IsWindowVisible(desktop
);
215 static int running_as_admin (void)
217 PSID administrators
= NULL
;
218 SID_IDENTIFIER_AUTHORITY nt_authority
= { SECURITY_NT_AUTHORITY
};
221 PTOKEN_GROUPS groups
;
224 /* Create a well-known SID for the Administrators group. */
225 if (! AllocateAndInitializeSid(&nt_authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
226 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
230 /* Get the process token */
231 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
233 FreeSid(administrators
);
237 /* Get the group info from the token */
239 GetTokenInformation(token
, TokenGroups
, NULL
, 0, &groups_size
);
240 groups
= heap_alloc(groups_size
);
244 FreeSid(administrators
);
247 if (! GetTokenInformation(token
, TokenGroups
, groups
, groups_size
, &groups_size
))
251 FreeSid(administrators
);
256 /* Now check if the token groups include the Administrators group */
257 for (group_index
= 0; group_index
< groups
->GroupCount
; group_index
++)
259 if (EqualSid(groups
->Groups
[group_index
].Sid
, administrators
))
262 FreeSid(administrators
);
267 /* If we end up here we didn't find the Administrators group */
269 FreeSid(administrators
);
273 static int running_elevated (void)
276 TOKEN_ELEVATION elevation_info
;
279 /* Get the process token */
280 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
283 /* Get the elevation info from the token */
284 if (! GetTokenInformation(token
, TokenElevation
, &elevation_info
,
285 sizeof(TOKEN_ELEVATION
), &size
))
292 return elevation_info
.TokenIsElevated
;
295 /* check for native dll when running under wine */
296 static BOOL
is_native_dll( HMODULE module
)
298 static const char builtin_signature
[] = "Wine builtin DLL";
299 static const char fakedll_signature
[] = "Wine placeholder DLL";
300 const IMAGE_DOS_HEADER
*dos
;
302 if (!running_under_wine()) return FALSE
;
303 if (!((ULONG_PTR
)module
& 1)) return FALSE
; /* not loaded as datafile */
304 /* builtin dlls can't be loaded as datafile, so we must have native or fake dll */
305 dos
= (const IMAGE_DOS_HEADER
*)((const char *)module
- 1);
306 if (dos
->e_magic
!= IMAGE_DOS_SIGNATURE
) return FALSE
;
307 if (dos
->e_lfanew
>= sizeof(*dos
) + 32)
309 if (!memcmp( dos
+ 1, builtin_signature
, sizeof(builtin_signature
) )) return FALSE
;
310 if (!memcmp( dos
+ 1, fakedll_signature
, sizeof(fakedll_signature
) )) return FALSE
;
316 * Windows 8 has a concept of stub DLLs. When DLLMain is called the user is prompted
317 * to install that component. To bypass this check we need to look at the version resource.
319 static BOOL
is_stub_dll(const char *filename
)
325 size
= GetFileVersionInfoSizeA(filename
, &ver
);
326 if (!size
) return FALSE
;
328 data
= HeapAlloc(GetProcessHeap(), 0, size
);
329 if (!data
) return FALSE
;
331 if (GetFileVersionInfoA(filename
, ver
, size
, data
))
335 sprintf(buf
, "\\StringFileInfo\\%04x%04x\\OriginalFilename", MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), 1200);
336 if (VerQueryValueA(data
, buf
, (void**)&p
, &size
))
337 isstub
= !lstrcmpiA("wcodstub.dll", p
);
339 HeapFree(GetProcessHeap(), 0, data
);
344 static void print_version (void)
347 static const char platform
[] = "i386";
348 #elif defined(__x86_64__)
349 static const char platform
[] = "x86_64";
350 #elif defined(__arm__)
351 static const char platform
[] = "arm";
352 #elif defined(__aarch64__)
353 static const char platform
[] = "arm64";
357 OSVERSIONINFOEXA ver
;
358 RTL_OSVERSIONINFOEXW rtlver
;
360 int is_win2k3_r2
, is_admin
, is_elevated
;
361 const char *(CDECL
*wine_get_build_id
)(void);
362 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
363 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
364 BOOL (WINAPI
*pGetProductInfo
)(DWORD
, DWORD
, DWORD
, DWORD
, DWORD
*);
365 NTSTATUS (WINAPI
*pRtlGetVersion
)(RTL_OSVERSIONINFOEXW
*);
367 ver
.dwOSVersionInfoSize
= sizeof(ver
);
368 if (!(ext
= GetVersionExA ((OSVERSIONINFOA
*) &ver
)))
370 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
371 if (!GetVersionExA ((OSVERSIONINFOA
*) &ver
))
372 report (R_FATAL
, "Can't get OS version.");
375 /* try to get non-faked values */
376 if (ver
.dwMajorVersion
== 6 && ver
.dwMinorVersion
== 2)
378 rtlver
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
380 pRtlGetVersion
= (void *)GetProcAddress(hntdll
, "RtlGetVersion");
381 pRtlGetVersion(&rtlver
);
383 ver
.dwMajorVersion
= rtlver
.dwMajorVersion
;
384 ver
.dwMinorVersion
= rtlver
.dwMinorVersion
;
385 ver
.dwBuildNumber
= rtlver
.dwBuildNumber
;
386 ver
.dwPlatformId
= rtlver
.dwPlatformId
;
387 ver
.wServicePackMajor
= rtlver
.wServicePackMajor
;
388 ver
.wServicePackMinor
= rtlver
.wServicePackMinor
;
389 ver
.wSuiteMask
= rtlver
.wSuiteMask
;
390 ver
.wProductType
= rtlver
.wProductType
;
392 WideCharToMultiByte(CP_ACP
, 0, rtlver
.szCSDVersion
, -1, ver
.szCSDVersion
, sizeof(ver
.szCSDVersion
), NULL
, NULL
);
395 xprintf (" Platform=%s%s\n", platform
, is_wow64
? " (WOW64)" : "");
396 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
397 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
398 is_admin
= running_as_admin ();
401 xprintf (" Account=%s", is_admin
? "admin" : "non-admin");
402 is_elevated
= running_elevated ();
403 if (0 <= is_elevated
)
404 xprintf(", %s", is_elevated
? "elevated" : "not elevated");
407 xprintf (" Submitter=%s\n", email
);
409 xprintf (" Description=%s\n", description
);
411 xprintf (" URL=%s\n", url
);
412 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
413 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
414 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
415 ver
.dwPlatformId
, ver
.szCSDVersion
);
417 wine_get_build_id
= (void *)GetProcAddress(hntdll
, "wine_get_build_id");
418 wine_get_host_version
= (void *)GetProcAddress(hntdll
, "wine_get_host_version");
419 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
420 if (wine_get_host_version
)
422 const char *sysname
, *release
;
423 wine_get_host_version( &sysname
, &release
);
424 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
426 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
428 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
432 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
433 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
434 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
435 ver
.wProductType
, ver
.wReserved
);
437 pGetProductInfo
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"GetProductInfo");
438 if (pGetProductInfo
&& !running_under_wine())
442 pGetProductInfo(ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.wServicePackMajor
, ver
.wServicePackMinor
, &prodtype
);
443 xprintf(" dwProductInfo=%u\n", prodtype
);
447 static void print_language(void)
450 BOOL (WINAPI
*pGetSystemPreferredUILanguages
)(DWORD
, PULONG
, PZZWSTR
, PULONG
);
451 LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
452 LANGID (WINAPI
*pGetThreadUILanguage
)(void);
454 xprintf (" SystemDefaultLCID=%04x\n", GetSystemDefaultLCID());
455 xprintf (" UserDefaultLCID=%04x\n", GetUserDefaultLCID());
456 xprintf (" ThreadLocale=%04x\n", GetThreadLocale());
458 hkernel32
= GetModuleHandleA("kernel32.dll");
459 pGetSystemPreferredUILanguages
= (void*)GetProcAddress(hkernel32
, "GetSystemPreferredUILanguages");
460 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
461 pGetThreadUILanguage
= (void*)GetProcAddress(hkernel32
, "GetThreadUILanguage");
463 if (pGetSystemPreferredUILanguages
&& !running_under_wine())
466 ULONG num
, size
= ARRAY_SIZE(langW
);
467 if (pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID
, &num
, langW
, &size
))
469 char lang
[32], *p
= lang
;
470 WideCharToMultiByte(CP_ACP
, 0, langW
, size
, lang
, sizeof(lang
), NULL
, NULL
);
471 for (p
+= strlen(p
) + 1; *p
!= '\0'; p
+= strlen(p
) + 1) *(p
- 1) = ',';
472 xprintf (" SystemPreferredUILanguages=%s\n", lang
);
475 if (pGetUserDefaultUILanguage
)
476 xprintf (" UserDefaultUILanguage=%04x\n", pGetUserDefaultUILanguage());
477 if (pGetThreadUILanguage
)
478 xprintf (" ThreadUILanguage=%04x\n", pGetThreadUILanguage());
481 static inline BOOL
is_dot_dir(const char* x
)
483 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
486 static void remove_dir (const char *dir
)
489 WIN32_FIND_DATAA wfd
;
491 size_t dirlen
= strlen (dir
);
493 /* Make sure the directory exists before going further */
494 memcpy (path
, dir
, dirlen
);
495 strcpy (path
+ dirlen
++, "\\*");
496 hFind
= FindFirstFileA (path
, &wfd
);
497 if (hFind
== INVALID_HANDLE_VALUE
) return;
500 char *lp
= wfd
.cFileName
;
502 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
503 if (is_dot_dir (lp
)) continue;
504 strcpy (path
+ dirlen
, lp
);
505 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
507 else if (!DeleteFileA(path
))
508 report (R_WARNING
, "Can't delete file %s: error %d",
509 path
, GetLastError ());
510 } while (FindNextFileA(hFind
, &wfd
));
512 if (!RemoveDirectoryA(dir
))
513 report (R_WARNING
, "Can't remove directory %s: error %d",
514 dir
, GetLastError ());
517 static const char* get_test_source_file(const char* test
, const char* subtest
)
519 static char buffer
[MAX_PATH
];
520 int len
= strlen(test
);
522 if (len
> 4 && !strcmp( test
+ len
- 4, ".exe" ) &&
523 strcmp( test
, "ntoskrnl.exe" )) /* the one exception! */
525 len
= sprintf(buffer
, "programs/%s", test
) - 4;
528 else len
= sprintf(buffer
, "dlls/%s", test
);
530 sprintf(buffer
+ len
, "/tests/%s.c", subtest
);
534 static void* extract_rcdata (LPCSTR name
, LPCSTR type
, DWORD
* size
)
540 if (!(rsrc
= FindResourceA(NULL
, name
, type
)) ||
541 !(*size
= SizeofResource (0, rsrc
)) ||
542 !(hdl
= LoadResource (0, rsrc
)) ||
543 !(addr
= LockResource (hdl
)))
548 /* Fills in the name and exename fields */
550 extract_test (struct wine_test
*test
, const char *dir
, LPSTR res_name
)
558 code
= extract_rcdata (res_name
, "TESTRES", &size
);
559 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
560 res_name
, GetLastError ());
561 test
->name
= heap_strdup( res_name
);
562 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
563 exepos
= strstr (test
->name
, testexe
);
564 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
566 test
->name
= heap_realloc (test
->name
, exepos
- test
->name
+ 1);
567 report (R_STEP
, "Extracting: %s", test
->name
);
569 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
570 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
571 if (hfile
== INVALID_HANDLE_VALUE
)
572 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
574 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
575 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
580 static DWORD
wait_process( HANDLE process
, DWORD timeout
)
582 DWORD wait
, diff
= 0, start
= GetTickCount();
585 while (diff
< timeout
)
587 wait
= MsgWaitForMultipleObjects( 1, &process
, FALSE
, timeout
- diff
, QS_ALLINPUT
);
588 if (wait
!= WAIT_OBJECT_0
+ 1) return wait
;
589 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
590 diff
= GetTickCount() - start
;
595 static void append_path( const char *path
)
599 newpath
= heap_alloc(strlen(curpath
) + 1 + strlen(path
) + 1);
600 strcpy(newpath
, curpath
);
601 strcat(newpath
, ";");
602 strcat(newpath
, path
);
603 SetEnvironmentVariableA("PATH", newpath
);
608 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
611 Return the exit status, -2 if can't create process or the return
612 value of WaitForSingleObject.
615 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
, BOOL nocritical
, DWORD
* pid
)
618 PROCESS_INFORMATION pi
;
619 DWORD wait
, status
, flags
;
622 /* Flush to disk so we know which test caused Windows to crash if it does */
624 FlushFileBuffers(out_file
);
626 GetStartupInfoA (&si
);
627 si
.dwFlags
= STARTF_USESTDHANDLES
;
628 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
629 si
.hStdOutput
= out_file
? out_file
: GetStdHandle( STD_OUTPUT_HANDLE
);
630 si
.hStdError
= out_file
? out_file
: GetStdHandle( STD_ERROR_HANDLE
);
633 old_errmode
= SetErrorMode(0);
634 SetErrorMode(old_errmode
| SEM_FAILCRITICALERRORS
);
638 flags
= CREATE_DEFAULT_ERROR_MODE
;
640 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, flags
,
641 NULL
, tempdir
, &si
, &pi
))
643 if (nocritical
) SetErrorMode(old_errmode
);
648 if (nocritical
) SetErrorMode(old_errmode
);
649 CloseHandle (pi
.hThread
);
650 if (pid
) *pid
= pi
.dwProcessId
;
651 status
= wait_process( pi
.hProcess
, ms
);
655 GetExitCodeProcess (pi
.hProcess
, &status
);
656 CloseHandle (pi
.hProcess
);
659 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
, GetLastError ());
664 report (R_ERROR
, "Wait returned %d", status
);
667 if (!TerminateProcess (pi
.hProcess
, 257))
668 report (R_ERROR
, "TerminateProcess failed: %d", GetLastError ());
669 wait
= wait_process( pi
.hProcess
, 5000 );
675 report (R_ERROR
, "Wait for termination of '%s' failed: %d", cmd
, GetLastError ());
678 report (R_ERROR
, "Can't kill process '%s'", cmd
);
681 report (R_ERROR
, "Waiting for termination: %d", wait
);
684 CloseHandle (pi
.hProcess
);
689 get_subtests (const char *tempdir
, struct wine_test
*test
, LPSTR res_name
)
694 char buffer
[8192], *index
;
695 static const char header
[] = "Valid test names:";
696 int status
, allocated
;
697 char tmpdir
[MAX_PATH
], subname
[MAX_PATH
];
698 SECURITY_ATTRIBUTES sa
;
700 test
->subtest_count
= 0;
702 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
703 !GetTempFileNameA( tmpdir
, "sub", 0, subname
))
704 report (R_FATAL
, "Can't name subtests file.");
706 /* make handle inheritable */
707 sa
.nLength
= sizeof(sa
);
708 sa
.lpSecurityDescriptor
= NULL
;
709 sa
.bInheritHandle
= TRUE
;
711 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
712 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
713 &sa
, CREATE_ALWAYS
, 0, NULL
);
715 if ((subfile
== INVALID_HANDLE_VALUE
) &&
716 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
717 /* FILE_SHARE_DELETE not supported on win9x */
718 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
719 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
720 &sa
, CREATE_ALWAYS
, 0, NULL
);
722 if (subfile
== INVALID_HANDLE_VALUE
) {
723 err
= GetLastError();
724 report (R_ERROR
, "Can't open subtests output of %s: %u",
725 test
->name
, GetLastError());
729 cmd
= strmake (NULL
, "%s --list", test
->exename
);
730 if (test
->maindllpath
) {
731 /* We need to add the path (to the main dll) to PATH */
732 append_path(test
->maindllpath
);
734 status
= run_ex (cmd
, subfile
, tempdir
, 5000, TRUE
, NULL
);
735 err
= GetLastError();
736 if (test
->maindllpath
) {
737 /* Restore PATH again */
738 SetEnvironmentVariableA("PATH", curpath
);
745 report (R_ERROR
, "Cannot run %s error %u", test
->exename
, err
);
748 CloseHandle( subfile
);
752 SetFilePointer( subfile
, 0, NULL
, FILE_BEGIN
);
753 ReadFile( subfile
, buffer
, sizeof(buffer
), &total
, NULL
);
754 CloseHandle( subfile
);
755 if (sizeof buffer
== total
) {
756 report (R_ERROR
, "Subtest list of %s too big.",
757 test
->name
, sizeof buffer
);
758 err
= ERROR_OUTOFMEMORY
;
763 index
= strstr (buffer
, header
);
765 report (R_ERROR
, "Can't parse subtests output of %s",
767 err
= ERROR_INTERNAL_ERROR
;
770 index
+= sizeof header
;
773 test
->subtests
= heap_alloc (allocated
* sizeof(char*));
774 index
= strtok (index
, whitespace
);
776 if (test
->subtest_count
== allocated
) {
778 test
->subtests
= heap_realloc (test
->subtests
,
779 allocated
* sizeof(char*));
781 test
->subtests
[test
->subtest_count
++] = heap_strdup(index
);
782 index
= strtok (NULL
, whitespace
);
784 test
->subtests
= heap_realloc (test
->subtests
,
785 test
->subtest_count
* sizeof(char*));
789 if (!DeleteFileA (subname
))
790 report (R_WARNING
, "Can't delete file '%s': %u", subname
, GetLastError());
795 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
797 /* Build the source filename so analysis tools can link to it */
798 const char* file
= get_test_source_file(test
->name
, subtest
);
800 if (test_filtered_out( test
->name
, subtest
))
802 report (R_STEP
, "Skipping: %s:%s", test
->name
, subtest
);
803 xprintf ("%s:%s skipped %s\n", test
->name
, subtest
, file
);
809 DWORD pid
, start
= GetTickCount();
810 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
811 report (R_STEP
, "Running: %s:%s", test
->name
, subtest
);
812 xprintf ("%s:%s start %s\n", test
->name
, subtest
, file
);
813 status
= run_ex (cmd
, out_file
, tempdir
, 120000, FALSE
, &pid
);
814 if (status
== -2) status
= -GetLastError();
816 xprintf ("%s:%s:%04x done (%d) in %ds\n", test
->name
, subtest
, pid
, status
, (GetTickCount()-start
)/1000);
817 if (status
) failures
++;
819 if (failures
) report (R_STATUS
, "Running tests - %u failures", failures
);
823 EnumTestFileProc (HMODULE hModule
, LPCSTR lpszType
,
824 LPSTR lpszName
, LONG_PTR lParam
)
826 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
830 static const struct clsid_mapping
836 {"oledb32", {0xc8b522d1, 0x5cf3, 0x11ce, {0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d}}},
837 {NULL
, {0, 0, 0, {0,0,0,0,0,0,0,0}}}
841 static BOOL
get_main_clsid(const char *name
, CLSID
*clsid
)
843 const struct clsid_mapping
*mapping
;
845 for(mapping
= clsid_list
; mapping
->name
; mapping
++)
847 if(!strcasecmp(name
, mapping
->name
))
849 *clsid
= mapping
->clsid
;
856 static HMODULE
load_com_dll(const char *name
, char **path
, char *filename
)
861 char dllname
[MAX_PATH
];
865 if(!get_main_clsid(name
, &clsid
)) return NULL
;
867 sprintf(keyname
, "CLSID\\{%08x-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
868 clsid
.Data1
, clsid
.Data2
, clsid
.Data3
, clsid
.Data4
[0], clsid
.Data4
[1],
869 clsid
.Data4
[2], clsid
.Data4
[3], clsid
.Data4
[4], clsid
.Data4
[5],
870 clsid
.Data4
[6], clsid
.Data4
[7]);
872 if(RegOpenKeyA(HKEY_CLASSES_ROOT
, keyname
, &hkey
) == ERROR_SUCCESS
)
874 LONG size
= sizeof(dllname
);
875 if(RegQueryValueA(hkey
, NULL
, dllname
, &size
) == ERROR_SUCCESS
)
877 if ((dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
)))
879 strcpy( filename
, dllname
);
880 p
= strrchr(dllname
, '\\');
882 *path
= heap_strdup( dllname
);
891 static void get_dll_path(HMODULE dll
, char **path
, char *filename
)
893 char dllpath
[MAX_PATH
];
895 GetModuleFileNameA(dll
, dllpath
, MAX_PATH
);
896 strcpy(filename
, dllpath
);
897 *strrchr(dllpath
, '\\') = '\0';
898 *path
= heap_strdup( dllpath
);
902 extract_test_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
904 const char *tempdir
= (const char *)lParam
;
905 char dllname
[MAX_PATH
];
906 char filename
[MAX_PATH
];
907 WCHAR dllnameW
[MAX_PATH
];
914 if (aborting
) return TRUE
;
916 /* Check if the main dll is present on this system */
917 CharLowerA(lpszName
);
918 strcpy(dllname
, lpszName
);
919 *strstr(dllname
, testexe
) = 0;
921 if (test_filtered_out( lpszName
, NULL
))
924 if (exclude_tests
) xprintf (" %s=skipped\n", dllname
);
927 extract_test (&wine_tests
[nr_of_files
], tempdir
, lpszName
);
929 if (pCreateActCtxA
!= NULL
&& pActivateActCtx
!= NULL
&&
930 pDeactivateActCtx
!= NULL
&& pReleaseActCtx
!= NULL
)
933 memset(&actctxinfo
, 0, sizeof(ACTCTXA
));
934 actctxinfo
.cbSize
= sizeof(ACTCTXA
);
935 actctxinfo
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
936 actctxinfo
.lpSource
= wine_tests
[nr_of_files
].exename
;
937 actctxinfo
.lpResourceName
= (LPSTR
)CREATEPROCESS_MANIFEST_RESOURCE_ID
;
938 actctx
= pCreateActCtxA(&actctxinfo
);
939 if (actctx
!= INVALID_HANDLE_VALUE
&&
940 ! pActivateActCtx(actctx
, &cookie
))
942 pReleaseActCtx(actctx
);
943 actctx
= INVALID_HANDLE_VALUE
;
945 } else actctx
= INVALID_HANDLE_VALUE
;
947 wine_tests
[nr_of_files
].maindllpath
= NULL
;
948 strcpy(filename
, dllname
);
949 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
951 if (!dll
) dll
= load_com_dll(dllname
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
953 if (!dll
&& pLoadLibraryShim
)
955 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
956 if (SUCCEEDED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) ) && dll
)
958 get_dll_path(dll
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
960 dll
= LoadLibraryExA(filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
968 if (is_stub_dll(dllname
))
970 xprintf (" %s=dll is a stub\n", dllname
);
973 else if (is_native_dll(dll
))
975 xprintf (" %s=dll is native\n", dllname
);
984 err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
);
988 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
989 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
992 case STATUS_DLL_NOT_FOUND
:
993 xprintf (" %s=dll is missing\n", dllname
);
994 /* or it is a side-by-side dll but the test has no manifest */
996 case STATUS_ORDINAL_NOT_FOUND
:
997 xprintf (" %s=dll is missing an ordinal (%s)\n", dllname
, get_file_version(filename
));
999 case STATUS_ENTRYPOINT_NOT_FOUND
:
1000 xprintf (" %s=dll is missing an entrypoint (%s)\n", dllname
, get_file_version(filename
));
1002 case ERROR_SXS_CANT_GEN_ACTCTX
:
1003 xprintf (" %s=dll is missing the requested side-by-side version\n", dllname
);
1006 xprintf (" %s=load error %u\n", dllname
, err
);
1011 if (actctx
!= INVALID_HANDLE_VALUE
)
1013 pDeactivateActCtx(0, cookie
);
1014 pReleaseActCtx(actctx
);
1020 run_tests (char *logname
, char *outdir
)
1023 char *strres
, *eol
, *nextline
;
1025 SECURITY_ATTRIBUTES sa
;
1026 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
1031 /* Get the current PATH only once */
1032 needed
= GetEnvironmentVariableA("PATH", NULL
, 0);
1033 curpath
= heap_alloc(needed
);
1034 GetEnvironmentVariableA("PATH", curpath
, needed
);
1036 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
1038 if (!GetTempPathA( MAX_PATH
, tmppath
))
1039 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1042 static char tmpname
[MAX_PATH
];
1043 if (!GetTempFileNameA( tmppath
, "res", 0, tmpname
))
1044 report (R_FATAL
, "Can't name logfile.");
1047 report (R_OUT
, logname
);
1049 /* make handle inheritable */
1050 sa
.nLength
= sizeof(sa
);
1051 sa
.lpSecurityDescriptor
= NULL
;
1052 sa
.bInheritHandle
= TRUE
;
1054 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
1055 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1056 &sa
, CREATE_ALWAYS
, 0, NULL
);
1058 if ((logfile
== INVALID_HANDLE_VALUE
) &&
1059 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
1060 /* FILE_SHARE_DELETE not supported on win9x */
1061 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
1062 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1063 &sa
, CREATE_ALWAYS
, 0, NULL
);
1065 if (logfile
== INVALID_HANDLE_VALUE
)
1066 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
1070 /* Get a full path so it is still valid after a chdir */
1071 GetFullPathNameA( outdir
, ARRAY_SIZE(tempdir
), tempdir
, NULL
);
1075 strcpy( tempdir
, tmppath
);
1076 strcat( tempdir
, "wct" ); /* try stable path for ZoneAlarm */
1078 newdir
= CreateDirectoryA( tempdir
, NULL
);
1079 if (!newdir
&& !outdir
)
1081 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
1082 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1083 DeleteFileA( tempdir
);
1084 newdir
= CreateDirectoryA( tempdir
, NULL
);
1086 if (!newdir
&& (!outdir
|| GetLastError() != ERROR_ALREADY_EXISTS
))
1087 report (R_FATAL
, "Could not create directory %s (%d)", tempdir
, GetLastError());
1089 report (R_DIR
, tempdir
);
1091 xprintf ("Version 4\n");
1092 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
1093 xprintf ("Archive: -\n"); /* no longer used */
1094 xprintf ("Tag: %s\n", tag
);
1095 xprintf ("Build info:\n");
1096 strres
= extract_rcdata ("BUILD_INFO", "STRINGRES", &strsize
);
1098 eol
= memchr (strres
, '\n', strsize
);
1101 eol
= strres
+ strsize
;
1103 strsize
-= eol
- strres
+ 1;
1104 nextline
= strsize
?eol
+1:NULL
;
1105 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
1107 xprintf (" %.*s\n", eol
-strres
, strres
);
1110 xprintf ("Operating system version:\n");
1113 xprintf ("Dll info:\n" );
1115 report (R_STATUS
, "Counting tests");
1116 if (!EnumResourceNamesA (NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1117 report (R_FATAL
, "Can't enumerate test files: %d",
1119 wine_tests
= heap_alloc (nr_of_files
* sizeof wine_tests
[0]);
1121 /* Do this only once during extraction (and version checking) */
1122 hmscoree
= LoadLibraryA("mscoree.dll");
1123 pLoadLibraryShim
= NULL
;
1125 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
1126 kernel32
= GetModuleHandleA("kernel32.dll");
1127 pCreateActCtxA
= (void *)GetProcAddress(kernel32
, "CreateActCtxA");
1128 pActivateActCtx
= (void *)GetProcAddress(kernel32
, "ActivateActCtx");
1129 pDeactivateActCtx
= (void *)GetProcAddress(kernel32
, "DeactivateActCtx");
1130 pReleaseActCtx
= (void *)GetProcAddress(kernel32
, "ReleaseActCtx");
1132 report (R_STATUS
, "Extracting tests");
1133 report (R_PROGRESS
, 0, nr_of_files
);
1137 if (!EnumResourceNamesA (NULL
, "TESTRES", extract_test_proc
, (LPARAM
)tempdir
))
1138 report (R_FATAL
, "Can't enumerate test files: %d",
1141 FreeLibrary(hmscoree
);
1143 if (aborting
) return logname
;
1145 xprintf ("Test output:\n" );
1147 report (R_DELTA
, 0, "Extracting: Done");
1150 report( R_WARNING
, "Some dlls are configured as native, you won't be able to submit results." );
1152 report (R_STATUS
, "Running tests");
1153 report (R_PROGRESS
, 1, nr_of_tests
);
1154 for (i
= 0; i
< nr_of_files
; i
++) {
1155 struct wine_test
*test
= wine_tests
+ i
;
1158 if (aborting
) break;
1160 if (test
->maindllpath
) {
1161 /* We need to add the path (to the main dll) to PATH */
1162 append_path(test
->maindllpath
);
1165 for (j
= 0; j
< test
->subtest_count
; j
++) {
1166 if (aborting
) break;
1167 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
1170 if (test
->maindllpath
) {
1171 /* Restore PATH again */
1172 SetEnvironmentVariableA("PATH", curpath
);
1175 report (R_DELTA
, 0, "Running: Done");
1177 report (R_STATUS
, "Cleaning up - %u failures", failures
);
1178 CloseHandle( logfile
);
1181 remove_dir (tempdir
);
1182 heap_free(wine_tests
);
1188 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
1190 if (ctrl_type
== CTRL_C_EVENT
) {
1191 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
1199 static BOOL CALLBACK
1200 extract_only_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
1202 const char *target_dir
= (const char *)lParam
;
1203 char filename
[MAX_PATH
];
1205 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
1207 strcpy(filename
, lpszName
);
1208 CharLowerA(filename
);
1210 extract_test( &wine_tests
[nr_of_files
], target_dir
, filename
);
1215 static void extract_only (const char *target_dir
)
1219 report (R_DIR
, target_dir
);
1220 res
= CreateDirectoryA( target_dir
, NULL
);
1221 if (!res
&& GetLastError() != ERROR_ALREADY_EXISTS
)
1222 report (R_FATAL
, "Could not create directory: %s (%d)", target_dir
, GetLastError ());
1225 report (R_STATUS
, "Counting tests");
1226 if (!EnumResourceNamesA(NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1227 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1229 wine_tests
= heap_alloc (nr_of_files
* sizeof wine_tests
[0] );
1231 report (R_STATUS
, "Extracting tests");
1232 report (R_PROGRESS
, 0, nr_of_files
);
1234 if (!EnumResourceNamesA(NULL
, "TESTRES", extract_only_proc
, (LPARAM
)target_dir
))
1235 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1237 report (R_DELTA
, 0, "Extracting: Done");
1244 "Usage: winetest [OPTION]... [TESTS]\n\n"
1245 " --help print this message and exit\n"
1246 " --version print the build version and exit\n"
1247 " -c console mode, no GUI\n"
1248 " -d DIR Use DIR as temp directory (default: %%TEMP%%\\wct)\n"
1249 " -e preserve the environment\n"
1250 " -h print this message and exit\n"
1251 " -i INFO an optional description of the test platform\n"
1252 " -m MAIL an email address to enable developers to contact you\n"
1253 " -n exclude the specified tests\n"
1254 " -p shutdown when the tests are done\n"
1255 " -q quiet mode, no output at all\n"
1256 " -o FILE put report into FILE, do not submit\n"
1257 " -s FILE submit FILE, do not run tests\n"
1258 " -S URL URL to submit the results to\n"
1259 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"
1260 " -u URL include TestBot URL in the report\n"
1261 " -x DIR Extract tests to DIR (default: .\\wct) and exit\n");
1264 int __cdecl
main( int argc
, char *argv
[] )
1266 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
1267 char *logname
= NULL
, *outdir
= NULL
;
1268 const char *extract
= NULL
;
1269 const char *cp
, *submit
= NULL
, *submiturl
= NULL
;
1272 int interactive
= 1;
1275 InitCommonControls();
1277 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
1279 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
1280 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &is_wow64
)) is_wow64
= FALSE
;
1282 for (i
= 1; i
< argc
&& argv
[i
]; i
++)
1284 if (!strcmp(argv
[i
], "--help")) {
1288 else if (!strcmp(argv
[i
], "--version")) {
1289 printf("%-12.12s\n", build_id
[0] ? build_id
: "unknown");
1292 else if ((argv
[i
][0] != '-' && argv
[i
][0] != '/') || argv
[i
][2]) {
1293 if (nb_filters
== ARRAY_SIZE(filters
))
1295 report (R_ERROR
, "Too many test filters specified");
1298 filters
[nb_filters
++] = argv
[i
];
1300 else switch (argv
[i
][1]) {
1302 report (R_TEXTMODE
);
1313 if (!(description
= argv
[++i
]))
1320 if (!(email
= argv
[++i
]))
1327 exclude_tests
= TRUE
;
1337 if (!(submit
= argv
[++i
]))
1344 if (!(submiturl
= argv
[++i
]))
1351 if (!(logname
= argv
[++i
]))
1358 if (!(tag
= argv
[++i
]))
1363 if (strlen (tag
) > MAXTAGLEN
)
1364 report (R_FATAL
, "tag is too long (maximum %d characters)",
1366 cp
= findbadtagchar (tag
);
1368 report (R_ERROR
, "invalid char in tag: %c", *cp
);
1374 if (!(url
= argv
[++i
]))
1381 report (R_TEXTMODE
);
1382 if (!(extract
= argv
[++i
]))
1385 extract_only (extract
);
1391 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
1398 report (R_WARNING
, "ignoring tag for submission");
1399 send_file (submiturl
, submit
);
1401 } else if (!extract
) {
1402 int is_win9x
= (GetVersion() & 0x80000000) != 0;
1404 report (R_STATUS
, "Starting up");
1407 report (R_WARNING
, "Running on win9x is not supported. You won't be able to submit results.");
1409 if (!running_on_visible_desktop ())
1410 report (R_FATAL
, "Tests must be run on a visible desktop");
1412 if (running_under_wine())
1414 if (!check_mount_mgr())
1415 report (R_FATAL
, "Mount manager not running, most likely your WINEPREFIX wasn't created correctly.");
1417 if (!check_wow64_registry())
1418 report (R_FATAL
, "WoW64 keys missing, most likely your WINEPREFIX wasn't created correctly.");
1420 if (!check_display_driver())
1421 report (R_FATAL
, "Unable to create a window, the display driver is not working.");
1424 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
1428 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
1429 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
1430 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
1431 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
1434 if (nb_filters
&& !exclude_tests
)
1436 run_tests( logname
, outdir
);
1442 report (R_FATAL
, "Please specify a tag (-t option) if "
1443 "running noninteractive!");
1444 if (guiAskTag () == IDABORT
) exit (1);
1450 report (R_FATAL
, "Please specify an email address (-m option) to enable developers\n"
1451 " to contact you about your report if necessary.");
1452 if (guiAskEmail () == IDABORT
) exit (1);
1456 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
1457 "To submit results, winetest needs to be built from a git checkout." );
1460 logname
= run_tests (NULL
, outdir
);
1462 DeleteFileA(logname
);
1465 if (failures
> FAILURES_LIMIT
)
1467 "%d tests failed. There is probably something broken with your setup.\n"
1468 "You need to address this before submitting results.", failures
);
1470 if (build_id
[0] && nr_of_skips
<= SKIP_LIMIT
&& failures
<= FAILURES_LIMIT
&&
1471 !nr_native_dlls
&& !is_win9x
&&
1472 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
1473 if (!send_file (submiturl
, logname
) && !DeleteFileA(logname
))
1474 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
1475 } else run_tests (logname
, outdir
);
1476 report (R_STATUS
, "Finished - %u failures", failures
);
1481 TOKEN_PRIVILEGES npr
;
1483 /* enable the shutdown privilege for the current process */
1484 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1486 LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr
.Privileges
[0].Luid
);
1487 npr
.PrivilegeCount
= 1;
1488 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1489 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
1490 CloseHandle(hToken
);
1492 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);