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.
29 #include "wine/port.h"
48 static struct wine_test
*wine_tests
;
49 static int nr_of_files
, nr_of_tests
;
50 static const char whitespace
[] = " \t\r\n";
51 static const char testexe
[] = "_test.exe";
52 static char build_id
[64];
54 /* filters for running only specific tests */
55 static char *filters
[64];
56 static unsigned int nb_filters
= 0;
58 /* Needed to check for .NET dlls */
59 static HMODULE hmscoree
;
60 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR
, LPCWSTR
, LPVOID
, HMODULE
*);
62 /* check if test is being filtered out */
63 static BOOL
test_filtered_out( LPCSTR module
, LPCSTR testname
)
65 char *p
, dllname
[MAX_PATH
];
68 strcpy( dllname
, module
);
69 CharLowerA( dllname
);
70 p
= strstr( dllname
, testexe
);
72 len
= strlen(dllname
);
74 if (!nb_filters
) return FALSE
;
75 for (i
= 0; i
< nb_filters
; i
++)
77 if (!strncmp( dllname
, filters
[i
], len
))
79 if (!filters
[i
][len
]) return FALSE
;
80 if (filters
[i
][len
] != ':') continue;
81 if (!testname
|| !strcmp( testname
, &filters
[i
][len
+1] )) return FALSE
;
87 static char * get_file_version(char * file_name
)
89 static char version
[32];
93 size
= GetFileVersionInfoSizeA(file_name
, &handle
);
95 char * data
= xmalloc(size
);
97 if (GetFileVersionInfoA(file_name
, handle
, size
, data
)) {
98 static char backslash
[] = "\\";
99 VS_FIXEDFILEINFO
*pFixedVersionInfo
;
101 if (VerQueryValueA(data
, backslash
, (LPVOID
*)&pFixedVersionInfo
, &len
)) {
102 sprintf(version
, "%d.%d.%d.%d",
103 pFixedVersionInfo
->dwFileVersionMS
>> 16,
104 pFixedVersionInfo
->dwFileVersionMS
& 0xffff,
105 pFixedVersionInfo
->dwFileVersionLS
>> 16,
106 pFixedVersionInfo
->dwFileVersionLS
& 0xffff);
108 sprintf(version
, "version not available");
110 sprintf(version
, "unknown");
113 sprintf(version
, "failed");
115 sprintf(version
, "version not available");
120 static int running_under_wine (void)
122 HMODULE module
= GetModuleHandleA("ntdll.dll");
124 if (!module
) return 0;
125 return (GetProcAddress(module
, "wine_server_call") != NULL
);
128 static int running_on_visible_desktop (void)
131 HMODULE huser32
= GetModuleHandle("user32.dll");
132 FARPROC pGetProcessWindowStation
= GetProcAddress(huser32
, "GetProcessWindowStation");
133 FARPROC pGetUserObjectInformationA
= GetProcAddress(huser32
, "GetUserObjectInformationA");
135 desktop
= GetDesktopWindow();
136 if (!GetWindowLongPtrW(desktop
, GWLP_WNDPROC
)) /* Win9x */
137 return IsWindowVisible(desktop
);
139 if (pGetProcessWindowStation
&& pGetUserObjectInformationA
)
143 USEROBJECTFLAGS uoflags
;
145 wstation
= (HWINSTA
)pGetProcessWindowStation();
146 assert(pGetUserObjectInformationA(wstation
, UOI_FLAGS
, &uoflags
, sizeof(uoflags
), &len
));
147 return (uoflags
.dwFlags
& WSF_VISIBLE
) != 0;
149 return IsWindowVisible(desktop
);
152 static void print_version (void)
155 static const char platform
[] = "i386";
156 #elif defined(__x86_64__)
157 static const char platform
[] = "x86_64";
158 #elif defined(__sparc__)
159 static const char platform
[] = "sparc";
160 #elif defined(__ALPHA__)
161 static const char platform
[] = "alpha";
162 #elif defined(__powerpc__)
163 static const char platform
[] = "powerpc";
168 const char *(CDECL
*wine_get_build_id
)(void);
169 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
170 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
172 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
173 if (!(ext
= GetVersionEx ((OSVERSIONINFO
*) &ver
)))
175 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
176 if (!GetVersionEx ((OSVERSIONINFO
*) &ver
))
177 report (R_FATAL
, "Can't get OS version.");
179 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
180 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &wow64
)) wow64
= FALSE
;
182 xprintf (" Platform=%s%s\n", platform
, wow64
? " (WOW64)" : "");
183 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
184 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
185 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
186 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
187 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
188 ver
.dwPlatformId
, ver
.szCSDVersion
);
190 wine_get_build_id
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
191 wine_get_host_version
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
192 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
193 if (wine_get_host_version
)
195 const char *sysname
, *release
;
196 wine_get_host_version( &sysname
, &release
);
197 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
199 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
201 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
205 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
206 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
207 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
208 ver
.wProductType
, ver
.wReserved
);
211 static inline int is_dot_dir(const char* x
)
213 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
216 static void remove_dir (const char *dir
)
221 size_t dirlen
= strlen (dir
);
223 /* Make sure the directory exists before going further */
224 memcpy (path
, dir
, dirlen
);
225 strcpy (path
+ dirlen
++, "\\*");
226 hFind
= FindFirstFile (path
, &wfd
);
227 if (hFind
== INVALID_HANDLE_VALUE
) return;
230 char *lp
= wfd
.cFileName
;
232 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
233 if (is_dot_dir (lp
)) continue;
234 strcpy (path
+ dirlen
, lp
);
235 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
237 else if (!DeleteFile (path
))
238 report (R_WARNING
, "Can't delete file %s: error %d",
239 path
, GetLastError ());
240 } while (FindNextFile (hFind
, &wfd
));
242 if (!RemoveDirectory (dir
))
243 report (R_WARNING
, "Can't remove directory %s: error %d",
244 dir
, GetLastError ());
247 static const char* get_test_source_file(const char* test
, const char* subtest
)
249 static const char* special_dirs
[][2] = {
252 static char buffer
[MAX_PATH
];
255 for (i
= 0; special_dirs
[i
][0]; i
++) {
256 if (strcmp(test
, special_dirs
[i
][0]) == 0) {
257 test
= special_dirs
[i
][1];
262 snprintf(buffer
, sizeof(buffer
), "dlls/%s/tests/%s.c", test
, subtest
);
266 static void* extract_rcdata (LPTSTR name
, int type
, DWORD
* size
)
272 if (!(rsrc
= FindResource (NULL
, name
, MAKEINTRESOURCE(type
))) ||
273 !(*size
= SizeofResource (0, rsrc
)) ||
274 !(hdl
= LoadResource (0, rsrc
)) ||
275 !(addr
= LockResource (hdl
)))
280 /* Fills in the name and exename fields */
282 extract_test (struct wine_test
*test
, const char *dir
, LPTSTR res_name
)
290 code
= extract_rcdata (res_name
, TESTRES
, &size
);
291 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
292 res_name
, GetLastError ());
293 test
->name
= xstrdup( res_name
);
294 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
295 exepos
= strstr (test
->name
, testexe
);
296 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
298 test
->name
= xrealloc (test
->name
, exepos
- test
->name
+ 1);
299 report (R_STEP
, "Extracting: %s", test
->name
);
301 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
302 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
303 if (hfile
== INVALID_HANDLE_VALUE
)
304 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
306 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
307 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
312 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
315 Return the exit status, -2 if can't create process or the return
316 value of WaitForSingleObject.
319 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
)
322 PROCESS_INFORMATION pi
;
325 GetStartupInfo (&si
);
326 si
.dwFlags
= STARTF_USESTDHANDLES
;
327 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
328 si
.hStdOutput
= out_file
? out_file
: GetStdHandle( STD_OUTPUT_HANDLE
);
329 si
.hStdError
= out_file
? out_file
: GetStdHandle( STD_ERROR_HANDLE
);
331 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, CREATE_DEFAULT_ERROR_MODE
,
332 NULL
, tempdir
, &si
, &pi
)) {
335 CloseHandle (pi
.hThread
);
336 wait
= WaitForSingleObject (pi
.hProcess
, ms
);
337 if (wait
== WAIT_OBJECT_0
) {
338 GetExitCodeProcess (pi
.hProcess
, &status
);
342 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
,
346 report (R_ERROR
, "Process '%s' timed out.", cmd
);
349 report (R_ERROR
, "Wait returned %d", wait
);
352 if (!TerminateProcess (pi
.hProcess
, 257))
353 report (R_ERROR
, "TerminateProcess failed: %d",
355 wait
= WaitForSingleObject (pi
.hProcess
, 5000);
359 "Wait for termination of '%s' failed: %d",
360 cmd
, GetLastError ());
365 report (R_ERROR
, "Can't kill process '%s'", cmd
);
368 report (R_ERROR
, "Waiting for termination: %d",
372 CloseHandle (pi
.hProcess
);
379 get_subtests (const char *tempdir
, struct wine_test
*test
, LPTSTR res_name
)
384 char buffer
[8192], *index
;
385 static const char header
[] = "Valid test names:";
386 int status
, allocated
;
387 char tmpdir
[MAX_PATH
], subname
[MAX_PATH
];
388 SECURITY_ATTRIBUTES sa
;
390 test
->subtest_count
= 0;
392 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
393 !GetTempFileNameA( tmpdir
, "sub", 0, subname
))
394 report (R_FATAL
, "Can't name subtests file.");
396 /* make handle inheritable */
397 sa
.nLength
= sizeof(sa
);
398 sa
.lpSecurityDescriptor
= NULL
;
399 sa
.bInheritHandle
= TRUE
;
401 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
402 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
403 &sa
, CREATE_ALWAYS
, 0, NULL
);
405 if ((subfile
== INVALID_HANDLE_VALUE
) &&
406 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
407 /* FILE_SHARE_DELETE not supported on win9x */
408 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
409 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
410 &sa
, CREATE_ALWAYS
, 0, NULL
);
412 if (subfile
== INVALID_HANDLE_VALUE
) {
413 err
= GetLastError();
414 report (R_ERROR
, "Can't open subtests output of %s: %u",
415 test
->name
, GetLastError());
419 extract_test (test
, tempdir
, res_name
);
420 cmd
= strmake (NULL
, "%s --list", test
->exename
);
421 status
= run_ex (cmd
, subfile
, tempdir
, 5000);
422 err
= GetLastError();
427 report (R_ERROR
, "Cannot run %s error %u", test
->exename
, err
);
431 SetFilePointer( subfile
, 0, NULL
, FILE_BEGIN
);
432 ReadFile( subfile
, buffer
, sizeof(buffer
), &total
, NULL
);
433 CloseHandle( subfile
);
434 if (sizeof buffer
== total
) {
435 report (R_ERROR
, "Subtest list of %s too big.",
436 test
->name
, sizeof buffer
);
437 err
= ERROR_OUTOFMEMORY
;
442 index
= strstr (buffer
, header
);
444 report (R_ERROR
, "Can't parse subtests output of %s",
446 err
= ERROR_INTERNAL_ERROR
;
449 index
+= sizeof header
;
452 test
->subtests
= xmalloc (allocated
* sizeof(char*));
453 index
= strtok (index
, whitespace
);
455 if (test
->subtest_count
== allocated
) {
457 test
->subtests
= xrealloc (test
->subtests
,
458 allocated
* sizeof(char*));
460 if (!test_filtered_out( test
->name
, index
))
461 test
->subtests
[test
->subtest_count
++] = xstrdup(index
);
462 index
= strtok (NULL
, whitespace
);
464 test
->subtests
= xrealloc (test
->subtests
,
465 test
->subtest_count
* sizeof(char*));
469 if (!DeleteFileA (subname
))
470 report (R_WARNING
, "Can't delete file '%s': %u", subname
, GetLastError());
475 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
478 const char* file
= get_test_source_file(test
->name
, subtest
);
479 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
481 xprintf ("%s:%s start %s -\n", test
->name
, subtest
, file
);
482 status
= run_ex (cmd
, out_file
, tempdir
, 120000);
484 xprintf ("%s:%s done (%d)\n", test
->name
, subtest
, status
);
488 EnumTestFileProc (HMODULE hModule
, LPCTSTR lpszType
,
489 LPTSTR lpszName
, LONG_PTR lParam
)
491 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
496 extract_test_proc (HMODULE hModule
, LPCTSTR lpszType
,
497 LPTSTR lpszName
, LONG_PTR lParam
)
499 const char *tempdir
= (const char *)lParam
;
500 char dllname
[MAX_PATH
];
501 char filename
[MAX_PATH
];
502 WCHAR dllnameW
[MAX_PATH
];
506 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
508 /* Check if the main dll is present on this system */
509 CharLowerA(lpszName
);
510 strcpy(dllname
, lpszName
);
511 *strstr(dllname
, testexe
) = 0;
513 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
514 if (!dll
&& pLoadLibraryShim
)
516 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
517 if (FAILED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) )) dll
= 0;
520 xprintf (" %s=dll is missing\n", dllname
);
523 GetModuleFileNameA(dll
, filename
, MAX_PATH
);
526 if (!(err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
)))
528 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
529 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
534 xprintf (" %s=load error %u\n", dllname
, err
);
540 run_tests (char *logname
)
543 char *strres
, *eol
, *nextline
;
545 SECURITY_ATTRIBUTES sa
;
546 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
548 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
550 if (!GetTempPathA( MAX_PATH
, tmppath
))
551 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
554 static char tmpname
[MAX_PATH
];
555 if (!GetTempFileNameA( tmppath
, "res", 0, tmpname
))
556 report (R_FATAL
, "Can't name logfile.");
559 report (R_OUT
, logname
);
561 /* make handle inheritable */
562 sa
.nLength
= sizeof(sa
);
563 sa
.lpSecurityDescriptor
= NULL
;
564 sa
.bInheritHandle
= TRUE
;
566 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
567 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
568 &sa
, CREATE_ALWAYS
, 0, NULL
);
570 if ((logfile
== INVALID_HANDLE_VALUE
) &&
571 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
572 /* FILE_SHARE_DELETE not supported on win9x */
573 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
574 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
575 &sa
, CREATE_ALWAYS
, 0, NULL
);
577 if (logfile
== INVALID_HANDLE_VALUE
)
578 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
580 if (!GetTempPathA( MAX_PATH
, tmppath
))
581 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
583 /* try stable path for ZoneAlarm */
584 strcpy( tempdir
, tmppath
);
585 strcat( tempdir
, "wct" );
586 if (!CreateDirectoryA( tempdir
, NULL
))
588 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
589 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
590 DeleteFileA( tempdir
);
591 if (!CreateDirectoryA( tempdir
, NULL
))
592 report (R_FATAL
, "Could not create directory: %s", tempdir
);
594 report (R_DIR
, tempdir
);
596 xprintf ("Version 4\n");
597 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
598 strres
= extract_rcdata (MAKEINTRESOURCE(TESTS_URL
), STRINGRES
, &strsize
);
599 xprintf ("Archive: ");
600 if (strres
) xprintf ("%.*s", strsize
, strres
);
601 else xprintf ("-\n");
602 xprintf ("Tag: %s\n", tag
);
603 xprintf ("Build info:\n");
604 strres
= extract_rcdata (MAKEINTRESOURCE(BUILD_INFO
), STRINGRES
, &strsize
);
606 eol
= memchr (strres
, '\n', strsize
);
609 eol
= strres
+ strsize
;
611 strsize
-= eol
- strres
+ 1;
612 nextline
= strsize
?eol
+1:NULL
;
613 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
615 xprintf (" %.*s\n", eol
-strres
, strres
);
618 xprintf ("Operating system version:\n");
620 xprintf ("Dll info:\n" );
622 report (R_STATUS
, "Counting tests");
623 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
624 EnumTestFileProc
, (LPARAM
)&nr_of_files
))
625 report (R_FATAL
, "Can't enumerate test files: %d",
627 wine_tests
= xmalloc (nr_of_files
* sizeof wine_tests
[0]);
629 /* Do this only once during extraction (and version checking) */
630 hmscoree
= LoadLibraryA("mscoree.dll");
631 pLoadLibraryShim
= NULL
;
633 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
635 report (R_STATUS
, "Extracting tests");
636 report (R_PROGRESS
, 0, nr_of_files
);
639 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
640 extract_test_proc
, (LPARAM
)tempdir
))
641 report (R_FATAL
, "Can't enumerate test files: %d",
644 FreeLibrary(hmscoree
);
646 xprintf ("Test output:\n" );
648 report (R_DELTA
, 0, "Extracting: Done");
650 report (R_STATUS
, "Running tests");
651 report (R_PROGRESS
, 1, nr_of_tests
);
652 for (i
= 0; i
< nr_of_files
; i
++) {
653 struct wine_test
*test
= wine_tests
+ i
;
656 for (j
= 0; j
< test
->subtest_count
; j
++) {
657 report (R_STEP
, "Running: %s:%s", test
->name
,
659 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
662 report (R_DELTA
, 0, "Running: Done");
664 report (R_STATUS
, "Cleaning up");
665 CloseHandle( logfile
);
667 remove_dir (tempdir
);
673 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
675 if (ctrl_type
== CTRL_C_EVENT
) {
676 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
687 "Usage: winetest [OPTION]... [TESTS]\n\n"
688 " -c console mode, no GUI\n"
689 " -e preserve the environment\n"
690 " -h print this message and exit\n"
691 " -p shutdown when the tests are done\n"
692 " -q quiet mode, no output at all\n"
693 " -o FILE put report into FILE, do not submit\n"
694 " -s FILE submit FILE, do not run tests\n"
695 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n");
698 int main( int argc
, char *argv
[] )
700 char *logname
= NULL
;
701 const char *cp
, *submit
= NULL
;
707 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
709 for (i
= 1; argv
[i
]; i
++)
711 if (argv
[i
][0] != '-' || argv
[i
][2]) {
712 if (nb_filters
== sizeof(filters
)/sizeof(filters
[0]))
714 report (R_ERROR
, "Too many test filters specified");
717 filters
[nb_filters
++] = argv
[i
];
719 else switch (argv
[i
][1]) {
739 if (!(submit
= argv
[++i
]))
745 report (R_WARNING
, "ignoring tag for submission");
749 if (!(logname
= argv
[++i
]))
756 if (!(tag
= argv
[++i
]))
761 if (strlen (tag
) > MAXTAGLEN
)
762 report (R_FATAL
, "tag is too long (maximum %d characters)",
764 cp
= findbadtagchar (tag
);
766 report (R_ERROR
, "invalid char in tag: %c", *cp
);
772 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
778 report (R_STATUS
, "Starting up");
780 if (!running_on_visible_desktop ())
781 report (R_FATAL
, "Tests must be run on a visible desktop");
783 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
787 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
788 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
789 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
790 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
793 if (!nb_filters
) /* don't submit results when filtering */
797 report (R_FATAL
, "Please specify a tag (-t option) if "
798 "running noninteractive!");
799 if (guiAskTag () == IDABORT
) exit (1);
804 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
805 "To submit results, winetest needs to be built from a git checkout." );
809 logname
= run_tests (NULL
);
810 if (build_id
[0] && !nb_filters
&&
811 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
812 if (!send_file (logname
) && !DeleteFileA(logname
))
813 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
814 } else run_tests (logname
);
815 report (R_STATUS
, "Finished");
820 TOKEN_PRIVILEGES npr
;
822 /* enable the shutdown privilege for the current process */
823 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
825 LookupPrivilegeValueA(0, SE_SHUTDOWN_NAME
, &npr
.Privileges
[0].Luid
);
826 npr
.PrivilegeCount
= 1;
827 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
828 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
831 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);