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)
158 HRESULT (WINAPI
*pDllGetClassObject
)(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
);
159 IClassFactory
*factory
= NULL
;
160 IHTMLDocument2
*doc
= NULL
;
164 if (!(mshtml
= LoadLibraryA( "mshtml.dll" ))) return FALSE
;
165 if (!(pDllGetClassObject
= (void *)GetProcAddress( mshtml
, "DllGetClassObject" )))
167 if (FAILED(pDllGetClassObject( &CLSID_HTMLDocument
, &IID_IClassFactory
, (void **)&factory
)))
169 if (FAILED(IClassFactory_CreateInstance( factory
, NULL
, &IID_IHTMLDocument2
, (void **)&doc
)))
171 if (FAILED(IHTMLDocument2_get_body( doc
, &body
)))
173 IHTMLElement_Release( body
);
176 if (doc
) IHTMLDocument_Release( doc
);
177 if (factory
) IClassFactory_Release( factory
);
178 FreeLibrary( mshtml
);
182 static void print_version (void)
185 static const char platform
[] = "i386";
186 #elif defined(__x86_64__)
187 static const char platform
[] = "x86_64";
188 #elif defined(__sparc__)
189 static const char platform
[] = "sparc";
190 #elif defined(__ALPHA__)
191 static const char platform
[] = "alpha";
192 #elif defined(__powerpc__)
193 static const char platform
[] = "powerpc";
198 const char *(CDECL
*wine_get_build_id
)(void);
199 void (CDECL
*wine_get_host_version
)( const char **sysname
, const char **release
);
200 BOOL (WINAPI
*pIsWow64Process
)(HANDLE hProcess
, PBOOL Wow64Process
);
202 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
203 if (!(ext
= GetVersionEx ((OSVERSIONINFO
*) &ver
)))
205 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
206 if (!GetVersionEx ((OSVERSIONINFO
*) &ver
))
207 report (R_FATAL
, "Can't get OS version.");
209 pIsWow64Process
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),"IsWow64Process");
210 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &wow64
)) wow64
= FALSE
;
212 xprintf (" Platform=%s%s\n", platform
, wow64
? " (WOW64)" : "");
213 xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
214 xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
215 xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
216 " dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
217 ver
.dwMajorVersion
, ver
.dwMinorVersion
, ver
.dwBuildNumber
,
218 ver
.dwPlatformId
, ver
.szCSDVersion
);
220 wine_get_build_id
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
221 wine_get_host_version
= (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
222 if (wine_get_build_id
) xprintf( " WineBuild=%s\n", wine_get_build_id() );
223 if (wine_get_host_version
)
225 const char *sysname
, *release
;
226 wine_get_host_version( &sysname
, &release
);
227 xprintf( " Host system=%s\n Host version=%s\n", sysname
, release
);
229 is_win2k3_r2
= GetSystemMetrics(SM_SERVERR2
);
231 xprintf(" R2 build number=%d\n", is_win2k3_r2
);
235 xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
236 " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
237 ver
.wServicePackMajor
, ver
.wServicePackMinor
, ver
.wSuiteMask
,
238 ver
.wProductType
, ver
.wReserved
);
241 static inline int is_dot_dir(const char* x
)
243 return ((x
[0] == '.') && ((x
[1] == 0) || ((x
[1] == '.') && (x
[2] == 0))));
246 static void remove_dir (const char *dir
)
251 size_t dirlen
= strlen (dir
);
253 /* Make sure the directory exists before going further */
254 memcpy (path
, dir
, dirlen
);
255 strcpy (path
+ dirlen
++, "\\*");
256 hFind
= FindFirstFile (path
, &wfd
);
257 if (hFind
== INVALID_HANDLE_VALUE
) return;
260 char *lp
= wfd
.cFileName
;
262 if (!lp
[0]) lp
= wfd
.cAlternateFileName
; /* ? FIXME not (!lp) ? */
263 if (is_dot_dir (lp
)) continue;
264 strcpy (path
+ dirlen
, lp
);
265 if (FILE_ATTRIBUTE_DIRECTORY
& wfd
.dwFileAttributes
)
267 else if (!DeleteFile (path
))
268 report (R_WARNING
, "Can't delete file %s: error %d",
269 path
, GetLastError ());
270 } while (FindNextFile (hFind
, &wfd
));
272 if (!RemoveDirectory (dir
))
273 report (R_WARNING
, "Can't remove directory %s: error %d",
274 dir
, GetLastError ());
277 static const char* get_test_source_file(const char* test
, const char* subtest
)
279 static const char* special_dirs
[][2] = {
282 static char buffer
[MAX_PATH
];
285 for (i
= 0; special_dirs
[i
][0]; i
++) {
286 if (strcmp(test
, special_dirs
[i
][0]) == 0) {
287 test
= special_dirs
[i
][1];
292 snprintf(buffer
, sizeof(buffer
), "dlls/%s/tests/%s.c", test
, subtest
);
296 static void* extract_rcdata (LPTSTR name
, int type
, DWORD
* size
)
302 if (!(rsrc
= FindResource (NULL
, name
, MAKEINTRESOURCE(type
))) ||
303 !(*size
= SizeofResource (0, rsrc
)) ||
304 !(hdl
= LoadResource (0, rsrc
)) ||
305 !(addr
= LockResource (hdl
)))
310 /* Fills in the name and exename fields */
312 extract_test (struct wine_test
*test
, const char *dir
, LPTSTR res_name
)
320 code
= extract_rcdata (res_name
, TESTRES
, &size
);
321 if (!code
) report (R_FATAL
, "Can't find test resource %s: %d",
322 res_name
, GetLastError ());
323 test
->name
= xstrdup( res_name
);
324 test
->exename
= strmake (NULL
, "%s\\%s", dir
, test
->name
);
325 exepos
= strstr (test
->name
, testexe
);
326 if (!exepos
) report (R_FATAL
, "Not an .exe file: %s", test
->name
);
328 test
->name
= xrealloc (test
->name
, exepos
- test
->name
+ 1);
329 report (R_STEP
, "Extracting: %s", test
->name
);
331 hfile
= CreateFileA(test
->exename
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
,
332 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
333 if (hfile
== INVALID_HANDLE_VALUE
)
334 report (R_FATAL
, "Failed to open file %s.", test
->exename
);
336 if (!WriteFile(hfile
, code
, size
, &written
, NULL
))
337 report (R_FATAL
, "Failed to write file %s.", test
->exename
);
342 /* Run a command for MS milliseconds. If OUT != NULL, also redirect
345 Return the exit status, -2 if can't create process or the return
346 value of WaitForSingleObject.
349 run_ex (char *cmd
, HANDLE out_file
, const char *tempdir
, DWORD ms
)
352 PROCESS_INFORMATION pi
;
355 GetStartupInfo (&si
);
356 si
.dwFlags
= STARTF_USESTDHANDLES
;
357 si
.hStdInput
= GetStdHandle( STD_INPUT_HANDLE
);
358 si
.hStdOutput
= out_file
? out_file
: GetStdHandle( STD_OUTPUT_HANDLE
);
359 si
.hStdError
= out_file
? out_file
: GetStdHandle( STD_ERROR_HANDLE
);
361 if (!CreateProcessA (NULL
, cmd
, NULL
, NULL
, TRUE
, CREATE_DEFAULT_ERROR_MODE
,
362 NULL
, tempdir
, &si
, &pi
)) {
365 CloseHandle (pi
.hThread
);
366 wait
= WaitForSingleObject (pi
.hProcess
, ms
);
367 if (wait
== WAIT_OBJECT_0
) {
368 GetExitCodeProcess (pi
.hProcess
, &status
);
372 report (R_ERROR
, "Wait for '%s' failed: %d", cmd
,
376 report (R_ERROR
, "Process '%s' timed out.", cmd
);
379 report (R_ERROR
, "Wait returned %d", wait
);
382 if (!TerminateProcess (pi
.hProcess
, 257))
383 report (R_ERROR
, "TerminateProcess failed: %d",
385 wait
= WaitForSingleObject (pi
.hProcess
, 5000);
389 "Wait for termination of '%s' failed: %d",
390 cmd
, GetLastError ());
395 report (R_ERROR
, "Can't kill process '%s'", cmd
);
398 report (R_ERROR
, "Waiting for termination: %d",
402 CloseHandle (pi
.hProcess
);
409 get_subtests (const char *tempdir
, struct wine_test
*test
, LPTSTR res_name
)
414 char buffer
[8192], *index
;
415 static const char header
[] = "Valid test names:";
416 int status
, allocated
;
417 char tmpdir
[MAX_PATH
], subname
[MAX_PATH
];
418 SECURITY_ATTRIBUTES sa
;
420 test
->subtest_count
= 0;
422 if (!GetTempPathA( MAX_PATH
, tmpdir
) ||
423 !GetTempFileNameA( tmpdir
, "sub", 0, subname
))
424 report (R_FATAL
, "Can't name subtests file.");
426 /* make handle inheritable */
427 sa
.nLength
= sizeof(sa
);
428 sa
.lpSecurityDescriptor
= NULL
;
429 sa
.bInheritHandle
= TRUE
;
431 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
432 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
433 &sa
, CREATE_ALWAYS
, 0, NULL
);
435 if ((subfile
== INVALID_HANDLE_VALUE
) &&
436 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
437 /* FILE_SHARE_DELETE not supported on win9x */
438 subfile
= CreateFileA( subname
, GENERIC_READ
|GENERIC_WRITE
,
439 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
440 &sa
, CREATE_ALWAYS
, 0, NULL
);
442 if (subfile
== INVALID_HANDLE_VALUE
) {
443 err
= GetLastError();
444 report (R_ERROR
, "Can't open subtests output of %s: %u",
445 test
->name
, GetLastError());
449 extract_test (test
, tempdir
, res_name
);
450 cmd
= strmake (NULL
, "%s --list", test
->exename
);
451 status
= run_ex (cmd
, subfile
, tempdir
, 5000);
452 err
= GetLastError();
457 report (R_ERROR
, "Cannot run %s error %u", test
->exename
, err
);
461 SetFilePointer( subfile
, 0, NULL
, FILE_BEGIN
);
462 ReadFile( subfile
, buffer
, sizeof(buffer
), &total
, NULL
);
463 CloseHandle( subfile
);
464 if (sizeof buffer
== total
) {
465 report (R_ERROR
, "Subtest list of %s too big.",
466 test
->name
, sizeof buffer
);
467 err
= ERROR_OUTOFMEMORY
;
472 index
= strstr (buffer
, header
);
474 report (R_ERROR
, "Can't parse subtests output of %s",
476 err
= ERROR_INTERNAL_ERROR
;
479 index
+= sizeof header
;
482 test
->subtests
= xmalloc (allocated
* sizeof(char*));
483 index
= strtok (index
, whitespace
);
485 if (test
->subtest_count
== allocated
) {
487 test
->subtests
= xrealloc (test
->subtests
,
488 allocated
* sizeof(char*));
490 if (!test_filtered_out( test
->name
, index
))
491 test
->subtests
[test
->subtest_count
++] = xstrdup(index
);
492 index
= strtok (NULL
, whitespace
);
494 test
->subtests
= xrealloc (test
->subtests
,
495 test
->subtest_count
* sizeof(char*));
499 if (!DeleteFileA (subname
))
500 report (R_WARNING
, "Can't delete file '%s': %u", subname
, GetLastError());
505 run_test (struct wine_test
* test
, const char* subtest
, HANDLE out_file
, const char *tempdir
)
508 const char* file
= get_test_source_file(test
->name
, subtest
);
509 char *cmd
= strmake (NULL
, "%s %s", test
->exename
, subtest
);
511 xprintf ("%s:%s start %s -\n", test
->name
, subtest
, file
);
512 status
= run_ex (cmd
, out_file
, tempdir
, 120000);
514 xprintf ("%s:%s done (%d)\n", test
->name
, subtest
, status
);
518 EnumTestFileProc (HMODULE hModule
, LPCTSTR lpszType
,
519 LPTSTR lpszName
, LONG_PTR lParam
)
521 if (!test_filtered_out( lpszName
, NULL
)) (*(int*)lParam
)++;
526 extract_test_proc (HMODULE hModule
, LPCTSTR lpszType
,
527 LPTSTR lpszName
, LONG_PTR lParam
)
529 const char *tempdir
= (const char *)lParam
;
530 char dllname
[MAX_PATH
];
531 char filename
[MAX_PATH
];
532 WCHAR dllnameW
[MAX_PATH
];
536 if (test_filtered_out( lpszName
, NULL
)) return TRUE
;
538 /* Check if the main dll is present on this system */
539 CharLowerA(lpszName
);
540 strcpy(dllname
, lpszName
);
541 *strstr(dllname
, testexe
) = 0;
543 dll
= LoadLibraryExA(dllname
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
544 if (!dll
&& pLoadLibraryShim
)
546 MultiByteToWideChar(CP_ACP
, 0, dllname
, -1, dllnameW
, MAX_PATH
);
547 if (FAILED( pLoadLibraryShim(dllnameW
, NULL
, NULL
, &dll
) )) dll
= 0;
550 xprintf (" %s=dll is missing\n", dllname
);
553 if (!strcmp( dllname
, "mshtml" ) && running_under_wine() && !gecko_check())
556 xprintf (" %s=load error Gecko is not installed\n", dllname
);
559 GetModuleFileNameA(dll
, filename
, MAX_PATH
);
562 if (!(err
= get_subtests( tempdir
, &wine_tests
[nr_of_files
], lpszName
)))
564 xprintf (" %s=%s\n", dllname
, get_file_version(filename
));
565 nr_of_tests
+= wine_tests
[nr_of_files
].subtest_count
;
570 xprintf (" %s=load error %u\n", dllname
, err
);
576 run_tests (char *logname
)
579 char *strres
, *eol
, *nextline
;
581 SECURITY_ATTRIBUTES sa
;
582 char tmppath
[MAX_PATH
], tempdir
[MAX_PATH
+4];
584 SetErrorMode (SEM_FAILCRITICALERRORS
| SEM_NOGPFAULTERRORBOX
);
586 if (!GetTempPathA( MAX_PATH
, tmppath
))
587 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
590 static char tmpname
[MAX_PATH
];
591 if (!GetTempFileNameA( tmppath
, "res", 0, tmpname
))
592 report (R_FATAL
, "Can't name logfile.");
595 report (R_OUT
, logname
);
597 /* make handle inheritable */
598 sa
.nLength
= sizeof(sa
);
599 sa
.lpSecurityDescriptor
= NULL
;
600 sa
.bInheritHandle
= TRUE
;
602 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
603 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
604 &sa
, CREATE_ALWAYS
, 0, NULL
);
606 if ((logfile
== INVALID_HANDLE_VALUE
) &&
607 (GetLastError() == ERROR_INVALID_PARAMETER
)) {
608 /* FILE_SHARE_DELETE not supported on win9x */
609 logfile
= CreateFileA( logname
, GENERIC_READ
|GENERIC_WRITE
,
610 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
611 &sa
, CREATE_ALWAYS
, 0, NULL
);
613 if (logfile
== INVALID_HANDLE_VALUE
)
614 report (R_FATAL
, "Could not open logfile: %u", GetLastError());
616 if (!GetTempPathA( MAX_PATH
, tmppath
))
617 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
619 /* try stable path for ZoneAlarm */
620 strcpy( tempdir
, tmppath
);
621 strcat( tempdir
, "wct" );
622 if (!CreateDirectoryA( tempdir
, NULL
))
624 if (!GetTempFileNameA( tmppath
, "wct", 0, tempdir
))
625 report (R_FATAL
, "Can't name temporary dir (check %%TEMP%%).");
626 DeleteFileA( tempdir
);
627 if (!CreateDirectoryA( tempdir
, NULL
))
628 report (R_FATAL
, "Could not create directory: %s", tempdir
);
630 report (R_DIR
, tempdir
);
632 xprintf ("Version 4\n");
633 xprintf ("Tests from build %s\n", build_id
[0] ? build_id
: "-" );
634 xprintf ("Archive: -\n"); /* no longer used */
635 xprintf ("Tag: %s\n", tag
);
636 xprintf ("Build info:\n");
637 strres
= extract_rcdata (MAKEINTRESOURCE(BUILD_INFO
), STRINGRES
, &strsize
);
639 eol
= memchr (strres
, '\n', strsize
);
642 eol
= strres
+ strsize
;
644 strsize
-= eol
- strres
+ 1;
645 nextline
= strsize
?eol
+1:NULL
;
646 if (eol
> strres
&& *(eol
-1) == '\r') eol
--;
648 xprintf (" %.*s\n", eol
-strres
, strres
);
651 xprintf ("Operating system version:\n");
653 xprintf ("Dll info:\n" );
655 report (R_STATUS
, "Counting tests");
656 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
657 EnumTestFileProc
, (LPARAM
)&nr_of_files
))
658 report (R_FATAL
, "Can't enumerate test files: %d",
660 wine_tests
= xmalloc (nr_of_files
* sizeof wine_tests
[0]);
662 /* Do this only once during extraction (and version checking) */
663 hmscoree
= LoadLibraryA("mscoree.dll");
664 pLoadLibraryShim
= NULL
;
666 pLoadLibraryShim
= (void *)GetProcAddress(hmscoree
, "LoadLibraryShim");
668 report (R_STATUS
, "Extracting tests");
669 report (R_PROGRESS
, 0, nr_of_files
);
672 if (!EnumResourceNames (NULL
, MAKEINTRESOURCE(TESTRES
),
673 extract_test_proc
, (LPARAM
)tempdir
))
674 report (R_FATAL
, "Can't enumerate test files: %d",
677 FreeLibrary(hmscoree
);
679 xprintf ("Test output:\n" );
681 report (R_DELTA
, 0, "Extracting: Done");
683 report (R_STATUS
, "Running tests");
684 report (R_PROGRESS
, 1, nr_of_tests
);
685 for (i
= 0; i
< nr_of_files
; i
++) {
686 struct wine_test
*test
= wine_tests
+ i
;
689 for (j
= 0; j
< test
->subtest_count
; j
++) {
690 report (R_STEP
, "Running: %s:%s", test
->name
,
692 run_test (test
, test
->subtests
[j
], logfile
, tempdir
);
695 report (R_DELTA
, 0, "Running: Done");
697 report (R_STATUS
, "Cleaning up");
698 CloseHandle( logfile
);
700 remove_dir (tempdir
);
706 static BOOL WINAPI
ctrl_handler(DWORD ctrl_type
)
708 if (ctrl_type
== CTRL_C_EVENT
) {
709 printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
720 "Usage: winetest [OPTION]... [TESTS]\n\n"
721 " -c console mode, no GUI\n"
722 " -e preserve the environment\n"
723 " -h print this message and exit\n"
724 " -p shutdown when the tests are done\n"
725 " -q quiet mode, no output at all\n"
726 " -o FILE put report into FILE, do not submit\n"
727 " -s FILE submit FILE, do not run tests\n"
728 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n");
731 int main( int argc
, char *argv
[] )
733 char *logname
= NULL
;
734 const char *cp
, *submit
= NULL
;
740 if (!LoadStringA( 0, IDS_BUILD_ID
, build_id
, sizeof(build_id
) )) build_id
[0] = 0;
742 for (i
= 1; argv
[i
]; i
++)
744 if (argv
[i
][0] != '-' || argv
[i
][2]) {
745 if (nb_filters
== sizeof(filters
)/sizeof(filters
[0]))
747 report (R_ERROR
, "Too many test filters specified");
750 filters
[nb_filters
++] = argv
[i
];
752 else switch (argv
[i
][1]) {
772 if (!(submit
= argv
[++i
]))
778 report (R_WARNING
, "ignoring tag for submission");
782 if (!(logname
= argv
[++i
]))
789 if (!(tag
= argv
[++i
]))
794 if (strlen (tag
) > MAXTAGLEN
)
795 report (R_FATAL
, "tag is too long (maximum %d characters)",
797 cp
= findbadtagchar (tag
);
799 report (R_ERROR
, "invalid char in tag: %c", *cp
);
805 report (R_ERROR
, "invalid option: -%c", argv
[i
][1]);
811 report (R_STATUS
, "Starting up");
813 if (!running_on_visible_desktop ())
814 report (R_FATAL
, "Tests must be run on a visible desktop");
816 SetConsoleCtrlHandler(ctrl_handler
, TRUE
);
820 SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
821 SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
822 SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
823 SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
826 if (!nb_filters
) /* don't submit results when filtering */
830 report (R_FATAL
, "Please specify a tag (-t option) if "
831 "running noninteractive!");
832 if (guiAskTag () == IDABORT
) exit (1);
837 report( R_WARNING
, "You won't be able to submit results without a valid build id.\n"
838 "To submit results, winetest needs to be built from a git checkout." );
842 logname
= run_tests (NULL
);
843 if (build_id
[0] && !nb_filters
&&
844 report (R_ASK
, MB_YESNO
, "Do you want to submit the test results?") == IDYES
)
845 if (!send_file (logname
) && !DeleteFileA(logname
))
846 report (R_WARNING
, "Can't remove logfile: %u", GetLastError());
847 } else run_tests (logname
);
848 report (R_STATUS
, "Finished");
853 TOKEN_PRIVILEGES npr
;
855 /* enable the shutdown privilege for the current process */
856 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
858 LookupPrivilegeValueA(0, SE_SHUTDOWN_NAME
, &npr
.Privileges
[0].Luid
);
859 npr
.PrivilegeCount
= 1;
860 npr
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
861 AdjustTokenPrivileges(hToken
, FALSE
, &npr
, 0, 0, 0);
864 ExitWindowsEx(EWX_SHUTDOWN
| EWX_POWEROFF
| EWX_FORCEIFHUNG
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
);