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"
50 static struct wine_test
*wine_tests
;
51 static int nr_of_files
, nr_of_tests
;
52 static const char whitespace
[] = " \t\r\n";
53 static const char testexe
[] = "_test.exe";
54 static char build_id
[64];
56 /* filters for running only specific tests */
57 static char *filters
[64];
58 static unsigned int nb_filters
= 0;
60 /* Needed to check for .NET dlls */
61 static HMODULE hmscoree
;
62 static HRESULT (WINAPI
*pLoadLibraryShim
)(LPCWSTR
, LPCWSTR
, LPVOID
, HMODULE
*);
64 /* check if test is being filtered out */
65 static BOOL
test_filtered_out( LPCSTR module
, LPCSTR testname
)
67 char *p
, dllname
[MAX_PATH
];
70 strcpy( dllname
, module
);
71 CharLowerA( dllname
);
72 p
= strstr( dllname
, testexe
);
74 len
= strlen(dllname
);
76 if (!nb_filters
) return FALSE
;
77 for (i
= 0; i
< nb_filters
; i
++)
79 if (!strncmp( dllname
, filters
[i
], len
))
81 if (!filters
[i
][len
]) return FALSE
;
82 if (filters
[i
][len
] != ':') continue;
83 if (!testname
|| !strcmp( testname
, &filters
[i
][len
+1] )) return FALSE
;
89 static char * get_file_version(char * file_name
)
91 static char version
[32];
95 size
= GetFileVersionInfoSizeA(file_name
, &handle
);
97 char * data
= xmalloc(size
);
99 if (GetFileVersionInfoA(file_name
, handle
, size
, data
)) {
100 static char backslash
[] = "\\";
101 VS_FIXEDFILEINFO
*pFixedVersionInfo
;
103 if (VerQueryValueA(data
, backslash
, (LPVOID
*)&pFixedVersionInfo
, &len
)) {
104 sprintf(version
, "%d.%d.%d.%d",
105 pFixedVersionInfo
->dwFileVersionMS
>> 16,
106 pFixedVersionInfo
->dwFileVersionMS
& 0xffff,
107 pFixedVersionInfo
->dwFileVersionLS
>> 16,
108 pFixedVersionInfo
->dwFileVersionLS
& 0xffff);
110 sprintf(version
, "version not available");
112 sprintf(version
, "unknown");
115 sprintf(version
, "failed");
117 sprintf(version
, "version not available");
122 static int running_under_wine (void)
124 HMODULE module
= GetModuleHandleA("ntdll.dll");
126 if (!module
) return 0;
127 return (GetProcAddress(module
, "wine_server_call") != NULL
);
130 static int running_on_visible_desktop (void)
133 HMODULE huser32
= GetModuleHandle("user32.dll");
134 FARPROC pGetProcessWindowStation
= GetProcAddress(huser32
, "GetProcessWindowStation");
135 FARPROC pGetUserObjectInformationA
= GetProcAddress(huser32
, "GetUserObjectInformationA");
137 desktop
= GetDesktopWindow();
138 if (!GetWindowLongPtrW(desktop
, GWLP_WNDPROC
)) /* Win9x */
139 return IsWindowVisible(desktop
);
141 if (pGetProcessWindowStation
&& pGetUserObjectInformationA
)
145 USEROBJECTFLAGS uoflags
;
147 wstation
= (HWINSTA
)pGetProcessWindowStation();
148 assert(pGetUserObjectInformationA(wstation
, UOI_FLAGS
, &uoflags
, sizeof(uoflags
), &len
));
149 return (uoflags
.dwFlags
& WSF_VISIBLE
) != 0;
151 return IsWindowVisible(desktop
);
154 /* check if Gecko is present, trying to trigger the install if not */
155 static BOOL
gecko_check(void)
161 CoInitialize( NULL
);
162 if (FAILED( CoCreateInstance( &CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
,
163 &IID_IHTMLDocument2
, (void **)&doc
))) return FALSE
;
164 if ((ret
= SUCCEEDED( IHTMLDocument2_get_body( doc
, &body
)))) IHTMLElement_Release( body
);
165 IHTMLDocument_Release( doc
);
169 static void print_version (void)
172 static const char platform
[] = "i386";
173 #elif defined(__x86_64__)
174 static const char platform
[] = "x86_64";
175 #elif defined(__sparc__)
176 static const char platform
[] = "sparc";
177 #elif defined(__ALPHA__)
178 static const char platform
[] = "alpha";
179 #elif defined(__powerpc__)
180 static const char platform
[] = "powerpc";
185 const char *(CDECL
*wine_get_build_id
)(void);
186 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
187 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
189 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
190 if (!(ext
= GetVersionEx ((OSVERSIONINFO
*) &ver
)))
192 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
193 if (!GetVersionEx ((OSVERSIONINFO
*) &ver
))
194 report (R_FATAL
, "Can't get OS version.");
196 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
197 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &wow64
)) wow64
= FALSE
;
199 xprintf (" Platform=%s%s\n", platform
, wow64
? " (WOW64)" : "");
200 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
201 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
202 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
203 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
204 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
205 ver
.dwPlatformId
, ver
.szCSDVersion
);
207 wine_get_build_id
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
208 wine_get_host_version
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
209 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
210 if (wine_get_host_version
)
212 const char *sysname
, *release
;
213 wine_get_host_version( &sysname
, &release
);
214 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
216 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
218 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
222 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
223 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
224 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
225 ver
.wProductType
, ver
.wReserved
);
228 static inline int is_dot_dir(const char* x
)
230 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
233 static void remove_dir (const char *dir
)
238 size_t dirlen
= strlen (dir
);
240 /* Make sure the directory exists before going further */
241 memcpy (path
, dir
, dirlen
);
242 strcpy (path
+ dirlen
++, "\\*");
243 hFind
= FindFirstFile (path
, &wfd
);
244 if (hFind
== INVALID_HANDLE_VALUE
) return;
247 char *lp
= wfd
.cFileName
;
249 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
250 if (is_dot_dir (lp
)) continue;
251 strcpy (path
+ dirlen
, lp
);
252 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
254 else if (!DeleteFile (path
))
255 report (R_WARNING
, "Can't delete file %s: error %d",
256 path
, GetLastError ());
257 } while (FindNextFile (hFind
, &wfd
));
259 if (!RemoveDirectory (dir
))
260 report (R_WARNING
, "Can't remove directory %s: error %d",
261 dir
, GetLastError ());
264 static const char* get_test_source_file(const char* test
, const char* subtest
)
266 static const char* special_dirs
[][2] = {
269 static char buffer
[MAX_PATH
];
272 for (i
= 0; special_dirs
[i
][0]; i
++) {
273 if (strcmp(test
, special_dirs
[i
][0]) == 0) {
274 test
= special_dirs
[i
][1];
279 snprintf(buffer
, sizeof(buffer
), "dlls/%s/tests/%s.c", test
, subtest
);
283 static void* extract_rcdata (LPTSTR name
, int type
, DWORD
* size
)
289 if (!(rsrc
= FindResource (NULL
, name
, MAKEINTRESOURCE(type
))) ||
290 !(*size
= SizeofResource (0, rsrc
)) ||
291 !(hdl
= LoadResource (0, rsrc
)) ||
292 !(addr
= LockResource (hdl
)))
297 /* Fills in the name and exename fields */
299 extract_test (struct wine_test
*test
, const char *dir
, LPTSTR res_name
)
307 code
= extract_rcdata (res_name
, TESTRES
, &size
);
308 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
309 res_name
, GetLastError ());
310 test
->name
= xstrdup( res_name
);
311 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
312 exepos
= strstr (test
->name
, testexe
);
313 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
315 test
->name
= xrealloc (test
->name
, exepos
- test
->name
+ 1);
316 report (R_STEP
, "Extracting: %s", test
->name
);
318 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
319 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
320 if (hfile
== INVALID_HANDLE_VALUE
)
321 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
323 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
324 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
329 static DWORD
wait_process( HANDLE process
, DWORD timeout
)
331 DWORD wait
, diff
= 0, start
= GetTickCount();
334 while (diff
< timeout
)
336 wait
= MsgWaitForMultipleObjects( 1, &process
, FALSE
, timeout
- diff
, QS_ALLINPUT
);
337 if (wait
!= WAIT_OBJECT_0
+ 1) return wait
;
338 while (PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
339 diff
= GetTickCount() - start
;
344 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
347 Return the exit status, -2 if can't create process or the return
348 value of WaitForSingleObject.
351 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
)
354 PROCESS_INFORMATION pi
;
357 GetStartupInfo (&si
);
358 si
.dwFlags
= STARTF_USESTDHANDLES
;
359 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
360 si
.hStdOutput
= out_file
? out_file
: GetStdHandle( STD_OUTPUT_HANDLE
);
361 si
.hStdError
= out_file
? out_file
: GetStdHandle( STD_ERROR_HANDLE
);
363 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, CREATE_DEFAULT_ERROR_MODE
,
364 NULL
, tempdir
, &si
, &pi
))
367 CloseHandle (pi
.hThread
);
368 status
= wait_process( pi
.hProcess
, ms
);
372 GetExitCodeProcess (pi
.hProcess
, &status
);
373 CloseHandle (pi
.hProcess
);
376 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
, GetLastError ());
379 report (R_ERROR
, "Process '%s' timed out.", cmd
);
382 report (R_ERROR
, "Wait returned %d", status
);
385 if (!TerminateProcess (pi
.hProcess
, 257))
386 report (R_ERROR
, "TerminateProcess failed: %d", GetLastError ());
387 wait
= wait_process( pi
.hProcess
, 5000 );
393 report (R_ERROR
, "Wait for termination of '%s' failed: %d", cmd
, GetLastError ());
396 report (R_ERROR
, "Can't kill process '%s'", cmd
);
399 report (R_ERROR
, "Waiting for termination: %d", wait
);
402 CloseHandle (pi
.hProcess
);
407 get_subtests (const char *tempdir
, struct wine_test
*test
, LPTSTR res_name
)
412 char buffer
[8192], *index
;
413 static const char header
[] = "Valid test names:";
414 int status
, allocated
;
415 char tmpdir
[MAX_PATH
], subname
[MAX_PATH
];
416 SECURITY_ATTRIBUTES sa
;
418 test
->subtest_count
= 0;
420 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
421 !GetTempFileNameA( tmpdir
, "sub", 0, subname
))
422 report (R_FATAL
, "Can't name subtests file.");
424 /* make handle inheritable */
425 sa
.nLength
= sizeof(sa
);
426 sa
.lpSecurityDescriptor
= NULL
;
427 sa
.bInheritHandle
= TRUE
;
429 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
430 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
431 &sa
, CREATE_ALWAYS
, 0, NULL
);
433 if ((subfile
== INVALID_HANDLE_VALUE
) &&
434 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
435 /* FILE_SHARE_DELETE not supported on win9x */
436 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
437 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
438 &sa
, CREATE_ALWAYS
, 0, NULL
);
440 if (subfile
== INVALID_HANDLE_VALUE
) {
441 err
= GetLastError();
442 report (R_ERROR
, "Can't open subtests output of %s: %u",
443 test
->name
, GetLastError());
447 extract_test (test
, tempdir
, res_name
);
448 cmd
= strmake (NULL
, "%s --list", test
->exename
);
449 status
= run_ex (cmd
, subfile
, tempdir
, 5000);
450 err
= GetLastError();
455 report (R_ERROR
, "Cannot run %s error %u", test
->exename
, err
);
459 SetFilePointer( subfile
, 0, NULL
, FILE_BEGIN
);
460 ReadFile( subfile
, buffer
, sizeof(buffer
), &total
, NULL
);
461 CloseHandle( subfile
);
462 if (sizeof buffer
== total
) {
463 report (R_ERROR
, "Subtest list of %s too big.",
464 test
->name
, sizeof buffer
);
465 err
= ERROR_OUTOFMEMORY
;
470 index
= strstr (buffer
, header
);
472 report (R_ERROR
, "Can't parse subtests output of %s",
474 err
= ERROR_INTERNAL_ERROR
;
477 index
+= sizeof header
;
480 test
->subtests
= xmalloc (allocated
* sizeof(char*));
481 index
= strtok (index
, whitespace
);
483 if (test
->subtest_count
== allocated
) {
485 test
->subtests
= xrealloc (test
->subtests
,
486 allocated
* sizeof(char*));
488 if (!test_filtered_out( test
->name
, index
))
489 test
->subtests
[test
->subtest_count
++] = xstrdup(index
);
490 index
= strtok (NULL
, whitespace
);
492 test
->subtests
= xrealloc (test
->subtests
,
493 test
->subtest_count
* sizeof(char*));
497 if (!DeleteFileA (subname
))
498 report (R_WARNING
, "Can't delete file '%s': %u", subname
, GetLastError());
503 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
506 const char* file
= get_test_source_file(test
->name
, subtest
);
507 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
509 xprintf ("%s:%s start %s -\n", test
->name
, subtest
, file
);
510 status
= run_ex (cmd
, out_file
, tempdir
, 120000);
512 xprintf ("%s:%s done (%d)\n", test
->name
, subtest
, status
);
516 EnumTestFileProc (HMODULE hModule
, LPCTSTR lpszType
,
517 LPTSTR lpszName
, LONG_PTR lParam
)
519 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
524 extract_test_proc (HMODULE hModule
, LPCTSTR lpszType
,
525 LPTSTR lpszName
, LONG_PTR lParam
)
527 const char *tempdir
= (const char *)lParam
;
528 char dllname
[MAX_PATH
];
529 char filename
[MAX_PATH
];
530 WCHAR dllnameW
[MAX_PATH
];
534 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
536 /* Check if the main dll is present on this system */
537 CharLowerA(lpszName
);
538 strcpy(dllname
, lpszName
);
539 *strstr(dllname
, testexe
) = 0;
541 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
542 if (!dll
&& pLoadLibraryShim
)
544 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
545 if (FAILED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) )) dll
= 0;
548 xprintf (" %s=dll is missing\n", dllname
);
551 if (!strcmp( dllname
, "mshtml" ) && running_under_wine() && !gecko_check())
554 xprintf (" %s=load error Gecko is not installed\n", dllname
);
557 GetModuleFileNameA(dll
, filename
, MAX_PATH
);
560 if (!(err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
)))
562 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
563 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
568 xprintf (" %s=load error %u\n", dllname
, err
);
574 run_tests (char *logname
)
577 char *strres
, *eol
, *nextline
;
579 SECURITY_ATTRIBUTES sa
;
580 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
582 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
584 if (!GetTempPathA( MAX_PATH
, tmppath
))
585 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
588 static char tmpname
[MAX_PATH
];
589 if (!GetTempFileNameA( tmppath
, "res", 0, tmpname
))
590 report (R_FATAL
, "Can't name logfile.");
593 report (R_OUT
, logname
);
595 /* make handle inheritable */
596 sa
.nLength
= sizeof(sa
);
597 sa
.lpSecurityDescriptor
= NULL
;
598 sa
.bInheritHandle
= TRUE
;
600 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
601 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
602 &sa
, CREATE_ALWAYS
, 0, NULL
);
604 if ((logfile
== INVALID_HANDLE_VALUE
) &&
605 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
606 /* FILE_SHARE_DELETE not supported on win9x */
607 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
608 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
609 &sa
, CREATE_ALWAYS
, 0, NULL
);
611 if (logfile
== INVALID_HANDLE_VALUE
)
612 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
614 if (!GetTempPathA( MAX_PATH
, tmppath
))
615 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
617 /* try stable path for ZoneAlarm */
618 strcpy( tempdir
, tmppath
);
619 strcat( tempdir
, "wct" );
620 if (!CreateDirectoryA( tempdir
, NULL
))
622 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
623 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
624 DeleteFileA( tempdir
);
625 if (!CreateDirectoryA( tempdir
, NULL
))
626 report (R_FATAL
, "Could not create directory: %s", tempdir
);
628 report (R_DIR
, tempdir
);
630 xprintf ("Version 4\n");
631 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
632 xprintf ("Archive: -\n"); /* no longer used */
633 xprintf ("Tag: %s\n", tag
);
634 xprintf ("Build info:\n");
635 strres
= extract_rcdata (MAKEINTRESOURCE(BUILD_INFO
), STRINGRES
, &strsize
);
637 eol
= memchr (strres
, '\n', strsize
);
640 eol
= strres
+ strsize
;
642 strsize
-= eol
- strres
+ 1;
643 nextline
= strsize
?eol
+1:NULL
;
644 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
646 xprintf (" %.*s\n", eol
-strres
, strres
);
649 xprintf ("Operating system version:\n");
651 xprintf ("Dll info:\n" );
653 report (R_STATUS
, "Counting tests");
654 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
655 EnumTestFileProc
, (LPARAM
)&nr_of_files
))
656 report (R_FATAL
, "Can't enumerate test files: %d",
658 wine_tests
= xmalloc (nr_of_files
* sizeof wine_tests
[0]);
660 /* Do this only once during extraction (and version checking) */
661 hmscoree
= LoadLibraryA("mscoree.dll");
662 pLoadLibraryShim
= NULL
;
664 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
666 report (R_STATUS
, "Extracting tests");
667 report (R_PROGRESS
, 0, nr_of_files
);
670 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
671 extract_test_proc
, (LPARAM
)tempdir
))
672 report (R_FATAL
, "Can't enumerate test files: %d",
675 FreeLibrary(hmscoree
);
677 xprintf ("Test output:\n" );
679 report (R_DELTA
, 0, "Extracting: Done");
681 report (R_STATUS
, "Running tests");
682 report (R_PROGRESS
, 1, nr_of_tests
);
683 for (i
= 0; i
< nr_of_files
; i
++) {
684 struct wine_test
*test
= wine_tests
+ i
;
687 for (j
= 0; j
< test
->subtest_count
; j
++) {
688 report (R_STEP
, "Running: %s:%s", test
->name
,
690 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
693 report (R_DELTA
, 0, "Running: Done");
695 report (R_STATUS
, "Cleaning up");
696 CloseHandle( logfile
);
698 remove_dir (tempdir
);
704 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
706 if (ctrl_type
== CTRL_C_EVENT
) {
707 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
718 "Usage: winetest [OPTION]... [TESTS]\n\n"
719 " -c console mode, no GUI\n"
720 " -e preserve the environment\n"
721 " -h print this message and exit\n"
722 " -p shutdown when the tests are done\n"
723 " -q quiet mode, no output at all\n"
724 " -o FILE put report into FILE, do not submit\n"
725 " -s FILE submit FILE, do not run tests\n"
726 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n");
729 int main( int argc
, char *argv
[] )
731 char *logname
= NULL
;
732 const char *cp
, *submit
= NULL
;
738 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
740 for (i
= 1; argv
[i
]; i
++)
742 if (argv
[i
][0] != '-' || argv
[i
][2]) {
743 if (nb_filters
== sizeof(filters
)/sizeof(filters
[0]))
745 report (R_ERROR
, "Too many test filters specified");
748 filters
[nb_filters
++] = argv
[i
];
750 else switch (argv
[i
][1]) {
770 if (!(submit
= argv
[++i
]))
776 report (R_WARNING
, "ignoring tag for submission");
780 if (!(logname
= argv
[++i
]))
787 if (!(tag
= argv
[++i
]))
792 if (strlen (tag
) > MAXTAGLEN
)
793 report (R_FATAL
, "tag is too long (maximum %d characters)",
795 cp
= findbadtagchar (tag
);
797 report (R_ERROR
, "invalid char in tag: %c", *cp
);
803 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
809 report (R_STATUS
, "Starting up");
811 if (!running_on_visible_desktop ())
812 report (R_FATAL
, "Tests must be run on a visible desktop");
814 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
818 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
819 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
820 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
821 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
824 if (!nb_filters
) /* don't submit results when filtering */
828 report (R_FATAL
, "Please specify a tag (-t option) if "
829 "running noninteractive!");
830 if (guiAskTag () == IDABORT
) exit (1);
835 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
836 "To submit results, winetest needs to be built from a git checkout." );
840 logname
= run_tests (NULL
);
841 if (build_id
[0] && !nb_filters
&&
842 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
843 if (!send_file (logname
) && !DeleteFileA(logname
))
844 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
845 } else run_tests (logname
);
846 report (R_STATUS
, "Finished");
851 TOKEN_PRIVILEGES npr
;
853 /* enable the shutdown privilege for the current process */
854 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
856 LookupPrivilegeValueA(0, SE_SHUTDOWN_NAME
, &npr
.Privileges
[0].Luid
);
857 npr
.PrivilegeCount
= 1;
858 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
859 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
862 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);