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.
38 /* Don't submit the results if more than SKIP_LIMIT tests have been skipped */
41 /* Don't submit the results if more than FAILURES_LIMIT tests have failed */
42 #define FAILURES_LIMIT 50
54 char *description
= NULL
;
57 BOOL aborting
= FALSE
;
58 static struct wine_test
*wine_tests
;
59 static int nr_of_files
, nr_of_tests
, nr_of_skips
;
60 static int nr_native_dlls
;
61 static const char whitespace
[] = " \t\r\n";
62 static const char testexe
[] = "_test.exe";
63 static char build_id
[64];
67 /* filters for running only specific tests */
68 static char *filters
[64];
69 static unsigned int nb_filters
= 0;
70 static BOOL exclude_tests
= FALSE
;
72 /* Needed to check for .NET dlls */
73 static HMODULE hmscoree
;
74 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR
, LPCWSTR
, LPVOID
, HMODULE
*);
76 /* For SxS DLLs e.g. msvcr90 */
77 static HANDLE (WINAPI
*pCreateActCtxA
)(PACTCTXA
);
78 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
, ULONG_PTR
*);
79 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
, ULONG_PTR
);
80 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
82 /* To store the current PATH setting (related to .NET only provided dlls) */
85 /* check if test is being filtered out */
86 static BOOL
test_filtered_out( LPCSTR module
, LPCSTR testname
)
88 char *p
, dllname
[MAX_PATH
];
91 strcpy( dllname
, module
);
92 CharLowerA( dllname
);
93 p
= strstr( dllname
, testexe
);
95 len
= strlen(dllname
);
97 if (!nb_filters
) return exclude_tests
;
98 for (i
= 0; i
< nb_filters
; i
++)
100 if (!strncmp( dllname
, filters
[i
], len
))
102 if (!filters
[i
][len
]) return exclude_tests
;
103 if (filters
[i
][len
] != ':') continue;
104 if (testname
&& !strcmp( testname
, &filters
[i
][len
+1] )) return exclude_tests
;
105 if (!testname
&& !exclude_tests
) return FALSE
;
108 return !exclude_tests
;
111 static char * get_file_version(char * file_name
)
113 static char version
[32];
117 size
= GetFileVersionInfoSizeA(file_name
, &handle
);
119 char * data
= heap_alloc(size
);
121 if (GetFileVersionInfoA(file_name
, handle
, size
, data
)) {
122 static const char backslash
[] = "\\";
123 VS_FIXEDFILEINFO
*pFixedVersionInfo
;
125 if (VerQueryValueA(data
, backslash
, (LPVOID
*)&pFixedVersionInfo
, &len
)) {
126 sprintf(version
, "%d.%d.%d.%d",
127 pFixedVersionInfo
->dwFileVersionMS
>> 16,
128 pFixedVersionInfo
->dwFileVersionMS
& 0xffff,
129 pFixedVersionInfo
->dwFileVersionLS
>> 16,
130 pFixedVersionInfo
->dwFileVersionLS
& 0xffff);
132 sprintf(version
, "version not available");
134 sprintf(version
, "unknown");
137 sprintf(version
, "failed");
139 sprintf(version
, "version not available");
144 static BOOL
running_under_wine (void)
146 HMODULE module
= GetModuleHandleA("ntdll.dll");
148 if (!module
) return FALSE
;
149 return (GetProcAddress(module
, "wine_server_call") != NULL
);
152 static BOOL
check_mount_mgr(void)
154 HANDLE handle
= CreateFileA( "\\\\.\\MountPointManager", GENERIC_READ
,
155 FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
156 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
157 CloseHandle( handle
);
161 static BOOL
check_wow64_registry(void)
163 char buffer
[MAX_PATH
];
164 DWORD type
, size
= MAX_PATH
;
168 if (!is_wow64
) return TRUE
;
169 if (RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
171 ret
= !RegQueryValueExA( hkey
, "ProgramFilesDir (x86)", NULL
, &type
, (BYTE
*)buffer
, &size
);
176 static BOOL
check_display_driver(void)
178 HWND hwnd
= CreateWindowA( "STATIC", "", WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0,
179 0, 0, GetModuleHandleA(0), 0 );
180 if (!hwnd
) return FALSE
;
181 DestroyWindow( hwnd
);
185 static BOOL
running_on_visible_desktop (void)
188 HMODULE huser32
= GetModuleHandleA("user32.dll");
189 HWINSTA (WINAPI
*pGetProcessWindowStation
)(void);
190 BOOL (WINAPI
*pGetUserObjectInformationA
)(HANDLE
,INT
,LPVOID
,DWORD
,LPDWORD
);
192 pGetProcessWindowStation
= (void *)GetProcAddress(huser32
, "GetProcessWindowStation");
193 pGetUserObjectInformationA
= (void *)GetProcAddress(huser32
, "GetUserObjectInformationA");
195 desktop
= GetDesktopWindow();
196 if (!GetWindowLongPtrW(desktop
, GWLP_WNDPROC
)) /* Win9x */
197 return IsWindowVisible(desktop
);
199 if (pGetProcessWindowStation
&& pGetUserObjectInformationA
)
203 USEROBJECTFLAGS uoflags
;
205 wstation
= (HWINSTA
)pGetProcessWindowStation();
206 assert(pGetUserObjectInformationA(wstation
, UOI_FLAGS
, &uoflags
, sizeof(uoflags
), &len
));
207 return (uoflags
.dwFlags
& WSF_VISIBLE
) != 0;
209 return IsWindowVisible(desktop
);
212 static int running_as_admin (void)
214 PSID administrators
= NULL
;
215 SID_IDENTIFIER_AUTHORITY nt_authority
= { SECURITY_NT_AUTHORITY
};
218 PTOKEN_GROUPS groups
;
221 /* Create a well-known SID for the Administrators group. */
222 if (! AllocateAndInitializeSid(&nt_authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
223 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
227 /* Get the process token */
228 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
230 FreeSid(administrators
);
234 /* Get the group info from the token */
236 GetTokenInformation(token
, TokenGroups
, NULL
, 0, &groups_size
);
237 groups
= heap_alloc(groups_size
);
241 FreeSid(administrators
);
244 if (! GetTokenInformation(token
, TokenGroups
, groups
, groups_size
, &groups_size
))
248 FreeSid(administrators
);
253 /* Now check if the token groups include the Administrators group */
254 for (group_index
= 0; group_index
< groups
->GroupCount
; group_index
++)
256 if (EqualSid(groups
->Groups
[group_index
].Sid
, administrators
))
259 FreeSid(administrators
);
264 /* If we end up here we didn't find the Administrators group */
266 FreeSid(administrators
);
270 static int running_elevated (void)
273 TOKEN_ELEVATION elevation_info
;
276 /* Get the process token */
277 if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
280 /* Get the elevation info from the token */
281 if (! GetTokenInformation(token
, TokenElevation
, &elevation_info
,
282 sizeof(TOKEN_ELEVATION
), &size
))
289 return elevation_info
.TokenIsElevated
;
292 /* check for native dll when running under wine */
293 static BOOL
is_native_dll( HMODULE module
)
295 static const char builtin_signature
[] = "Wine builtin DLL";
296 static const char fakedll_signature
[] = "Wine placeholder DLL";
297 const IMAGE_DOS_HEADER
*dos
;
299 if (!running_under_wine()) return FALSE
;
300 if (!((ULONG_PTR
)module
& 1)) return FALSE
; /* not loaded as datafile */
301 /* builtin dlls can't be loaded as datafile, so we must have native or fake dll */
302 dos
= (const IMAGE_DOS_HEADER
*)((const char *)module
- 1);
303 if (dos
->e_magic
!= IMAGE_DOS_SIGNATURE
) return FALSE
;
304 if (dos
->e_lfanew
>= sizeof(*dos
) + 32)
306 if (!memcmp( dos
+ 1, builtin_signature
, sizeof(builtin_signature
) )) return FALSE
;
307 if (!memcmp( dos
+ 1, fakedll_signature
, sizeof(fakedll_signature
) )) return FALSE
;
313 * Windows 8 has a concept of stub DLLs. When DLLMain is called the user is prompted
314 * to install that component. To bypass this check we need to look at the version resource.
316 static BOOL
is_stub_dll(const char *filename
)
322 size
= GetFileVersionInfoSizeA(filename
, &ver
);
323 if (!size
) return FALSE
;
325 data
= HeapAlloc(GetProcessHeap(), 0, size
);
326 if (!data
) return FALSE
;
328 if (GetFileVersionInfoA(filename
, ver
, size
, data
))
332 sprintf(buf
, "\\StringFileInfo\\%04x%04x\\OriginalFilename", MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), 1200);
333 if (VerQueryValueA(data
, buf
, (void**)&p
, &size
))
334 isstub
= !lstrcmpiA("wcodstub.dll", p
);
336 HeapFree(GetProcessHeap(), 0, data
);
341 static void print_version (void)
344 static const char platform
[] = "i386";
345 #elif defined(__x86_64__)
346 static const char platform
[] = "x86_64";
347 #elif defined(__powerpc__)
348 static const char platform
[] = "powerpc";
349 #elif defined(__arm__)
350 static const char platform
[] = "arm";
351 #elif defined(__aarch64__)
352 static const char platform
[] = "arm64";
356 OSVERSIONINFOEXA ver
;
357 RTL_OSVERSIONINFOEXW rtlver
;
359 int is_win2k3_r2
, is_admin
, is_elevated
;
360 const char *(CDECL
*wine_get_build_id
)(void);
361 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
362 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
363 BOOL (WINAPI
*pGetProductInfo
)(DWORD
, DWORD
, DWORD
, DWORD
, DWORD
*);
364 NTSTATUS (WINAPI
*pRtlGetVersion
)(RTL_OSVERSIONINFOEXW
*);
366 ver
.dwOSVersionInfoSize
= sizeof(ver
);
367 if (!(ext
= GetVersionExA ((OSVERSIONINFOA
*) &ver
)))
369 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
370 if (!GetVersionExA ((OSVERSIONINFOA
*) &ver
))
371 report (R_FATAL
, "Can't get OS version.");
374 /* try to get non-faked values */
375 if (ver
.dwMajorVersion
== 6 && ver
.dwMinorVersion
== 2)
377 rtlver
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
379 pRtlGetVersion
= (void *)GetProcAddress(hntdll
, "RtlGetVersion");
380 pRtlGetVersion(&rtlver
);
382 ver
.dwMajorVersion
= rtlver
.dwMajorVersion
;
383 ver
.dwMinorVersion
= rtlver
.dwMinorVersion
;
384 ver
.dwBuildNumber
= rtlver
.dwBuildNumber
;
385 ver
.dwPlatformId
= rtlver
.dwPlatformId
;
386 ver
.wServicePackMajor
= rtlver
.wServicePackMajor
;
387 ver
.wServicePackMinor
= rtlver
.wServicePackMinor
;
388 ver
.wSuiteMask
= rtlver
.wSuiteMask
;
389 ver
.wProductType
= rtlver
.wProductType
;
391 WideCharToMultiByte(CP_ACP
, 0, rtlver
.szCSDVersion
, -1, ver
.szCSDVersion
, sizeof(ver
.szCSDVersion
), NULL
, NULL
);
394 xprintf (" Platform=%s%s\n", platform
, is_wow64
? " (WOW64)" : "");
395 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
396 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
397 is_admin
= running_as_admin ();
400 xprintf (" Account=%s", is_admin
? "admin" : "non-admin");
401 is_elevated
= running_elevated ();
402 if (0 <= is_elevated
)
403 xprintf(", %s", is_elevated
? "elevated" : "not elevated");
406 xprintf (" Submitter=%s\n", email
);
408 xprintf (" Description=%s\n", description
);
410 xprintf (" URL=%s\n", url
);
411 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
412 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
413 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
414 ver
.dwPlatformId
, ver
.szCSDVersion
);
416 wine_get_build_id
= (void *)GetProcAddress(hntdll
, "wine_get_build_id");
417 wine_get_host_version
= (void *)GetProcAddress(hntdll
, "wine_get_host_version");
418 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
419 if (wine_get_host_version
)
421 const char *sysname
, *release
;
422 wine_get_host_version( &sysname
, &release
);
423 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
425 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
427 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
431 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
432 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
433 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
434 ver
.wProductType
, ver
.wReserved
);
436 pGetProductInfo
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"GetProductInfo");
437 if (pGetProductInfo
&& !running_under_wine())
441 pGetProductInfo(ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.wServicePackMajor
, ver
.wServicePackMinor
, &prodtype
);
442 xprintf(" dwProductInfo=%u\n", prodtype
);
446 static void print_language(void)
449 BOOL (WINAPI
*pGetSystemPreferredUILanguages
)(DWORD
, PULONG
, PZZWSTR
, PULONG
);
450 LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
451 LANGID (WINAPI
*pGetThreadUILanguage
)(void);
453 xprintf (" SystemDefaultLCID=%04x\n", GetSystemDefaultLCID());
454 xprintf (" UserDefaultLCID=%04x\n", GetUserDefaultLCID());
455 xprintf (" ThreadLocale=%04x\n", GetThreadLocale());
457 hkernel32
= GetModuleHandleA("kernel32.dll");
458 pGetSystemPreferredUILanguages
= (void*)GetProcAddress(hkernel32
, "GetSystemPreferredUILanguages");
459 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
460 pGetThreadUILanguage
= (void*)GetProcAddress(hkernel32
, "GetThreadUILanguage");
462 if (pGetSystemPreferredUILanguages
&& !running_under_wine())
465 ULONG num
, size
= ARRAY_SIZE(langW
);
466 if (pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID
, &num
, langW
, &size
))
468 char lang
[32], *p
= lang
;
469 WideCharToMultiByte(CP_ACP
, 0, langW
, size
, lang
, sizeof(lang
), NULL
, NULL
);
470 for (p
+= strlen(p
) + 1; *p
!= '\0'; p
+= strlen(p
) + 1) *(p
- 1) = ',';
471 xprintf (" SystemPreferredUILanguages=%s\n", lang
);
474 if (pGetUserDefaultUILanguage
)
475 xprintf (" UserDefaultUILanguage=%04x\n", pGetUserDefaultUILanguage());
476 if (pGetThreadUILanguage
)
477 xprintf (" ThreadUILanguage=%04x\n", pGetThreadUILanguage());
480 static inline BOOL
is_dot_dir(const char* x
)
482 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
485 static void remove_dir (const char *dir
)
488 WIN32_FIND_DATAA wfd
;
490 size_t dirlen
= strlen (dir
);
492 /* Make sure the directory exists before going further */
493 memcpy (path
, dir
, dirlen
);
494 strcpy (path
+ dirlen
++, "\\*");
495 hFind
= FindFirstFileA (path
, &wfd
);
496 if (hFind
== INVALID_HANDLE_VALUE
) return;
499 char *lp
= wfd
.cFileName
;
501 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
502 if (is_dot_dir (lp
)) continue;
503 strcpy (path
+ dirlen
, lp
);
504 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
506 else if (!DeleteFileA(path
))
507 report (R_WARNING
, "Can't delete file %s: error %d",
508 path
, GetLastError ());
509 } while (FindNextFileA(hFind
, &wfd
));
511 if (!RemoveDirectoryA(dir
))
512 report (R_WARNING
, "Can't remove directory %s: error %d",
513 dir
, GetLastError ());
516 static const char* get_test_source_file(const char* test
, const char* subtest
)
518 static char buffer
[MAX_PATH
];
519 int len
= strlen(test
);
521 if (len
> 4 && !strcmp( test
+ len
- 4, ".exe" ))
523 len
= sprintf(buffer
, "programs/%s", test
) - 4;
526 else len
= sprintf(buffer
, "dlls/%s", test
);
528 sprintf(buffer
+ len
, "/tests/%s.c", subtest
);
532 static void* extract_rcdata (LPCSTR name
, LPCSTR type
, DWORD
* size
)
538 if (!(rsrc
= FindResourceA(NULL
, name
, type
)) ||
539 !(*size
= SizeofResource (0, rsrc
)) ||
540 !(hdl
= LoadResource (0, rsrc
)) ||
541 !(addr
= LockResource (hdl
)))
546 /* Fills in the name and exename fields */
548 extract_test (struct wine_test
*test
, const char *dir
, LPSTR res_name
)
556 code
= extract_rcdata (res_name
, "TESTRES", &size
);
557 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
558 res_name
, GetLastError ());
559 test
->name
= heap_strdup( res_name
);
560 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
561 exepos
= strstr (test
->name
, testexe
);
562 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
564 test
->name
= heap_realloc (test
->name
, exepos
- test
->name
+ 1);
565 report (R_STEP
, "Extracting: %s", test
->name
);
567 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
568 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
569 if (hfile
== INVALID_HANDLE_VALUE
)
570 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
572 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
573 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
578 static DWORD
wait_process( HANDLE process
, DWORD timeout
)
580 DWORD wait
, diff
= 0, start
= GetTickCount();
583 while (diff
< timeout
)
585 wait
= MsgWaitForMultipleObjects( 1, &process
, FALSE
, timeout
- diff
, QS_ALLINPUT
);
586 if (wait
!= WAIT_OBJECT_0
+ 1) return wait
;
587 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
588 diff
= GetTickCount() - start
;
593 static void append_path( const char *path
)
597 newpath
= heap_alloc(strlen(curpath
) + 1 + strlen(path
) + 1);
598 strcpy(newpath
, curpath
);
599 strcat(newpath
, ";");
600 strcat(newpath
, path
);
601 SetEnvironmentVariableA("PATH", newpath
);
606 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
609 Return the exit status, -2 if can't create process or the return
610 value of WaitForSingleObject.
613 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
, DWORD
* pid
)
616 PROCESS_INFORMATION pi
;
619 /* Flush to disk so we know which test caused Windows to crash if it does */
621 FlushFileBuffers(out_file
);
623 GetStartupInfoA (&si
);
624 si
.dwFlags
= STARTF_USESTDHANDLES
;
625 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
626 si
.hStdOutput
= out_file
? out_file
: GetStdHandle( STD_OUTPUT_HANDLE
);
627 si
.hStdError
= out_file
? out_file
: GetStdHandle( STD_ERROR_HANDLE
);
629 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, CREATE_DEFAULT_ERROR_MODE
,
630 NULL
, tempdir
, &si
, &pi
))
636 CloseHandle (pi
.hThread
);
637 if (pid
) *pid
= pi
.dwProcessId
;
638 status
= wait_process( pi
.hProcess
, ms
);
642 GetExitCodeProcess (pi
.hProcess
, &status
);
643 CloseHandle (pi
.hProcess
);
646 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
, GetLastError ());
651 report (R_ERROR
, "Wait returned %d", status
);
654 if (!TerminateProcess (pi
.hProcess
, 257))
655 report (R_ERROR
, "TerminateProcess failed: %d", GetLastError ());
656 wait
= wait_process( pi
.hProcess
, 5000 );
662 report (R_ERROR
, "Wait for termination of '%s' failed: %d", cmd
, GetLastError ());
665 report (R_ERROR
, "Can't kill process '%s'", cmd
);
668 report (R_ERROR
, "Waiting for termination: %d", wait
);
671 CloseHandle (pi
.hProcess
);
676 get_subtests (const char *tempdir
, struct wine_test
*test
, LPSTR res_name
)
681 char buffer
[8192], *index
;
682 static const char header
[] = "Valid test names:";
683 int status
, allocated
;
684 char tmpdir
[MAX_PATH
], subname
[MAX_PATH
];
685 SECURITY_ATTRIBUTES sa
;
687 test
->subtest_count
= 0;
689 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
690 !GetTempFileNameA( tmpdir
, "sub", 0, subname
))
691 report (R_FATAL
, "Can't name subtests file.");
693 /* make handle inheritable */
694 sa
.nLength
= sizeof(sa
);
695 sa
.lpSecurityDescriptor
= NULL
;
696 sa
.bInheritHandle
= TRUE
;
698 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
699 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
700 &sa
, CREATE_ALWAYS
, 0, NULL
);
702 if ((subfile
== INVALID_HANDLE_VALUE
) &&
703 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
704 /* FILE_SHARE_DELETE not supported on win9x */
705 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
706 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
707 &sa
, CREATE_ALWAYS
, 0, NULL
);
709 if (subfile
== INVALID_HANDLE_VALUE
) {
710 err
= GetLastError();
711 report (R_ERROR
, "Can't open subtests output of %s: %u",
712 test
->name
, GetLastError());
716 cmd
= strmake (NULL
, "%s --list", test
->exename
);
717 if (test
->maindllpath
) {
718 /* We need to add the path (to the main dll) to PATH */
719 append_path(test
->maindllpath
);
721 status
= run_ex (cmd
, subfile
, tempdir
, 5000, NULL
);
722 err
= GetLastError();
723 if (test
->maindllpath
) {
724 /* Restore PATH again */
725 SetEnvironmentVariableA("PATH", curpath
);
731 report (R_ERROR
, "Cannot run %s error %u", test
->exename
, err
);
732 CloseHandle( subfile
);
736 SetFilePointer( subfile
, 0, NULL
, FILE_BEGIN
);
737 ReadFile( subfile
, buffer
, sizeof(buffer
), &total
, NULL
);
738 CloseHandle( subfile
);
739 if (sizeof buffer
== total
) {
740 report (R_ERROR
, "Subtest list of %s too big.",
741 test
->name
, sizeof buffer
);
742 err
= ERROR_OUTOFMEMORY
;
747 index
= strstr (buffer
, header
);
749 report (R_ERROR
, "Can't parse subtests output of %s",
751 err
= ERROR_INTERNAL_ERROR
;
754 index
+= sizeof header
;
757 test
->subtests
= heap_alloc (allocated
* sizeof(char*));
758 index
= strtok (index
, whitespace
);
760 if (test
->subtest_count
== allocated
) {
762 test
->subtests
= heap_realloc (test
->subtests
,
763 allocated
* sizeof(char*));
765 test
->subtests
[test
->subtest_count
++] = heap_strdup(index
);
766 index
= strtok (NULL
, whitespace
);
768 test
->subtests
= heap_realloc (test
->subtests
,
769 test
->subtest_count
* sizeof(char*));
773 if (!DeleteFileA (subname
))
774 report (R_WARNING
, "Can't delete file '%s': %u", subname
, GetLastError());
779 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
781 /* Build the source filename so analysis tools can link to it */
782 const char* file
= get_test_source_file(test
->name
, subtest
);
784 if (test_filtered_out( test
->name
, subtest
))
786 report (R_STEP
, "Skipping: %s:%s", test
->name
, subtest
);
787 xprintf ("%s:%s skipped %s -\n", test
->name
, subtest
, file
);
793 DWORD pid
, start
= GetTickCount();
794 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
795 report (R_STEP
, "Running: %s:%s", test
->name
, subtest
);
796 xprintf ("%s:%s start %s -\n", test
->name
, subtest
, file
);
797 status
= run_ex (cmd
, out_file
, tempdir
, 120000, &pid
);
799 xprintf ("%s:%s:%04x done (%d) in %ds\n", test
->name
, subtest
, pid
, status
, (GetTickCount()-start
)/1000);
800 if (status
) failures
++;
802 if (failures
) report (R_STATUS
, "Running tests - %u failures", failures
);
806 EnumTestFileProc (HMODULE hModule
, LPCSTR lpszType
,
807 LPSTR lpszName
, LONG_PTR lParam
)
809 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
813 static const struct clsid_mapping
819 {"oledb32", {0xc8b522d1, 0x5cf3, 0x11ce, {0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d}}},
820 {NULL
, {0, 0, 0, {0,0,0,0,0,0,0,0}}}
824 static BOOL
get_main_clsid(const char *name
, CLSID
*clsid
)
826 const struct clsid_mapping
*mapping
;
828 for(mapping
= clsid_list
; mapping
->name
; mapping
++)
830 if(!strcasecmp(name
, mapping
->name
))
832 *clsid
= mapping
->clsid
;
839 static HMODULE
load_com_dll(const char *name
, char **path
, char *filename
)
844 char dllname
[MAX_PATH
];
848 if(!get_main_clsid(name
, &clsid
)) return NULL
;
850 sprintf(keyname
, "CLSID\\{%08x-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
851 clsid
.Data1
, clsid
.Data2
, clsid
.Data3
, clsid
.Data4
[0], clsid
.Data4
[1],
852 clsid
.Data4
[2], clsid
.Data4
[3], clsid
.Data4
[4], clsid
.Data4
[5],
853 clsid
.Data4
[6], clsid
.Data4
[7]);
855 if(RegOpenKeyA(HKEY_CLASSES_ROOT
, keyname
, &hkey
) == ERROR_SUCCESS
)
857 LONG size
= sizeof(dllname
);
858 if(RegQueryValueA(hkey
, NULL
, dllname
, &size
) == ERROR_SUCCESS
)
860 if ((dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
)))
862 strcpy( filename
, dllname
);
863 p
= strrchr(dllname
, '\\');
865 *path
= heap_strdup( dllname
);
874 static void get_dll_path(HMODULE dll
, char **path
, char *filename
)
876 char dllpath
[MAX_PATH
];
878 GetModuleFileNameA(dll
, dllpath
, MAX_PATH
);
879 strcpy(filename
, dllpath
);
880 *strrchr(dllpath
, '\\') = '\0';
881 *path
= heap_strdup( dllpath
);
885 extract_test_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
887 const char *tempdir
= (const char *)lParam
;
888 char dllname
[MAX_PATH
];
889 char filename
[MAX_PATH
];
890 WCHAR dllnameW
[MAX_PATH
];
896 if (aborting
) return TRUE
;
898 /* Check if the main dll is present on this system */
899 CharLowerA(lpszName
);
900 strcpy(dllname
, lpszName
);
901 *strstr(dllname
, testexe
) = 0;
903 if (test_filtered_out( lpszName
, NULL
))
908 extract_test (&wine_tests
[nr_of_files
], tempdir
, lpszName
);
910 if (pCreateActCtxA
!= NULL
&& pActivateActCtx
!= NULL
&&
911 pDeactivateActCtx
!= NULL
&& pReleaseActCtx
!= NULL
)
914 memset(&actctxinfo
, 0, sizeof(ACTCTXA
));
915 actctxinfo
.cbSize
= sizeof(ACTCTXA
);
916 actctxinfo
.dwFlags
= ACTCTX_FLAG_RESOURCE_NAME_VALID
;
917 actctxinfo
.lpSource
= wine_tests
[nr_of_files
].exename
;
918 actctxinfo
.lpResourceName
= (LPSTR
)CREATEPROCESS_MANIFEST_RESOURCE_ID
;
919 actctx
= pCreateActCtxA(&actctxinfo
);
920 if (actctx
!= INVALID_HANDLE_VALUE
&&
921 ! pActivateActCtx(actctx
, &cookie
))
923 pReleaseActCtx(actctx
);
924 actctx
= INVALID_HANDLE_VALUE
;
926 } else actctx
= INVALID_HANDLE_VALUE
;
928 wine_tests
[nr_of_files
].maindllpath
= NULL
;
929 strcpy(filename
, dllname
);
930 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
932 if (!dll
) dll
= load_com_dll(dllname
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
934 if (!dll
&& pLoadLibraryShim
)
936 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
937 if (SUCCEEDED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) ) && dll
)
939 get_dll_path(dll
, &wine_tests
[nr_of_files
].maindllpath
, filename
);
941 dll
= LoadLibraryExA(filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
948 xprintf (" %s=dll is missing\n", dllname
);
949 if (actctx
!= INVALID_HANDLE_VALUE
)
951 pDeactivateActCtx(0, cookie
);
952 pReleaseActCtx(actctx
);
956 if(is_stub_dll(dllname
))
959 xprintf (" %s=dll is a stub\n", dllname
);
960 if (actctx
!= INVALID_HANDLE_VALUE
)
962 pDeactivateActCtx(0, cookie
);
963 pReleaseActCtx(actctx
);
967 if (is_native_dll(dll
))
970 xprintf (" %s=load error Configured as native\n", dllname
);
972 if (actctx
!= INVALID_HANDLE_VALUE
)
974 pDeactivateActCtx(0, cookie
);
975 pReleaseActCtx(actctx
);
981 if (!(err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
)))
983 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
984 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
989 xprintf (" %s=load error %u\n", dllname
, err
);
992 if (actctx
!= INVALID_HANDLE_VALUE
)
994 pDeactivateActCtx(0, cookie
);
995 pReleaseActCtx(actctx
);
1001 run_tests (char *logname
, char *outdir
)
1004 char *strres
, *eol
, *nextline
;
1006 SECURITY_ATTRIBUTES sa
;
1007 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
1011 /* Get the current PATH only once */
1012 needed
= GetEnvironmentVariableA("PATH", NULL
, 0);
1013 curpath
= heap_alloc(needed
);
1014 GetEnvironmentVariableA("PATH", curpath
, needed
);
1016 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
1018 if (!GetTempPathA( MAX_PATH
, tmppath
))
1019 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1022 static char tmpname
[MAX_PATH
];
1023 if (!GetTempFileNameA( tmppath
, "res", 0, tmpname
))
1024 report (R_FATAL
, "Can't name logfile.");
1027 report (R_OUT
, logname
);
1029 /* make handle inheritable */
1030 sa
.nLength
= sizeof(sa
);
1031 sa
.lpSecurityDescriptor
= NULL
;
1032 sa
.bInheritHandle
= TRUE
;
1034 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
1035 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1036 &sa
, CREATE_ALWAYS
, 0, NULL
);
1038 if ((logfile
== INVALID_HANDLE_VALUE
) &&
1039 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
1040 /* FILE_SHARE_DELETE not supported on win9x */
1041 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
1042 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1043 &sa
, CREATE_ALWAYS
, 0, NULL
);
1045 if (logfile
== INVALID_HANDLE_VALUE
)
1046 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
1048 /* try stable path for ZoneAlarm */
1050 strcpy( tempdir
, tmppath
);
1051 strcat( tempdir
, "wct" );
1053 if (!CreateDirectoryA( tempdir
, NULL
))
1055 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
1056 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
1057 DeleteFileA( tempdir
);
1058 if (!CreateDirectoryA( tempdir
, NULL
))
1059 report (R_FATAL
, "Could not create directory: %s", tempdir
);
1063 strcpy( tempdir
, outdir
);
1065 report (R_DIR
, tempdir
);
1067 xprintf ("Version 4\n");
1068 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
1069 xprintf ("Archive: -\n"); /* no longer used */
1070 xprintf ("Tag: %s\n", tag
);
1071 xprintf ("Build info:\n");
1072 strres
= extract_rcdata ("BUILD_INFO", "STRINGRES", &strsize
);
1074 eol
= memchr (strres
, '\n', strsize
);
1077 eol
= strres
+ strsize
;
1079 strsize
-= eol
- strres
+ 1;
1080 nextline
= strsize
?eol
+1:NULL
;
1081 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
1083 xprintf (" %.*s\n", eol
-strres
, strres
);
1086 xprintf ("Operating system version:\n");
1089 xprintf ("Dll info:\n" );
1091 report (R_STATUS
, "Counting tests");
1092 if (!EnumResourceNamesA (NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1093 report (R_FATAL
, "Can't enumerate test files: %d",
1095 wine_tests
= heap_alloc (nr_of_files
* sizeof wine_tests
[0]);
1097 /* Do this only once during extraction (and version checking) */
1098 hmscoree
= LoadLibraryA("mscoree.dll");
1099 pLoadLibraryShim
= NULL
;
1101 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
1102 kernel32
= GetModuleHandleA("kernel32.dll");
1103 pCreateActCtxA
= (void *)GetProcAddress(kernel32
, "CreateActCtxA");
1104 pActivateActCtx
= (void *)GetProcAddress(kernel32
, "ActivateActCtx");
1105 pDeactivateActCtx
= (void *)GetProcAddress(kernel32
, "DeactivateActCtx");
1106 pReleaseActCtx
= (void *)GetProcAddress(kernel32
, "ReleaseActCtx");
1108 report (R_STATUS
, "Extracting tests");
1109 report (R_PROGRESS
, 0, nr_of_files
);
1113 if (!EnumResourceNamesA (NULL
, "TESTRES", extract_test_proc
, (LPARAM
)tempdir
))
1114 report (R_FATAL
, "Can't enumerate test files: %d",
1117 FreeLibrary(hmscoree
);
1119 if (aborting
) return logname
;
1121 xprintf ("Test output:\n" );
1123 report (R_DELTA
, 0, "Extracting: Done");
1126 report( R_WARNING
, "Some dlls are configured as native, you won't be able to submit results." );
1128 report (R_STATUS
, "Running tests");
1129 report (R_PROGRESS
, 1, nr_of_tests
);
1130 for (i
= 0; i
< nr_of_files
; i
++) {
1131 struct wine_test
*test
= wine_tests
+ i
;
1134 if (aborting
) break;
1136 if (test
->maindllpath
) {
1137 /* We need to add the path (to the main dll) to PATH */
1138 append_path(test
->maindllpath
);
1141 for (j
= 0; j
< test
->subtest_count
; j
++) {
1142 if (aborting
) break;
1143 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
1146 if (test
->maindllpath
) {
1147 /* Restore PATH again */
1148 SetEnvironmentVariableA("PATH", curpath
);
1151 report (R_DELTA
, 0, "Running: Done");
1153 report (R_STATUS
, "Cleaning up - %u failures", failures
);
1154 CloseHandle( logfile
);
1157 remove_dir (tempdir
);
1158 heap_free(wine_tests
);
1164 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
1166 if (ctrl_type
== CTRL_C_EVENT
) {
1167 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
1175 static BOOL CALLBACK
1176 extract_only_proc (HMODULE hModule
, LPCSTR lpszType
, LPSTR lpszName
, LONG_PTR lParam
)
1178 const char *target_dir
= (const char *)lParam
;
1179 char filename
[MAX_PATH
];
1181 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
1183 strcpy(filename
, lpszName
);
1184 CharLowerA(filename
);
1186 extract_test( &wine_tests
[nr_of_files
], target_dir
, filename
);
1191 static void extract_only (const char *target_dir
)
1195 report (R_DIR
, target_dir
);
1196 res
= CreateDirectoryA( target_dir
, NULL
);
1197 if (!res
&& GetLastError() != ERROR_ALREADY_EXISTS
)
1198 report (R_FATAL
, "Could not create directory: %s (%d)", target_dir
, GetLastError ());
1201 report (R_STATUS
, "Counting tests");
1202 if (!EnumResourceNamesA(NULL
, "TESTRES", EnumTestFileProc
, (LPARAM
)&nr_of_files
))
1203 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1205 wine_tests
= heap_alloc (nr_of_files
* sizeof wine_tests
[0] );
1207 report (R_STATUS
, "Extracting tests");
1208 report (R_PROGRESS
, 0, nr_of_files
);
1210 if (!EnumResourceNamesA(NULL
, "TESTRES", extract_only_proc
, (LPARAM
)target_dir
))
1211 report (R_FATAL
, "Can't enumerate test files: %d", GetLastError ());
1213 report (R_DELTA
, 0, "Extracting: Done");
1220 "Usage: winetest [OPTION]... [TESTS]\n\n"
1221 " --help print this message and exit\n"
1222 " --version print the build version and exit\n"
1223 " -c console mode, no GUI\n"
1224 " -d DIR Use DIR as temp directory (default: %%TEMP%%\\wct)\n"
1225 " -e preserve the environment\n"
1226 " -h print this message and exit\n"
1227 " -i INFO an optional description of the test platform\n"
1228 " -m MAIL an email address to enable developers to contact you\n"
1229 " -n exclude the specified tests\n"
1230 " -p shutdown when the tests are done\n"
1231 " -q quiet mode, no output at all\n"
1232 " -o FILE put report into FILE, do not submit\n"
1233 " -s FILE submit FILE, do not run tests\n"
1234 " -S URL URL to submit the results to\n"
1235 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"
1236 " -u URL include TestBot URL in the report\n"
1237 " -x DIR Extract tests to DIR (default: .\\wct) and exit\n");
1240 int __cdecl
main( int argc
, char *argv
[] )
1242 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
1243 char *logname
= NULL
, *outdir
= NULL
;
1244 const char *extract
= NULL
;
1245 const char *cp
, *submit
= NULL
, *submiturl
= NULL
;
1248 int interactive
= 1;
1251 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
1253 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
1254 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &is_wow64
)) is_wow64
= FALSE
;
1256 for (i
= 1; i
< argc
&& argv
[i
]; i
++)
1258 if (!strcmp(argv
[i
], "--help")) {
1262 else if (!strcmp(argv
[i
], "--version")) {
1263 printf("%-12.12s\n", build_id
[0] ? build_id
: "unknown");
1266 else if ((argv
[i
][0] != '-' && argv
[i
][0] != '/') || argv
[i
][2]) {
1267 if (nb_filters
== ARRAY_SIZE(filters
))
1269 report (R_ERROR
, "Too many test filters specified");
1272 filters
[nb_filters
++] = argv
[i
];
1274 else switch (argv
[i
][1]) {
1276 report (R_TEXTMODE
);
1287 if (!(description
= argv
[++i
]))
1294 if (!(email
= argv
[++i
]))
1301 exclude_tests
= TRUE
;
1311 if (!(submit
= argv
[++i
]))
1318 if (!(submiturl
= argv
[++i
]))
1325 if (!(logname
= argv
[++i
]))
1332 if (!(tag
= argv
[++i
]))
1337 if (strlen (tag
) > MAXTAGLEN
)
1338 report (R_FATAL
, "tag is too long (maximum %d characters)",
1340 cp
= findbadtagchar (tag
);
1342 report (R_ERROR
, "invalid char in tag: %c", *cp
);
1348 if (!(url
= argv
[++i
]))
1355 report (R_TEXTMODE
);
1356 if (!(extract
= argv
[++i
]))
1359 extract_only (extract
);
1365 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
1372 report (R_WARNING
, "ignoring tag for submission");
1373 send_file (submiturl
, submit
);
1375 } else if (!extract
) {
1376 int is_win9x
= (GetVersion() & 0x80000000) != 0;
1378 report (R_STATUS
, "Starting up");
1381 report (R_WARNING
, "Running on win9x is not supported. You won't be able to submit results.");
1383 if (!running_on_visible_desktop ())
1384 report (R_FATAL
, "Tests must be run on a visible desktop");
1386 if (running_under_wine())
1388 if (!check_mount_mgr())
1389 report (R_FATAL
, "Mount manager not running, most likely your WINEPREFIX wasn't created correctly.");
1391 if (!check_wow64_registry())
1392 report (R_FATAL
, "WoW64 keys missing, most likely your WINEPREFIX wasn't created correctly.");
1394 if (!check_display_driver())
1395 report (R_FATAL
, "Unable to create a window, the display driver is not working.");
1398 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
1402 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
1403 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
1404 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
1405 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
1408 if (nb_filters
&& !exclude_tests
)
1410 run_tests( logname
, outdir
);
1416 report (R_FATAL
, "Please specify a tag (-t option) if "
1417 "running noninteractive!");
1418 if (guiAskTag () == IDABORT
) exit (1);
1424 report (R_FATAL
, "Please specify an email address (-m option) to enable developers\n"
1425 " to contact you about your report if necessary.");
1426 if (guiAskEmail () == IDABORT
) exit (1);
1430 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
1431 "To submit results, winetest needs to be built from a git checkout." );
1434 logname
= run_tests (NULL
, outdir
);
1436 DeleteFileA(logname
);
1439 if (failures
> FAILURES_LIMIT
)
1441 "%d tests failed. There is probably something broken with your setup.\n"
1442 "You need to address this before submitting results.", failures
);
1444 if (build_id
[0] && nr_of_skips
<= SKIP_LIMIT
&& failures
<= FAILURES_LIMIT
&&
1445 !nr_native_dlls
&& !is_win9x
&&
1446 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
1447 if (!send_file (submiturl
, logname
) && !DeleteFileA(logname
))
1448 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
1449 } else run_tests (logname
, outdir
);
1450 report (R_STATUS
, "Finished - %u failures", failures
);
1455 TOKEN_PRIVILEGES npr
;
1457 /* enable the shutdown privilege for the current process */
1458 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1460 LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr
.Privileges
[0].Luid
);
1461 npr
.PrivilegeCount
= 1;
1462 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1463 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
1464 CloseHandle(hToken
);
1466 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);