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
45 /* Maximum output size for individual test */
46 #define MAX_OUTPUT_SIZE (32 * 1024)
58 char *description
= NULL
;
61 BOOL aborting
= FALSE
;
62 static struct wine_test
*wine_tests
;
63 static int nr_of_files
, nr_of_tests
, nr_of_skips
;
64 static int nr_native_dlls
;
65 static const char whitespace
[] = " \t\r\n";
66 static const char testexe
[] = "_test.exe";
67 static char build_id
[64];
70 static int quiet_mode
;
72 /* filters for running only specific tests */
73 static char **filters
;
74 static unsigned int nb_filters
;
75 static unsigned int alloc_filters
;
76 static BOOL exclude_tests
= FALSE
;
78 /* Needed to check for .NET dlls */
79 static HMODULE hmscoree
;
80 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR
, LPCWSTR
, LPVOID
, HMODULE
*);
82 /* For SxS DLLs e.g. msvcr90 */
83 static HANDLE (WINAPI
*pCreateActCtxA
)(PACTCTXA
);
84 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
, ULONG_PTR
*);
85 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
, ULONG_PTR
);
86 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
88 /* To store the current PATH setting (related to .NET only provided dlls) */
91 /* check if test is being filtered out */
92 static BOOL
test_filtered_out( LPCSTR module
, LPCSTR testname
)
94 char *p
, dllname
[MAX_PATH
];
97 strcpy( dllname
, module
);
98 CharLowerA( dllname
);
99 p
= strstr( dllname
, testexe
);
101 len
= strlen(dllname
);
103 if (!nb_filters
) return exclude_tests
;
104 for (i
= 0; i
< nb_filters
; i
++)
106 if (!strncmp( dllname
, filters
[i
], len
))
108 if (!filters
[i
][len
]) return exclude_tests
;
109 if (filters
[i
][len
] != ':') continue;
110 if (testname
&& !strcmp( testname
, &filters
[i
][len
+1] )) return exclude_tests
;
111 if (!testname
&& !exclude_tests
) return FALSE
;
114 return !exclude_tests
;
117 static void add_filter( const char *name
)
121 char *p
, *str
, buffer
[256];
122 FILE *f
= fopen( name
+ 1, "rt" );
125 while (fgets( buffer
, sizeof(buffer
), f
))
128 while (*p
== ' ' || *p
== '\t') p
++;
129 if (*p
== '#') continue;
131 while (*p
&& *p
!= ' ' && *p
!= '\t' && *p
!= '\r' && *p
!= '\n') p
++;
139 if (nb_filters
>= alloc_filters
)
141 alloc_filters
= max( alloc_filters
* 2, 64 );
142 filters
= xrealloc( filters
, alloc_filters
* sizeof(*filters
) );
144 filters
[nb_filters
++] = xstrdup(name
);
147 static HANDLE
create_output_file( const char *name
)
149 SECURITY_ATTRIBUTES sa
;
152 /* make handle inheritable */
153 sa
.nLength
= sizeof(sa
);
154 sa
.lpSecurityDescriptor
= NULL
;
155 sa
.bInheritHandle
= TRUE
;
157 file
= CreateFileA( name
, GENERIC_READ
|GENERIC_WRITE
,
158 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
159 &sa
, CREATE_ALWAYS
, 0, NULL
);
161 if (file
== INVALID_HANDLE_VALUE
&& GetLastError() == ERROR_INVALID_PARAMETER
)
163 /* FILE_SHARE_DELETE not supported on win9x */
164 file
= CreateFileA( name
, GENERIC_READ
|GENERIC_WRITE
,
165 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
166 &sa
, CREATE_ALWAYS
, 0, NULL
);
171 static HANDLE
create_temp_file( char name
[MAX_PATH
] )
173 char tmpdir
[MAX_PATH
];
175 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
176 !GetTempFileNameA( tmpdir
, "out", 0, name
))
177 report (R_FATAL
, "Can't name temp file.");
179 return create_output_file( name
);
182 static void close_temp_file( const char *name
, HANDLE file
)
188 static char *flush_temp_file( const char *name
, HANDLE file
, DWORD
*retsize
)
190 DWORD size
= SetFilePointer( file
, 0, NULL
, FILE_CURRENT
);
191 char *buffer
= xalloc( size
+ 1 );
193 SetFilePointer( file
, 0, NULL
, FILE_BEGIN
);
194 if (!ReadFile( file
, buffer
, size
, retsize
, NULL
)) *retsize
= 0;
195 close_temp_file( name
, file
);
196 buffer
[*retsize
] = 0;
200 static char * get_file_version(char * file_name
)
202 static char version
[32];
206 size
= GetFileVersionInfoSizeA(file_name
, &handle
);
208 char * data
= xalloc(size
);
209 if (GetFileVersionInfoA(file_name
, handle
, size
, data
)) {
210 static const char backslash
[] = "\\";
211 VS_FIXEDFILEINFO
*pFixedVersionInfo
;
213 if (VerQueryValueA(data
, backslash
, (LPVOID
*)&pFixedVersionInfo
, &len
)) {
214 sprintf(version
, "%ld.%ld.%ld.%ld",
215 pFixedVersionInfo
->dwFileVersionMS
>> 16,
216 pFixedVersionInfo
->dwFileVersionMS
& 0xffff,
217 pFixedVersionInfo
->dwFileVersionLS
>> 16,
218 pFixedVersionInfo
->dwFileVersionLS
& 0xffff);
220 sprintf(version
, "version not found");
222 sprintf(version
, "version error %lu", GetLastError());
224 } else if (GetLastError() == ERROR_FILE_NOT_FOUND
)
225 sprintf(version
, "dll is missing");
227 sprintf(version
, "version not present %lu", GetLastError());
232 static BOOL
running_under_wine (void)
234 HMODULE module
= GetModuleHandleA("ntdll.dll");
236 if (!module
) return FALSE
;
237 return (GetProcAddress(module
, "wine_server_call") != NULL
);
240 static BOOL
check_mount_mgr(void)
242 HANDLE handle
= CreateFileA( "\\\\.\\MountPointManager", GENERIC_READ
,
243 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
244 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
245 CloseHandle( handle
);
249 static BOOL
check_wow64_registry(void)
251 char buffer
[MAX_PATH
];
252 DWORD type
, size
= MAX_PATH
;
256 if (!is_wow64
) return TRUE
;
257 if (RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
259 ret
= !RegQueryValueExA( hkey
, "ProgramFilesDir (x86)", NULL
, &type
, (BYTE
*)buffer
, &size
);
264 static BOOL
check_display_driver(void)
266 HWND hwnd
= CreateWindowA( "STATIC", "", WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0,
267 0, 0, GetModuleHandleA(0), 0 );
268 if (!hwnd
) return FALSE
;
269 DestroyWindow( hwnd
);
273 static BOOL
running_on_visible_desktop (void)
276 HMODULE huser32
= GetModuleHandleA("user32.dll");
277 HWINSTA (WINAPI
*pGetProcessWindowStation
)(void);
278 BOOL (WINAPI
*pGetUserObjectInformationA
)(HANDLE
,INT
,LPVOID
,DWORD
,LPDWORD
);
280 pGetProcessWindowStation
= (void *)GetProcAddress(huser32
, "GetProcessWindowStation");
281 pGetUserObjectInformationA
= (void *)GetProcAddress(huser32
, "GetUserObjectInformationA");
283 desktop
= GetDesktopWindow();
284 if (!GetWindowLongPtrW(desktop
, GWLP_WNDPROC
)) /* Win9x */
285 return IsWindowVisible(desktop
);
287 if (pGetProcessWindowStation
&& pGetUserObjectInformationA
)
291 USEROBJECTFLAGS uoflags
;
293 wstation
= pGetProcessWindowStation();
294 assert(pGetUserObjectInformationA(wstation
, UOI_FLAGS
, &uoflags
, sizeof(uoflags
), &len
));
295 return (uoflags
.dwFlags
& WSF_VISIBLE
) != 0;
297 return IsWindowVisible(desktop
);
300 static int running_as_admin (void)
302 PSID administrators
= NULL
;
303 SID_IDENTIFIER_AUTHORITY nt_authority
= { SECURITY_NT_AUTHORITY
};
306 PTOKEN_GROUPS groups
;
309 /* Create a well-known SID for the Administrators group. */
310 if (! AllocateAndInitializeSid(&nt_authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
311 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
315 /* Get the process token */
316 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
318 FreeSid(administrators
);
322 /* Get the group info from the token */
324 GetTokenInformation(token
, TokenGroups
, NULL
, 0, &groups_size
);
325 groups
= xalloc(groups_size
);
326 if (! GetTokenInformation(token
, TokenGroups
, groups
, groups_size
, &groups_size
))
330 FreeSid(administrators
);
335 /* Now check if the token groups include the Administrators group */
336 for (group_index
= 0; group_index
< groups
->GroupCount
; group_index
++)
338 if (EqualSid(groups
->Groups
[group_index
].Sid
, administrators
))
341 FreeSid(administrators
);
346 /* If we end up here we didn't find the Administrators group */
348 FreeSid(administrators
);
352 static int running_elevated (void)
355 TOKEN_ELEVATION elevation_info
;
358 /* Get the process token */
359 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
362 /* Get the elevation info from the token */
363 if (! GetTokenInformation(token
, TokenElevation
, &elevation_info
,
364 sizeof(TOKEN_ELEVATION
), &size
))
371 return elevation_info
.TokenIsElevated
;
374 /* check for native dll when running under wine */
375 static BOOL
is_native_dll( HMODULE module
)
377 static const char builtin_signature
[] = "Wine builtin DLL";
378 static const char fakedll_signature
[] = "Wine placeholder DLL";
379 const IMAGE_DOS_HEADER
*dos
;
381 if (!running_under_wine()) return FALSE
;
382 if (!((ULONG_PTR
)module
& 1)) return FALSE
; /* not loaded as datafile */
383 /* builtin dlls can't be loaded as datafile, so we must have native or fake dll */
384 dos
= (const IMAGE_DOS_HEADER
*)((const char *)module
- 1);
385 if (dos
->e_magic
!= IMAGE_DOS_SIGNATURE
) return FALSE
;
386 if (dos
->e_lfanew
>= sizeof(*dos
) + 32)
388 if (!memcmp( dos
+ 1, builtin_signature
, sizeof(builtin_signature
) )) return FALSE
;
389 if (!memcmp( dos
+ 1, fakedll_signature
, sizeof(fakedll_signature
) )) return FALSE
;
395 * Windows 8 has a concept of stub DLLs. When DLLMain is called the user is prompted
396 * to install that component. To bypass this check we need to look at the version resource.
398 static BOOL
is_stub_dll(const char *filename
)
405 size
= GetFileVersionInfoSizeA(filename
, &ver
);
406 if (!size
) return FALSE
;
409 if (GetFileVersionInfoA(filename
, ver
, size
, data
))
413 sprintf(buf
, "\\StringFileInfo\\%04x%04x\\OriginalFilename", MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), 1200);
414 if (VerQueryValueA(data
, buf
, (void**)&p
, &size
))
415 isstub
= !lstrcmpiA("wcodstub.dll", p
);
422 static int disable_crash_dialog(void)
425 DWORD type
, data
, size
;
428 if (RegCreateKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\WineDbg", &key
)) return 0;
430 if (RegQueryValueExA( key
, "ShowCrashDialog", NULL
, &type
, (BYTE
*)&data
, &size
)) ret
= 1;
431 else if (type
!= REG_DWORD
|| data
) ret
= 2;
433 RegSetValueExA( key
, "ShowCrashDialog", 0, REG_DWORD
, (BYTE
*)&data
, sizeof(data
) );
438 static void restore_crash_dialog( int prev
)
444 if (RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\WineDbg", &key
)) return;
445 if (prev
== 1) RegDeleteKeyValueA( key
, NULL
, "ShowCrashDialog" );
446 else RegSetValueExA( key
, "ShowCrashDialog", 0, REG_DWORD
, (BYTE
*)&data
, sizeof(data
) );
450 static void print_version (void)
453 static const char platform
[] = "i386";
454 #elif defined(__x86_64__)
455 static const char platform
[] = "x86_64";
456 #elif defined(__arm__)
457 static const char platform
[] = "arm";
458 #elif defined(__aarch64__)
459 static const char platform
[] = "arm64";
463 OSVERSIONINFOEXA ver
;
464 RTL_OSVERSIONINFOEXW rtlver
;
466 int is_win2k3_r2
, is_admin
, is_elevated
;
467 const char *(CDECL
*wine_get_build_id
)(void);
468 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
469 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
470 BOOL (WINAPI
*pGetProductInfo
)(DWORD
, DWORD
, DWORD
, DWORD
, DWORD
*);
471 NTSTATUS (WINAPI
*pRtlGetVersion
)(RTL_OSVERSIONINFOEXW
*);
473 ver
.dwOSVersionInfoSize
= sizeof(ver
);
474 if (!(ext
= GetVersionExA ((OSVERSIONINFOA
*) &ver
)))
476 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
477 if (!GetVersionExA ((OSVERSIONINFOA
*) &ver
))
478 report (R_FATAL
, "Can't get OS version.");
481 /* try to get non-faked values */
482 if (ver
.dwMajorVersion
== 6 && ver
.dwMinorVersion
== 2)
484 rtlver
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
486 pRtlGetVersion
= (void *)GetProcAddress(hntdll
, "RtlGetVersion");
487 pRtlGetVersion(&rtlver
);
489 ver
.dwMajorVersion
= rtlver
.dwMajorVersion
;
490 ver
.dwMinorVersion
= rtlver
.dwMinorVersion
;
491 ver
.dwBuildNumber
= rtlver
.dwBuildNumber
;
492 ver
.dwPlatformId
= rtlver
.dwPlatformId
;
493 ver
.wServicePackMajor
= rtlver
.wServicePackMajor
;
494 ver
.wServicePackMinor
= rtlver
.wServicePackMinor
;
495 ver
.wSuiteMask
= rtlver
.wSuiteMask
;
496 ver
.wProductType
= rtlver
.wProductType
;
498 WideCharToMultiByte(CP_ACP
, 0, rtlver
.szCSDVersion
, -1, ver
.szCSDVersion
, sizeof(ver
.szCSDVersion
), NULL
, NULL
);
501 xprintf (" Platform=%s%s\n", platform
, is_wow64
? " (WOW64)" : "");
502 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
503 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
504 is_admin
= running_as_admin ();
507 xprintf (" Account=%s", is_admin
? "admin" : "non-admin");
508 is_elevated
= running_elevated ();
509 if (0 <= is_elevated
)
510 xprintf(", %s", is_elevated
? "elevated" : "not elevated");
514 xprintf (" Submitter=%s\n", email
);
516 xprintf (" Description=%s\n", description
);
518 xprintf (" URL=%s\n", url
);
519 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
520 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
521 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
522 ver
.dwPlatformId
, ver
.szCSDVersion
);
524 wine_get_build_id
= (void *)GetProcAddress(hntdll
, "wine_get_build_id");
525 wine_get_host_version
= (void *)GetProcAddress(hntdll
, "wine_get_host_version");
526 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
527 if (wine_get_host_version
)
529 const char *sysname
, *release
;
530 wine_get_host_version( &sysname
, &release
);
531 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
533 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
535 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
539 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
540 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
541 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
542 ver
.wProductType
, ver
.wReserved
);
544 pGetProductInfo
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"GetProductInfo");
545 if (pGetProductInfo
&& !running_under_wine())
549 pGetProductInfo(ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.wServicePackMajor
, ver
.wServicePackMinor
, &prodtype
);
550 xprintf(" dwProductInfo=%u\n", prodtype
);
554 static void print_language(void)
557 BOOL (WINAPI
*pGetSystemPreferredUILanguages
)(DWORD
, PULONG
, PZZWSTR
, PULONG
);
558 LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
559 LANGID (WINAPI
*pGetThreadUILanguage
)(void);
561 xprintf (" SystemDefaultLCID=%04x\n", GetSystemDefaultLCID());
562 xprintf (" UserDefaultLCID=%04x\n", GetUserDefaultLCID());
563 xprintf (" ThreadLocale=%04x\n", GetThreadLocale());
565 hkernel32
= GetModuleHandleA("kernel32.dll");
566 pGetSystemPreferredUILanguages
= (void*)GetProcAddress(hkernel32
, "GetSystemPreferredUILanguages");
567 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
568 pGetThreadUILanguage
= (void*)GetProcAddress(hkernel32
, "GetThreadUILanguage");
570 if (pGetSystemPreferredUILanguages
&& !running_under_wine())
573 ULONG num
, size
= ARRAY_SIZE(langW
);
574 if (pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID
, &num
, langW
, &size
))
576 char lang
[32], *p
= lang
;
577 WideCharToMultiByte(CP_ACP
, 0, langW
, size
, lang
, sizeof(lang
), NULL
, NULL
);
578 for (p
+= strlen(p
) + 1; *p
!= '\0'; p
+= strlen(p
) + 1) *(p
- 1) = ',';
579 xprintf (" SystemPreferredUILanguages=%s\n", lang
);
582 if (pGetUserDefaultUILanguage
)
583 xprintf (" UserDefaultUILanguage=%04x\n", pGetUserDefaultUILanguage());
584 if (pGetThreadUILanguage
)
585 xprintf (" ThreadUILanguage=%04x\n", pGetThreadUILanguage());
586 xprintf (" KeyboardLayout=%p\n", GetKeyboardLayout(0));
587 xprintf (" Country=%d\n", GetUserGeoID(GEOCLASS_NATION
));
588 xprintf (" ACP=%d\n", GetACP());
591 static inline BOOL
is_dot_dir(const char* x
)
593 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
596 static void remove_dir (const char *dir
)
599 WIN32_FIND_DATAA wfd
;
601 size_t dirlen
= strlen (dir
);
603 /* Make sure the directory exists before going further */
604 memcpy (path
, dir
, dirlen
);
605 strcpy (path
+ dirlen
++, "\\*");
606 hFind
= FindFirstFileA (path
, &wfd
);
607 if (hFind
== INVALID_HANDLE_VALUE
) return;
610 char *lp
= wfd
.cFileName
;
612 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
613 if (is_dot_dir (lp
)) continue;
614 strcpy (path
+ dirlen
, lp
);
615 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
617 else if (!DeleteFileA(path
))
618 report (R_WARNING
, "Can't delete file %s: error %d",
619 path
, GetLastError ());
620 } while (FindNextFileA(hFind
, &wfd
));
622 if (!RemoveDirectoryA(dir
))
623 report (R_WARNING
, "Can't remove directory %s: error %d",
624 dir
, GetLastError ());
627 static const char* get_test_source_file(const char* test
, const char* subtest
)
629 static char buffer
[MAX_PATH
];
630 int len
= strlen(test
);
632 if (len
> 4 && !strcmp( test
+ len
- 4, ".exe" ) &&
633 strcmp( test
, "ntoskrnl.exe" )) /* the one exception! */
635 len
= sprintf(buffer
, "programs/%s", test
) - 4;
638 else len
= sprintf(buffer
, "dlls/%s", test
);
640 sprintf(buffer
+ len
, "/tests/%s.c", subtest
);
644 static void* extract_rcdata (LPCSTR name
, LPCSTR type
, DWORD
* size
)
650 if (!(rsrc
= FindResourceA(NULL
, name
, type
)) ||
651 !(*size
= SizeofResource (0, rsrc
)) ||
652 !(hdl
= LoadResource (0, rsrc
)) ||
653 !(addr
= LockResource (hdl
)))
658 /* Fills in the name and exename fields */
660 extract_test (struct wine_test
*test
, const char *dir
, LPSTR res_name
)
668 code
= extract_rcdata (res_name
, "TESTRES", &size
);
669 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
670 res_name
, GetLastError ());
671 test
->name
= xstrdup( res_name
);
672 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
673 exepos
= strstr (test
->name
, testexe
);
674 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
676 test
->name
= xrealloc(test
->name
, exepos
- test
->name
+ 1);
677 report (R_STEP
, "Extracting: %s", test
->name
);
679 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
680 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
681 if (hfile
== INVALID_HANDLE_VALUE
)
682 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
684 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
685 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
690 static DWORD
wait_process( HANDLE process
, DWORD timeout
)
692 DWORD wait
, diff
= 0, start
= GetTickCount();
695 while (diff
< timeout
)
697 wait
= MsgWaitForMultipleObjects( 1, &process
, FALSE
, timeout
- diff
, QS_ALLINPUT
);
698 if (wait
!= WAIT_OBJECT_0
+ 1) return wait
;
699 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
700 diff
= GetTickCount() - start
;
705 static void append_path( const char *path
)
707 char *newpath
= strmake( NULL
, "%s;%s", curpath
, path
);
708 SetEnvironmentVariableA("PATH", newpath
);
712 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
715 Return the exit status, -2 if can't create process or the return
716 value of WaitForSingleObject.
719 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
, BOOL nocritical
, DWORD
* pid
)
722 PROCESS_INFORMATION pi
;
723 DWORD wait
, status
, flags
;
726 GetStartupInfoA (&si
);
727 si
.dwFlags
= STARTF_USESTDHANDLES
;
728 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
729 si
.hStdOutput
= out_file
;
730 si
.hStdError
= out_file
;
733 old_errmode
= SetErrorMode(0);
734 SetErrorMode(old_errmode
| SEM_FAILCRITICALERRORS
);
738 flags
= CREATE_DEFAULT_ERROR_MODE
;
740 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, flags
,
741 NULL
, tempdir
, &si
, &pi
))
743 if (nocritical
) SetErrorMode(old_errmode
);
748 if (nocritical
) SetErrorMode(old_errmode
);
749 CloseHandle (pi
.hThread
);
750 if (pid
) *pid
= pi
.dwProcessId
;
751 status
= wait_process( pi
.hProcess
, ms
);
755 GetExitCodeProcess (pi
.hProcess
, &status
);
756 CloseHandle (pi
.hProcess
);
759 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
, GetLastError ());
764 report (R_ERROR
, "Wait returned %d", status
);
767 if (!TerminateProcess (pi
.hProcess
, 257))
768 report (R_ERROR
, "TerminateProcess failed: %d", GetLastError ());
769 wait
= wait_process( pi
.hProcess
, 5000 );
775 report (R_ERROR
, "Wait for termination of '%s' failed: %d", cmd
, GetLastError ());
778 report (R_ERROR
, "Can't kill process '%s'", cmd
);
781 report (R_ERROR
, "Waiting for termination: %d", wait
);
784 CloseHandle (pi
.hProcess
);
789 get_subtests (const char *tempdir
, struct wine_test
*test
, LPSTR res_name
)
794 char *buffer
, *index
;
795 static const char header
[] = "Valid test names:";
796 int status
, allocated
;
797 char subname
[MAX_PATH
];
799 test
->subtest_count
= 0;
801 subfile
= create_temp_file( subname
);
802 if (subfile
== INVALID_HANDLE_VALUE
) return GetLastError();
804 cmd
= strmake (NULL
, "%s --list", test
->exename
);
805 if (test
->maindllpath
) {
806 /* We need to add the path (to the main dll) to PATH */
807 append_path(test
->maindllpath
);
809 status
= run_ex (cmd
, subfile
, tempdir
, 5000, TRUE
, NULL
);
810 err
= GetLastError();
811 if (test
->maindllpath
) {
812 /* Restore PATH again */
813 SetEnvironmentVariableA("PATH", curpath
);
819 close_temp_file( subname
, subfile
);
820 return status
== -2 ? err
: status
;
823 buffer
= flush_temp_file( subname
, subfile
, &total
);
824 index
= strstr (buffer
, header
);
826 report (R_ERROR
, "Can't parse subtests output of %s",
828 return ERROR_INTERNAL_ERROR
;
830 index
+= sizeof header
;
833 test
->subtests
= xalloc(allocated
* sizeof(char*));
834 index
= strtok (index
, whitespace
);
836 if (test
->subtest_count
== allocated
) {
838 test
->subtests
= xrealloc(test
->subtests
, allocated
* sizeof(char*));
840 test
->subtests
[test
->subtest_count
++] = xstrdup(index
);
841 index
= strtok (NULL
, whitespace
);
843 test
->subtests
= xrealloc(test
->subtests
, test
->subtest_count
* sizeof(char*));
849 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
851 /* Build the source filename so analysis tools can link to it */
852 const char* file
= get_test_source_file(test
->name
, subtest
);
854 if (test_filtered_out( test
->name
, subtest
))
856 report (R_STEP
, "Skipping: %s:%s", test
->name
, subtest
);
857 xprintf ("%s:%s skipped %s\n", test
->name
, subtest
, file
);
863 DWORD pid
, size
, start
= GetTickCount();
864 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
865 report (R_STEP
, "Running: %s:%s", test
->name
, subtest
);
866 xprintf ("%s:%s start %s\n", test
->name
, subtest
, file
);
867 /* Flush to disk so we know which test caused Windows to crash if it does */
868 FlushFileBuffers(out_file
);
871 char *data
, tmpname
[MAX_PATH
];
872 HANDLE tmpfile
= create_temp_file( tmpname
);
873 status
= run_ex (cmd
, tmpfile
, tempdir
, 120000, FALSE
, &pid
);
874 data
= flush_temp_file( tmpname
, tmpfile
, &size
);
875 if (status
|| size
> MAX_OUTPUT_SIZE
) WriteFile( out_file
, data
, size
, &size
, NULL
);
880 DWORD start_size
= GetFileSize( out_file
, NULL
);
881 status
= run_ex (cmd
, out_file
, tempdir
, 120000, FALSE
, &pid
);
882 size
= GetFileSize( out_file
, NULL
) - start_size
;
884 if (status
== -2) status
= -GetLastError();
886 xprintf ("%s:%s:%04x done (%d) in %ds %uB\n", test
->name
, subtest
, pid
, status
, (GetTickCount()-start
)/1000, size
);
887 if (size
> MAX_OUTPUT_SIZE
)
889 xprintf ("%s:%s:%04x The test prints too much data (%u bytes)\n", test
->name
, subtest
, pid
, size
);
892 else if (status
) failures
++;
894 if (failures
) report (R_STATUS
, "Running tests - %u failures", failures
);
898 EnumTestFileProc (HMODULE hModule
, LPCSTR lpszType
,
899 LPSTR lpszName
, LONG_PTR lParam
)
901 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
905 static const struct clsid_mapping
911 {"oledb32", {0xc8b522d1, 0x5cf3, 0x11ce, {0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d}}},
912 {NULL
, {0, 0, 0, {0,0,0,0,0,0,0,0}}}
916 static BOOL
get_main_clsid(const char *name
, CLSID
*clsid
)
918 const struct clsid_mapping
*mapping
;
920 for(mapping
= clsid_list
; mapping
->name
; mapping
++)
922 if(!strcasecmp(name
, mapping
->name
))
924 *clsid
= mapping
->clsid
;
931 static HMODULE
load_com_dll(const char *name
, char **path
, char *filename
)
936 char dllname
[MAX_PATH
];
940 if(!get_main_clsid(name
, &clsid
)) return NULL
;
942 sprintf(keyname
, "CLSID\\{%08lx-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
943 clsid
.Data1
, clsid
.Data2
, clsid
.Data3
, clsid
.Data4
[0], clsid
.Data4
[1],
944 clsid
.Data4
[2], clsid
.Data4
[3], clsid
.Data4
[4], clsid
.Data4
[5],
945 clsid
.Data4
[6], clsid
.Data4
[7]);
947 if(RegOpenKeyA(HKEY_CLASSES_ROOT
, keyname
, &hkey
) == ERROR_SUCCESS
)
949 LONG size
= sizeof(dllname
);
950 if(RegQueryValueA(hkey
, NULL
, dllname
, &size
) == ERROR_SUCCESS
)
952 if ((dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
)))
954 strcpy( filename
, dllname
);
955 p
= strrchr(dllname
, '\\');
957 *path
= xstrdup( dllname
);
966 static void get_dll_path(HMODULE dll
, char **path
, char *filename
)
968 char dllpath
[MAX_PATH
];
970 GetModuleFileNameA(dll
, dllpath
, MAX_PATH
);
971 strcpy(filename
, dllpath
);
972 *strrchr(dllpath
, '\\') = '\0';
973 *path
= xstrdup( dllpath
);
977 extract_test_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
979 const char *tempdir
= (const char *)lParam
;
980 char dllname
[MAX_PATH
];
981 char filename
[MAX_PATH
];
982 WCHAR dllnameW
[MAX_PATH
];
989 if (aborting
) return TRUE
;
991 /* Check if the main dll is present on this system */
992 CharLowerA(lpszName
);
993 strcpy(dllname
, lpszName
);
994 *strstr(dllname
, testexe
) = 0;
996 if (test_filtered_out( lpszName
, NULL
))
999 if (exclude_tests
) xprintf (" %s=skipped\n", dllname
);
1002 extract_test (&wine_tests
[nr_of_files
], tempdir
, lpszName
);
1004 if (pCreateActCtxA
!= NULL
&& pActivateActCtx
!= NULL
&&
1005 pDeactivateActCtx
!= NULL
&& pReleaseActCtx
!= NULL
)
1008 memset(&actctxinfo
, 0, sizeof(ACTCTXA
));
1009 actctxinfo
.cbSize
= sizeof(ACTCTXA
);
1010 actctxinfo
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
1011 actctxinfo
.lpSource
= wine_tests
[nr_of_files
].exename
;
1012 actctxinfo
.lpResourceName
= (LPSTR
)CREATEPROCESS_MANIFEST_RESOURCE_ID
;
1013 actctx
= pCreateActCtxA(&actctxinfo
);
1014 if (actctx
!= INVALID_HANDLE_VALUE
&&
1015 ! pActivateActCtx(actctx
, &cookie
))
1017 pReleaseActCtx(actctx
);
1018 actctx
= INVALID_HANDLE_VALUE
;
1020 } else actctx
= INVALID_HANDLE_VALUE
;
1022 wine_tests
[nr_of_files
].maindllpath
= NULL
;
1023 strcpy(filename
, dllname
);
1024 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
1026 if (!dll
) dll
= load_com_dll(dllname
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
1028 if (!dll
&& pLoadLibraryShim
)
1030 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
1031 if (SUCCEEDED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) ) && dll
)
1033 get_dll_path(dll
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
1035 dll
= LoadLibraryExA(filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
1043 if (is_stub_dll(dllname
))
1045 xprintf (" %s=dll is a stub\n", dllname
);
1048 else if (is_native_dll(dll
))
1050 xprintf (" %s=dll is native\n", dllname
);
1059 err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
);
1063 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
1064 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
1067 case STATUS_DLL_NOT_FOUND
:
1068 xprintf (" %s=dll is missing\n", dllname
);
1069 /* or it is a side-by-side dll but the test has no manifest */
1071 case STATUS_ORDINAL_NOT_FOUND
:
1072 xprintf (" %s=dll is missing an ordinal (%s)\n", dllname
, get_file_version(filename
));
1074 case STATUS_ENTRYPOINT_NOT_FOUND
:
1075 xprintf (" %s=dll is missing an entrypoint (%s)\n", dllname
, get_file_version(filename
));
1077 case ERROR_SXS_CANT_GEN_ACTCTX
:
1078 xprintf (" %s=dll is missing the requested side-by-side version\n", dllname
);
1081 xprintf (" %s=load error %u\n", dllname
, err
);
1086 if (actctx
!= INVALID_HANDLE_VALUE
)
1088 pDeactivateActCtx(0, cookie
);
1089 pReleaseActCtx(actctx
);
1095 run_tests (char *logname
, char *outdir
)
1098 char *strres
, *eol
, *nextline
;
1100 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
1105 /* Get the current PATH only once */
1106 needed
= GetEnvironmentVariableA("PATH", NULL
, 0);
1107 curpath
= xalloc(needed
);
1108 GetEnvironmentVariableA("PATH", curpath
, needed
);
1110 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
1112 if (!GetTempPathA( MAX_PATH
, tmppath
))
1113 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1117 if (!strcmp(logname
, "-")) logfile
= GetStdHandle( STD_OUTPUT_HANDLE
);
1118 else logfile
= create_output_file( logname
);
1122 static char tmpname
[MAX_PATH
];
1123 logfile
= create_temp_file( tmpname
);
1126 report (R_OUT
, "%s", logname
);
1128 if (logfile
== INVALID_HANDLE_VALUE
)
1129 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
1133 /* Get a full path so it is still valid after a chdir */
1134 GetFullPathNameA( outdir
, ARRAY_SIZE(tempdir
), tempdir
, NULL
);
1138 strcpy( tempdir
, tmppath
);
1139 strcat( tempdir
, "wct" ); /* try stable path for ZoneAlarm */
1141 newdir
= CreateDirectoryA( tempdir
, NULL
);
1142 if (!newdir
&& !outdir
)
1144 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
1145 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1146 DeleteFileA( tempdir
);
1147 newdir
= CreateDirectoryA( tempdir
, NULL
);
1149 if (!newdir
&& (!outdir
|| GetLastError() != ERROR_ALREADY_EXISTS
))
1150 report (R_FATAL
, "Could not create directory %s (%d)", tempdir
, GetLastError());
1152 report (R_DIR
, "%s", tempdir
);
1154 xprintf ("Version 4\n");
1155 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
1156 xprintf ("Archive: -\n"); /* no longer used */
1157 xprintf ("Tag: %s\n", tag
);
1158 xprintf ("Build info:\n");
1159 strres
= extract_rcdata ("BUILD_INFO", "STRINGRES", &strsize
);
1161 eol
= memchr (strres
, '\n', strsize
);
1164 eol
= strres
+ strsize
;
1166 strsize
-= eol
- strres
+ 1;
1167 nextline
= strsize
?eol
+1:NULL
;
1168 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
1170 xprintf (" %.*s\n", eol
-strres
, strres
);
1173 xprintf ("Operating system version:\n");
1176 xprintf ("Dll info:\n" );
1178 report (R_STATUS
, "Counting tests");
1179 if (!EnumResourceNamesA (NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1180 report (R_FATAL
, "Can't enumerate test files: %d",
1182 wine_tests
= xalloc(nr_of_files
* sizeof wine_tests
[0]);
1184 /* Do this only once during extraction (and version checking) */
1185 hmscoree
= LoadLibraryA("mscoree.dll");
1186 pLoadLibraryShim
= NULL
;
1188 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
1189 kernel32
= GetModuleHandleA("kernel32.dll");
1190 pCreateActCtxA
= (void *)GetProcAddress(kernel32
, "CreateActCtxA");
1191 pActivateActCtx
= (void *)GetProcAddress(kernel32
, "ActivateActCtx");
1192 pDeactivateActCtx
= (void *)GetProcAddress(kernel32
, "DeactivateActCtx");
1193 pReleaseActCtx
= (void *)GetProcAddress(kernel32
, "ReleaseActCtx");
1195 report (R_STATUS
, "Extracting tests");
1196 report (R_PROGRESS
, 0, nr_of_files
);
1200 if (!EnumResourceNamesA (NULL
, "TESTRES", extract_test_proc
, (LPARAM
)tempdir
))
1201 report (R_FATAL
, "Can't enumerate test files: %d",
1204 FreeLibrary(hmscoree
);
1206 if (aborting
) return logname
;
1208 xprintf ("Test output:\n" );
1210 report (R_DELTA
, 0, "Extracting: Done");
1213 report( R_WARNING
, "Some dlls are configured as native, you won't be able to submit results." );
1215 report (R_STATUS
, "Running tests");
1216 report (R_PROGRESS
, 1, nr_of_tests
);
1217 for (i
= 0; i
< nr_of_files
; i
++) {
1218 struct wine_test
*test
= wine_tests
+ i
;
1221 if (aborting
) break;
1223 if (test
->maindllpath
) {
1224 /* We need to add the path (to the main dll) to PATH */
1225 append_path(test
->maindllpath
);
1228 for (j
= 0; j
< test
->subtest_count
; j
++) {
1229 if (aborting
) break;
1230 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
1233 if (test
->maindllpath
) {
1234 /* Restore PATH again */
1235 SetEnvironmentVariableA("PATH", curpath
);
1238 report (R_DELTA
, 0, "Running: Done");
1240 report (R_STATUS
, "Cleaning up - %u failures", failures
);
1241 if (strcmp(logname
, "-") != 0) CloseHandle( logfile
);
1244 remove_dir (tempdir
);
1251 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
1253 if (ctrl_type
== CTRL_C_EVENT
) {
1254 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
1262 static BOOL CALLBACK
1263 extract_only_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
1265 const char *target_dir
= (const char *)lParam
;
1266 char filename
[MAX_PATH
];
1268 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
1270 strcpy(filename
, lpszName
);
1271 CharLowerA(filename
);
1273 extract_test( &wine_tests
[nr_of_files
], target_dir
, filename
);
1278 static void extract_only (const char *target_dir
)
1282 report (R_DIR
, target_dir
);
1283 res
= CreateDirectoryA( target_dir
, NULL
);
1284 if (!res
&& GetLastError() != ERROR_ALREADY_EXISTS
)
1285 report (R_FATAL
, "Could not create directory: %s (%d)", target_dir
, GetLastError ());
1288 report (R_STATUS
, "Counting tests");
1289 if (!EnumResourceNamesA(NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1290 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1292 wine_tests
= xalloc(nr_of_files
* sizeof wine_tests
[0] );
1294 report (R_STATUS
, "Extracting tests");
1295 report (R_PROGRESS
, 0, nr_of_files
);
1297 if (!EnumResourceNamesA(NULL
, "TESTRES", extract_only_proc
, (LPARAM
)target_dir
))
1298 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1300 report (R_DELTA
, 0, "Extracting: Done");
1307 "Usage: winetest [OPTION]... [TESTS]\n\n"
1308 " --help print this message and exit\n"
1309 " --version print the build version and exit\n"
1310 " -c console mode, no GUI\n"
1311 " -d DIR Use DIR as temp directory (default: %%TEMP%%\\wct)\n"
1312 " -e preserve the environment\n"
1313 " -h print this message and exit\n"
1314 " -i INFO an optional description of the test platform\n"
1315 " -m MAIL an email address to enable developers to contact you\n"
1316 " -n exclude the specified tests\n"
1317 " -p shutdown when the tests are done\n"
1318 " -q quiet mode, no output at all\n"
1319 " -o FILE put report into FILE, do not submit\n"
1320 " -s FILE submit FILE, do not run tests\n"
1321 " -S URL URL to submit the results to\n"
1322 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"
1323 " -u URL include TestBot URL in the report\n"
1324 " -x DIR Extract tests to DIR (default: .\\wct) and exit\n");
1327 int __cdecl
main( int argc
, char *argv
[] )
1329 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
1330 char *logname
= NULL
, *outdir
= NULL
;
1331 const char *extract
= NULL
;
1332 const char *cp
, *submit
= NULL
, *submiturl
= NULL
;
1335 int interactive
= 1;
1336 int prev_crash_dialog
= 0;
1339 InitCommonControls();
1341 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
1343 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
1344 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &is_wow64
)) is_wow64
= FALSE
;
1346 for (i
= 1; i
< argc
&& argv
[i
]; i
++)
1348 if (!strcmp(argv
[i
], "--help")) {
1352 else if (!strcmp(argv
[i
], "--version")) {
1353 printf("%-12.12s\n", build_id
[0] ? build_id
: "unknown");
1356 else if ((argv
[i
][0] != '-' && argv
[i
][0] != '/') || argv
[i
][2]) {
1357 add_filter( argv
[i
] );
1359 else switch (argv
[i
][1]) {
1361 report (R_TEXTMODE
);
1372 if (!(description
= argv
[++i
]))
1379 if (!(email
= argv
[++i
]))
1386 exclude_tests
= TRUE
;
1397 if (!(submit
= argv
[++i
]))
1404 if (!(submiturl
= argv
[++i
]))
1411 if (!(logname
= argv
[++i
]))
1418 if (!(tag
= argv
[++i
]))
1423 if (strlen (tag
) > MAXTAGLEN
)
1424 report (R_FATAL
, "tag is too long (maximum %d characters)",
1426 cp
= findbadtagchar (tag
);
1428 report (R_ERROR
, "invalid char in tag: %c", *cp
);
1434 if (!(url
= argv
[++i
]))
1441 report (R_TEXTMODE
);
1442 if (!(extract
= argv
[++i
]))
1445 extract_only (extract
);
1451 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
1458 report (R_WARNING
, "ignoring tag for submission");
1459 send_file (submiturl
, submit
);
1461 } else if (!extract
) {
1462 int is_win9x
= (GetVersion() & 0x80000000) != 0;
1464 report (R_STATUS
, "Starting up");
1467 report (R_WARNING
, "Running on win9x is not supported. You won't be able to submit results.");
1469 if (!running_on_visible_desktop ())
1470 report (R_FATAL
, "Tests must be run on a visible desktop");
1472 if (running_under_wine())
1474 if (!check_mount_mgr())
1475 report (R_FATAL
, "Mount manager not running, most likely your WINEPREFIX wasn't created correctly.");
1477 if (!check_wow64_registry())
1478 report (R_FATAL
, "WoW64 keys missing, most likely your WINEPREFIX wasn't created correctly.");
1480 if (!check_display_driver())
1481 report (R_FATAL
, "Unable to create a window, the display driver is not working.");
1483 if (!interactive
) prev_crash_dialog
= disable_crash_dialog();
1486 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
1490 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
1491 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
1492 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
1493 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
1496 if (nb_filters
&& !exclude_tests
)
1498 run_tests( logname
, outdir
);
1499 exit( failures
? 3 : 0 );
1504 report (R_FATAL
, "Please specify a tag (-t option) if "
1505 "running noninteractive!");
1506 if (guiAskTag () == IDABORT
) exit (1);
1514 report (R_FATAL
, "Please specify an email address (-m option) to enable developers\n"
1515 " to contact you about your report if necessary.");
1517 if (guiAskEmail () == IDABORT
) exit (1);
1521 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
1522 "To submit results, winetest needs to be built from a git checkout." );
1525 logname
= run_tests (NULL
, outdir
);
1527 DeleteFileA(logname
);
1530 if (failures
> FAILURES_LIMIT
)
1532 "%d tests failed. There is probably something broken with your setup.\n"
1533 "You need to address this before submitting results.", failures
);
1535 if (build_id
[0] && nr_of_skips
<= SKIP_LIMIT
&& failures
<= FAILURES_LIMIT
&&
1536 !nr_native_dlls
&& !is_win9x
&&
1537 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
1539 if (!send_file (submiturl
, logname
) && !DeleteFileA(logname
))
1540 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
1542 failures
= 0; /* return success */
1547 run_tests (logname
, outdir
);
1548 report (R_STATUS
, "Finished - %u failures", failures
);
1550 if (prev_crash_dialog
) restore_crash_dialog( prev_crash_dialog
);
1555 TOKEN_PRIVILEGES npr
;
1557 /* enable the shutdown privilege for the current process */
1558 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1560 LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr
.Privileges
[0].Luid
);
1561 npr
.PrivilegeCount
= 1;
1562 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1563 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
1564 CloseHandle(hToken
);
1566 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);
1568 exit( failures
? 3 : 0 );