2003-12-04 03:01:39 +01:00
|
|
|
/*
|
|
|
|
* Wine Conformance Test EXE
|
|
|
|
*
|
2004-12-22 15:50:50 +01:00
|
|
|
* Copyright 2003, 2004 Jakob Eriksson (for Solid Form Sweden AB)
|
2003-12-04 03:01:39 +01:00
|
|
|
* Copyright 2003 Dimitrie O. Paun
|
|
|
|
* Copyright 2003 Ferenc Wagner
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-12-04 03:01:39 +01:00
|
|
|
*
|
|
|
|
* This program is dedicated to Anna Lindh,
|
|
|
|
* Swedish Minister of Foreign Affairs.
|
|
|
|
* Anna was murdered September 11, 2003.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2005-03-10 18:17:35 +01:00
|
|
|
#include <assert.h>
|
2003-12-04 03:01:39 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "winetest.h"
|
2004-06-16 00:45:15 +02:00
|
|
|
#include "resource.h"
|
2004-01-15 02:48:05 +01:00
|
|
|
|
2003-12-04 03:01:39 +01:00
|
|
|
struct wine_test
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
int resource;
|
|
|
|
int subtest_count;
|
|
|
|
char **subtests;
|
|
|
|
char *exename;
|
|
|
|
};
|
|
|
|
|
2005-03-31 17:22:41 +02:00
|
|
|
char *tag = NULL;
|
2004-01-15 02:48:05 +01:00
|
|
|
static struct wine_test *wine_tests;
|
2006-09-11 14:23:07 +02:00
|
|
|
static int nr_of_files, nr_of_tests;
|
2004-09-07 21:33:52 +02:00
|
|
|
static const char whitespace[] = " \t\r\n";
|
2007-08-03 12:59:36 +02:00
|
|
|
static const char testexe[] = "_test.exe";
|
2008-05-27 11:48:50 +02:00
|
|
|
static char build_id[64];
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2007-08-23 18:28:23 +02:00
|
|
|
static char * get_file_version(char * file_name)
|
|
|
|
{
|
|
|
|
static char version[32];
|
|
|
|
DWORD size;
|
|
|
|
DWORD handle;
|
|
|
|
|
|
|
|
size = GetFileVersionInfoSizeA(file_name, &handle);
|
|
|
|
if (size) {
|
|
|
|
char * data = xmalloc(size);
|
|
|
|
if (data) {
|
|
|
|
if (GetFileVersionInfoA(file_name, handle, size, data)) {
|
|
|
|
static char backslash[] = "\\";
|
|
|
|
VS_FIXEDFILEINFO *pFixedVersionInfo;
|
|
|
|
UINT len;
|
|
|
|
if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) {
|
|
|
|
sprintf(version, "%d.%d.%d.%d",
|
|
|
|
pFixedVersionInfo->dwFileVersionMS >> 16,
|
|
|
|
pFixedVersionInfo->dwFileVersionMS & 0xffff,
|
|
|
|
pFixedVersionInfo->dwFileVersionLS >> 16,
|
|
|
|
pFixedVersionInfo->dwFileVersionLS & 0xffff);
|
|
|
|
} else
|
|
|
|
sprintf(version, "version not available");
|
|
|
|
} else
|
|
|
|
sprintf(version, "unknown");
|
|
|
|
free(data);
|
|
|
|
} else
|
|
|
|
sprintf(version, "failed");
|
|
|
|
} else
|
|
|
|
sprintf(version, "version not available");
|
|
|
|
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static int running_under_wine (void)
|
2004-04-23 02:06:57 +02:00
|
|
|
{
|
|
|
|
HMODULE module = GetModuleHandleA("ntdll.dll");
|
|
|
|
|
|
|
|
if (!module) return 0;
|
2004-04-23 04:46:18 +02:00
|
|
|
return (GetProcAddress(module, "wine_server_call") != NULL);
|
2004-04-23 02:06:57 +02:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static int running_on_visible_desktop (void)
|
2004-12-22 15:50:50 +01:00
|
|
|
{
|
2005-03-14 11:06:22 +01:00
|
|
|
HWND desktop;
|
|
|
|
HMODULE huser32 = GetModuleHandle("user32.dll");
|
|
|
|
FARPROC pGetProcessWindowStation = GetProcAddress(huser32, "GetProcessWindowStation");
|
|
|
|
FARPROC pGetUserObjectInformationA = GetProcAddress(huser32, "GetUserObjectInformationA");
|
2005-03-07 11:58:37 +01:00
|
|
|
|
2005-03-14 11:06:22 +01:00
|
|
|
desktop = GetDesktopWindow();
|
|
|
|
if (!GetWindowLongPtrW(desktop, GWLP_WNDPROC)) /* Win9x */
|
|
|
|
return IsWindowVisible(desktop);
|
|
|
|
|
|
|
|
if (pGetProcessWindowStation && pGetUserObjectInformationA)
|
2005-03-10 18:17:35 +01:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
HWINSTA wstation;
|
|
|
|
USEROBJECTFLAGS uoflags;
|
2005-03-07 11:58:37 +01:00
|
|
|
|
2005-03-10 18:17:35 +01:00
|
|
|
wstation = (HWINSTA)pGetProcessWindowStation();
|
|
|
|
assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len));
|
|
|
|
return (uoflags.dwFlags & WSF_VISIBLE) != 0;
|
|
|
|
}
|
2005-03-14 11:06:22 +01:00
|
|
|
return IsWindowVisible(desktop);
|
2004-12-22 15:50:50 +01:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void print_version (void)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
|
|
|
OSVERSIONINFOEX ver;
|
|
|
|
BOOL ext;
|
2005-09-15 20:56:20 +02:00
|
|
|
int is_win2k3_r2;
|
2008-03-27 16:47:31 +01:00
|
|
|
const char *(*wine_get_build_id)(void);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
|
|
|
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
|
|
if (!(ext = GetVersionEx ((OSVERSIONINFO *) &ver)))
|
|
|
|
{
|
|
|
|
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
if (!GetVersionEx ((OSVERSIONINFO *) &ver))
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_FATAL, "Can't get OS version.");
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2004-04-23 04:52:21 +02:00
|
|
|
xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
|
2004-12-22 15:50:50 +01:00
|
|
|
xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
|
2008-06-10 17:45:24 +02:00
|
|
|
xprintf (" dwMajorVersion=%u\n dwMinorVersion=%u\n"
|
|
|
|
" dwBuildNumber=%u\n PlatformId=%u\n szCSDVersion=%s\n",
|
2003-12-04 03:01:39 +01:00
|
|
|
ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber,
|
|
|
|
ver.dwPlatformId, ver.szCSDVersion);
|
|
|
|
|
2008-03-27 16:47:31 +01:00
|
|
|
wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
|
|
|
|
if (wine_get_build_id) xprintf( " WineBuild=%s\n", wine_get_build_id() );
|
|
|
|
|
2005-09-15 20:56:20 +02:00
|
|
|
is_win2k3_r2 = GetSystemMetrics(SM_SERVERR2);
|
|
|
|
if(is_win2k3_r2)
|
|
|
|
xprintf(" R2 build number=%d\n", is_win2k3_r2);
|
|
|
|
|
2003-12-04 03:01:39 +01:00
|
|
|
if (!ext) return;
|
|
|
|
|
|
|
|
xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
|
|
|
|
" wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
|
|
|
|
ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask,
|
|
|
|
ver.wProductType, ver.wReserved);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int is_dot_dir(const char* x)
|
|
|
|
{
|
|
|
|
return ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))));
|
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void remove_dir (const char *dir)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
|
|
|
HANDLE hFind;
|
|
|
|
WIN32_FIND_DATA wfd;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
size_t dirlen = strlen (dir);
|
|
|
|
|
|
|
|
/* Make sure the directory exists before going further */
|
|
|
|
memcpy (path, dir, dirlen);
|
|
|
|
strcpy (path + dirlen++, "\\*");
|
|
|
|
hFind = FindFirstFile (path, &wfd);
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE) return;
|
|
|
|
|
|
|
|
do {
|
|
|
|
char *lp = wfd.cFileName;
|
|
|
|
|
|
|
|
if (!lp[0]) lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */
|
|
|
|
if (is_dot_dir (lp)) continue;
|
|
|
|
strcpy (path + dirlen, lp);
|
|
|
|
if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
|
|
|
|
remove_dir(path);
|
|
|
|
else if (!DeleteFile (path))
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_WARNING, "Can't delete file %s: error %d",
|
|
|
|
path, GetLastError ());
|
2003-12-04 03:01:39 +01:00
|
|
|
} while (FindNextFile (hFind, &wfd));
|
|
|
|
FindClose (hFind);
|
|
|
|
if (!RemoveDirectory (dir))
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_WARNING, "Can't remove directory %s: error %d",
|
|
|
|
dir, GetLastError ());
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static const char* get_test_source_file(const char* test, const char* subtest)
|
2004-03-20 20:21:39 +01:00
|
|
|
{
|
|
|
|
static const char* special_dirs[][2] = {
|
2006-12-12 17:18:43 +01:00
|
|
|
{ 0, 0 }
|
2004-03-20 20:21:39 +01:00
|
|
|
};
|
|
|
|
static char buffer[MAX_PATH];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; special_dirs[i][0]; i++) {
|
|
|
|
if (strcmp(test, special_dirs[i][0]) == 0) {
|
|
|
|
test = special_dirs[i][1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "dlls/%s/tests/%s.c", test, subtest);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
static void* extract_rcdata (LPTSTR name, int type, DWORD* size)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
|
|
|
HRSRC rsrc;
|
|
|
|
HGLOBAL hdl;
|
2004-06-16 00:45:15 +02:00
|
|
|
LPVOID addr;
|
2004-01-15 02:48:05 +01:00
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
if (!(rsrc = FindResource (NULL, name, MAKEINTRESOURCE(type))) ||
|
2004-01-15 02:48:05 +01:00
|
|
|
!(*size = SizeofResource (0, rsrc)) ||
|
|
|
|
!(hdl = LoadResource (0, rsrc)) ||
|
|
|
|
!(addr = LockResource (hdl)))
|
2004-06-16 00:45:15 +02:00
|
|
|
return NULL;
|
2004-01-15 02:48:05 +01:00
|
|
|
return addr;
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2004-04-20 06:00:07 +02:00
|
|
|
/* Fills in the name and exename fields */
|
2005-06-04 12:01:25 +02:00
|
|
|
static void
|
2006-09-11 14:23:07 +02:00
|
|
|
extract_test (struct wine_test *test, const char *dir, LPTSTR res_name)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
|
|
|
BYTE* code;
|
|
|
|
DWORD size;
|
2004-02-19 05:12:42 +01:00
|
|
|
char *exepos;
|
2008-05-26 07:18:55 +02:00
|
|
|
HANDLE hfile;
|
|
|
|
DWORD written;
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
code = extract_rcdata (res_name, TESTRES, &size);
|
|
|
|
if (!code) report (R_FATAL, "Can't find test resource %s: %d",
|
|
|
|
res_name, GetLastError ());
|
|
|
|
test->name = xstrdup( res_name );
|
2008-05-26 07:18:55 +02:00
|
|
|
test->exename = strmake (NULL, "%s\\%s", dir, test->name);
|
2007-08-03 12:59:36 +02:00
|
|
|
exepos = strstr (test->name, testexe);
|
2004-02-19 05:12:42 +01:00
|
|
|
if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
|
|
|
|
*exepos = 0;
|
|
|
|
test->name = xrealloc (test->name, exepos - test->name + 1);
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_STEP, "Extracting: %s", test->name);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2008-05-26 07:18:55 +02:00
|
|
|
hfile = CreateFileA(test->exename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (hfile == INVALID_HANDLE_VALUE)
|
|
|
|
report (R_FATAL, "Failed to open file %s.", test->exename);
|
|
|
|
|
|
|
|
if (!WriteFile(hfile, code, size, &written, NULL))
|
|
|
|
report (R_FATAL, "Failed to write file %s.", test->exename);
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2004-04-20 06:00:07 +02:00
|
|
|
/* Run a command for MS milliseconds. If OUT != NULL, also redirect
|
|
|
|
stdout to there.
|
|
|
|
|
|
|
|
Return the exit status, -2 if can't create process or the return
|
|
|
|
value of WaitForSingleObject.
|
|
|
|
*/
|
2005-06-04 12:01:25 +02:00
|
|
|
static int
|
2008-07-10 17:45:22 +02:00
|
|
|
run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms)
|
2004-04-20 06:00:07 +02:00
|
|
|
{
|
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
DWORD wait, status;
|
|
|
|
|
|
|
|
GetStartupInfo (&si);
|
2008-07-10 17:45:22 +02:00
|
|
|
si.dwFlags = STARTF_USESTDHANDLES;
|
|
|
|
si.hStdInput = GetStdHandle( STD_INPUT_HANDLE );
|
|
|
|
si.hStdOutput = out_file ? out_file : GetStdHandle( STD_OUTPUT_HANDLE );
|
|
|
|
si.hStdError = GetStdHandle( STD_ERROR_HANDLE );
|
2004-04-20 06:00:07 +02:00
|
|
|
|
2008-05-06 23:14:56 +02:00
|
|
|
if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE,
|
2007-01-04 21:35:23 +01:00
|
|
|
NULL, tempdir, &si, &pi)) {
|
2004-04-20 06:00:07 +02:00
|
|
|
status = -2;
|
|
|
|
} else {
|
|
|
|
CloseHandle (pi.hThread);
|
|
|
|
wait = WaitForSingleObject (pi.hProcess, ms);
|
|
|
|
if (wait == WAIT_OBJECT_0) {
|
|
|
|
GetExitCodeProcess (pi.hProcess, &status);
|
|
|
|
} else {
|
|
|
|
switch (wait) {
|
|
|
|
case WAIT_FAILED:
|
|
|
|
report (R_ERROR, "Wait for '%s' failed: %d", cmd,
|
|
|
|
GetLastError ());
|
|
|
|
break;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
report (R_ERROR, "Process '%s' timed out.", cmd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
report (R_ERROR, "Wait returned %d", wait);
|
|
|
|
}
|
|
|
|
status = wait;
|
|
|
|
if (!TerminateProcess (pi.hProcess, 257))
|
|
|
|
report (R_ERROR, "TerminateProcess failed: %d",
|
|
|
|
GetLastError ());
|
|
|
|
wait = WaitForSingleObject (pi.hProcess, 5000);
|
|
|
|
switch (wait) {
|
|
|
|
case WAIT_FAILED:
|
|
|
|
report (R_ERROR,
|
|
|
|
"Wait for termination of '%s' failed: %d",
|
|
|
|
cmd, GetLastError ());
|
|
|
|
break;
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
break;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
report (R_ERROR, "Can't kill process '%s'", cmd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
report (R_ERROR, "Waiting for termination: %d",
|
|
|
|
wait);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseHandle (pi.hProcess);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void
|
2006-09-11 14:23:07 +02:00
|
|
|
get_subtests (const char *tempdir, struct wine_test *test, LPTSTR res_name)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
2008-07-10 17:45:22 +02:00
|
|
|
char *cmd;
|
|
|
|
HANDLE subfile;
|
|
|
|
DWORD total;
|
2004-04-20 06:00:07 +02:00
|
|
|
char buffer[8192], *index;
|
2004-05-04 06:13:05 +02:00
|
|
|
static const char header[] = "Valid test names:";
|
2004-01-15 02:48:05 +01:00
|
|
|
int allocated;
|
2008-07-10 17:45:22 +02:00
|
|
|
char tmpdir[MAX_PATH], subname[MAX_PATH];
|
|
|
|
SECURITY_ATTRIBUTES sa;
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-04-20 06:00:07 +02:00
|
|
|
test->subtest_count = 0;
|
|
|
|
|
2008-07-10 17:45:22 +02:00
|
|
|
if (!GetTempPathA( MAX_PATH, tmpdir ) ||
|
|
|
|
!GetTempFileNameA( tmpdir, "sub", 0, subname ))
|
|
|
|
report (R_FATAL, "Can't name subtests file.");
|
|
|
|
|
|
|
|
/* make handle inheritable */
|
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
sa.bInheritHandle = TRUE;
|
|
|
|
|
|
|
|
subfile = CreateFileA( subname, GENERIC_READ|GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
|
|
&sa, CREATE_ALWAYS, 0, NULL );
|
2008-07-16 18:33:12 +02:00
|
|
|
|
|
|
|
if ((subfile == INVALID_HANDLE_VALUE) &&
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)) {
|
|
|
|
/* FILE_SHARE_DELETE not supported on win9x */
|
|
|
|
subfile = CreateFileA( subname, GENERIC_READ|GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
|
|
&sa, CREATE_ALWAYS, 0, NULL );
|
|
|
|
}
|
2008-07-10 17:45:22 +02:00
|
|
|
if (subfile == INVALID_HANDLE_VALUE) {
|
|
|
|
report (R_ERROR, "Can't open subtests output of %s: %u",
|
|
|
|
test->name, GetLastError());
|
|
|
|
goto quit;
|
|
|
|
}
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
extract_test (test, tempdir, res_name);
|
2005-05-27 22:10:59 +02:00
|
|
|
cmd = strmake (NULL, "%s --list", test->exename);
|
2008-07-10 17:45:22 +02:00
|
|
|
run_ex (cmd, subfile, tempdir, 5000);
|
2005-05-27 22:10:59 +02:00
|
|
|
free (cmd);
|
2004-04-20 06:00:07 +02:00
|
|
|
|
2008-07-10 17:45:22 +02:00
|
|
|
SetFilePointer( subfile, 0, NULL, FILE_BEGIN );
|
|
|
|
ReadFile( subfile, buffer, sizeof(buffer), &total, NULL );
|
|
|
|
CloseHandle( subfile );
|
2004-04-20 06:00:07 +02:00
|
|
|
if (sizeof buffer == total) {
|
|
|
|
report (R_ERROR, "Subtest list of %s too big.",
|
|
|
|
test->name, sizeof buffer);
|
|
|
|
goto quit;
|
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
buffer[total] = 0;
|
2004-04-20 06:00:07 +02:00
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
index = strstr (buffer, header);
|
2004-04-20 06:00:07 +02:00
|
|
|
if (!index) {
|
|
|
|
report (R_ERROR, "Can't parse subtests output of %s",
|
2004-01-15 02:48:05 +01:00
|
|
|
test->name);
|
2004-04-20 06:00:07 +02:00
|
|
|
goto quit;
|
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
index += sizeof header;
|
|
|
|
|
|
|
|
allocated = 10;
|
|
|
|
test->subtests = xmalloc (allocated * sizeof(char*));
|
2004-09-07 21:33:52 +02:00
|
|
|
index = strtok (index, whitespace);
|
2004-01-15 02:48:05 +01:00
|
|
|
while (index) {
|
|
|
|
if (test->subtest_count == allocated) {
|
|
|
|
allocated *= 2;
|
|
|
|
test->subtests = xrealloc (test->subtests,
|
|
|
|
allocated * sizeof(char*));
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
test->subtests[test->subtest_count++] = strdup (index);
|
2004-09-07 21:33:52 +02:00
|
|
|
index = strtok (NULL, whitespace);
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
test->subtests = xrealloc (test->subtests,
|
|
|
|
test->subtest_count * sizeof(char*));
|
2004-04-20 06:00:07 +02:00
|
|
|
|
|
|
|
quit:
|
2008-07-10 17:45:22 +02:00
|
|
|
if (!DeleteFileA (subname))
|
|
|
|
report (R_WARNING, "Can't delete file '%s': %u", subname, GetLastError());
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void
|
2008-07-10 17:45:22 +02:00
|
|
|
run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const char *tempdir)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
|
|
|
int status;
|
2004-03-20 20:21:39 +01:00
|
|
|
const char* file = get_test_source_file(test->name, subtest);
|
2004-04-20 06:00:07 +02:00
|
|
|
char *cmd = strmake (NULL, "%s %s", test->exename, subtest);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2008-05-27 11:32:34 +02:00
|
|
|
xprintf ("%s:%s start %s -\n", test->name, subtest, file);
|
2008-07-10 17:45:22 +02:00
|
|
|
status = run_ex (cmd, out_file, tempdir, 120000);
|
2004-04-20 06:00:07 +02:00
|
|
|
free (cmd);
|
2004-01-15 02:48:05 +01:00
|
|
|
xprintf ("%s:%s done (%d)\n", test->name, subtest, status);
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static BOOL CALLBACK
|
2004-01-15 02:48:05 +01:00
|
|
|
EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType,
|
|
|
|
LPTSTR lpszName, LONG_PTR lParam)
|
2003-12-04 03:01:39 +01:00
|
|
|
{
|
2004-01-15 02:48:05 +01:00
|
|
|
(*(int*)lParam)++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
static BOOL CALLBACK
|
|
|
|
extract_test_proc (HMODULE hModule, LPCTSTR lpszType,
|
|
|
|
LPTSTR lpszName, LONG_PTR lParam)
|
|
|
|
{
|
|
|
|
const char *tempdir = (const char *)lParam;
|
2007-08-03 12:59:36 +02:00
|
|
|
char dllname[MAX_PATH];
|
|
|
|
HMODULE dll;
|
|
|
|
|
|
|
|
/* Check if the main dll is present on this system */
|
|
|
|
CharLowerA(lpszName);
|
|
|
|
strcpy(dllname, lpszName);
|
|
|
|
*strstr(dllname, testexe) = 0;
|
|
|
|
|
|
|
|
dll = LoadLibraryExA(dllname, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if (!dll) {
|
2007-08-23 08:55:05 +02:00
|
|
|
xprintf (" %s=dll is missing\n", dllname);
|
2007-08-03 12:59:36 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
FreeLibrary(dll);
|
|
|
|
|
2007-08-23 18:28:23 +02:00
|
|
|
xprintf (" %s=%s\n", dllname, get_file_version(dllname));
|
|
|
|
|
2006-09-11 14:23:07 +02:00
|
|
|
get_subtests( tempdir, &wine_tests[nr_of_files], lpszName );
|
|
|
|
nr_of_tests += wine_tests[nr_of_files].subtest_count;
|
|
|
|
nr_of_files++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static char *
|
2005-03-31 17:22:41 +02:00
|
|
|
run_tests (char *logname)
|
2004-01-15 02:48:05 +01:00
|
|
|
{
|
2006-09-11 14:23:07 +02:00
|
|
|
int i;
|
2004-06-16 00:45:15 +02:00
|
|
|
char *strres, *eol, *nextline;
|
|
|
|
DWORD strsize;
|
2008-07-10 17:45:22 +02:00
|
|
|
SECURITY_ATTRIBUTES sa;
|
|
|
|
char tmppath[MAX_PATH], tempdir[MAX_PATH+4];
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-07-06 23:03:22 +02:00
|
|
|
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2008-07-10 17:45:22 +02:00
|
|
|
if (!GetTempPathA( MAX_PATH, tmppath ))
|
|
|
|
report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
|
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
if (!logname) {
|
2008-07-10 17:45:22 +02:00
|
|
|
static char tmpname[MAX_PATH];
|
|
|
|
if (!GetTempFileNameA( tmppath, "res", 0, tmpname ))
|
|
|
|
report (R_FATAL, "Can't name logfile.");
|
|
|
|
logname = tmpname;
|
2004-02-19 05:12:42 +01:00
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_OUT, logname);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2008-07-10 17:45:22 +02:00
|
|
|
/* make handle inheritable */
|
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
sa.bInheritHandle = TRUE;
|
2004-06-16 00:45:15 +02:00
|
|
|
|
2008-07-10 17:45:22 +02:00
|
|
|
logfile = CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
|
|
&sa, CREATE_ALWAYS, 0, NULL );
|
2008-07-16 18:33:12 +02:00
|
|
|
|
|
|
|
if ((logfile == INVALID_HANDLE_VALUE) &&
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)) {
|
|
|
|
/* FILE_SHARE_DELETE not supported on win9x */
|
|
|
|
logfile = CreateFileA( logname, GENERIC_READ|GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
|
|
&sa, CREATE_ALWAYS, 0, NULL );
|
|
|
|
}
|
2008-07-10 17:45:22 +02:00
|
|
|
if (logfile == INVALID_HANDLE_VALUE)
|
|
|
|
report (R_FATAL, "Could not open logfile: %u", GetLastError());
|
|
|
|
|
|
|
|
if (!GetTempPathA( MAX_PATH, tmppath ))
|
2004-06-16 00:45:15 +02:00
|
|
|
report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
|
2008-07-10 17:45:22 +02:00
|
|
|
|
|
|
|
/* try stable path for ZoneAlarm */
|
|
|
|
strcpy( tempdir, tmppath );
|
|
|
|
strcat( tempdir, "wct" );
|
|
|
|
if (!CreateDirectoryA( tempdir, NULL ))
|
|
|
|
{
|
|
|
|
if (!GetTempFileNameA( tmppath, "wct", 0, tempdir ))
|
|
|
|
report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
|
|
|
|
DeleteFileA( tempdir );
|
|
|
|
if (!CreateDirectoryA( tempdir, NULL ))
|
|
|
|
report (R_FATAL, "Could not create directory: %s", tempdir);
|
2005-03-29 21:51:49 +02:00
|
|
|
}
|
|
|
|
report (R_DIR, tempdir);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2007-03-02 19:09:35 +01:00
|
|
|
xprintf ("Version 4\n");
|
2008-05-27 11:48:50 +02:00
|
|
|
xprintf ("Tests from build %s\n", build_id[0] ? build_id : "-" );
|
2006-09-11 14:23:07 +02:00
|
|
|
strres = extract_rcdata (MAKEINTRESOURCE(TESTS_URL), STRINGRES, &strsize);
|
2004-06-16 00:45:15 +02:00
|
|
|
xprintf ("Archive: ");
|
|
|
|
if (strres) xprintf ("%.*s", strsize, strres);
|
|
|
|
else xprintf ("-\n");
|
2005-03-31 17:22:41 +02:00
|
|
|
xprintf ("Tag: %s\n", tag);
|
2004-04-23 04:52:21 +02:00
|
|
|
xprintf ("Build info:\n");
|
2006-09-11 14:23:07 +02:00
|
|
|
strres = extract_rcdata (MAKEINTRESOURCE(BUILD_INFO), STRINGRES, &strsize);
|
2004-06-16 00:45:15 +02:00
|
|
|
while (strres) {
|
|
|
|
eol = memchr (strres, '\n', strsize);
|
|
|
|
if (!eol) {
|
|
|
|
nextline = NULL;
|
|
|
|
eol = strres + strsize;
|
|
|
|
} else {
|
|
|
|
strsize -= eol - strres + 1;
|
|
|
|
nextline = strsize?eol+1:NULL;
|
|
|
|
if (eol > strres && *(eol-1) == '\r') eol--;
|
|
|
|
}
|
|
|
|
xprintf (" %.*s\n", eol-strres, strres);
|
|
|
|
strres = nextline;
|
|
|
|
}
|
2003-12-04 03:01:39 +01:00
|
|
|
xprintf ("Operating system version:\n");
|
|
|
|
print_version ();
|
2007-08-23 08:55:05 +02:00
|
|
|
xprintf ("Dll info:\n" );
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_STATUS, "Counting tests");
|
2004-06-16 00:45:15 +02:00
|
|
|
if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES),
|
2004-01-15 02:48:05 +01:00
|
|
|
EnumTestFileProc, (LPARAM)&nr_of_files))
|
|
|
|
report (R_FATAL, "Can't enumerate test files: %d",
|
|
|
|
GetLastError ());
|
|
|
|
wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
|
|
|
|
|
|
|
|
report (R_STATUS, "Extracting tests");
|
2004-02-21 05:01:56 +01:00
|
|
|
report (R_PROGRESS, 0, nr_of_files);
|
2006-09-11 14:23:07 +02:00
|
|
|
nr_of_files = 0;
|
|
|
|
nr_of_tests = 0;
|
|
|
|
if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES),
|
|
|
|
extract_test_proc, (LPARAM)tempdir))
|
|
|
|
report (R_FATAL, "Can't enumerate test files: %d",
|
|
|
|
GetLastError ());
|
|
|
|
|
2007-08-23 08:55:05 +02:00
|
|
|
xprintf ("Test output:\n" );
|
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_DELTA, 0, "Extracting: Done");
|
|
|
|
|
|
|
|
report (R_STATUS, "Running tests");
|
2004-02-21 05:01:56 +01:00
|
|
|
report (R_PROGRESS, 1, nr_of_tests);
|
2004-01-15 02:48:05 +01:00
|
|
|
for (i = 0; i < nr_of_files; i++) {
|
|
|
|
struct wine_test *test = wine_tests + i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < test->subtest_count; j++) {
|
2004-03-19 02:54:10 +01:00
|
|
|
report (R_STEP, "Running: %s:%s", test->name,
|
2004-01-15 02:48:05 +01:00
|
|
|
test->subtests[j]);
|
2008-07-10 17:45:22 +02:00
|
|
|
run_test (test, test->subtests[j], logfile, tempdir);
|
2004-01-15 02:48:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
report (R_DELTA, 0, "Running: Done");
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
report (R_STATUS, "Cleaning up");
|
2008-07-10 17:45:22 +02:00
|
|
|
CloseHandle( logfile );
|
|
|
|
logfile = 0;
|
2003-12-04 03:01:39 +01:00
|
|
|
remove_dir (tempdir);
|
2004-01-15 02:48:05 +01:00
|
|
|
free (wine_tests);
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-02-19 05:12:42 +01:00
|
|
|
return logname;
|
|
|
|
}
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2005-06-04 12:01:25 +02:00
|
|
|
static void
|
|
|
|
usage (void)
|
2004-02-19 05:12:42 +01:00
|
|
|
{
|
2007-01-09 23:42:26 +01:00
|
|
|
fprintf (stderr,
|
|
|
|
"Usage: winetest [OPTION]...\n\n"
|
|
|
|
" -c console mode, no GUI\n"
|
|
|
|
" -e preserve the environment\n"
|
|
|
|
" -h print this message and exit\n"
|
2007-10-28 02:48:59 +02:00
|
|
|
" -p shutdown when the tests are done\n"
|
2007-01-09 23:42:26 +01:00
|
|
|
" -q quiet mode, no output at all\n"
|
|
|
|
" -o FILE put report into FILE, do not submit\n"
|
|
|
|
" -s FILE submit FILE, do not run tests\n"
|
|
|
|
" -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n");
|
2004-01-15 02:48:05 +01:00
|
|
|
}
|
2003-12-04 03:01:39 +01:00
|
|
|
|
2004-01-15 02:48:05 +01:00
|
|
|
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
|
|
|
|
LPSTR cmdLine, int cmdShow)
|
|
|
|
{
|
2004-02-20 20:56:29 +01:00
|
|
|
char *logname = NULL;
|
2005-03-31 17:22:41 +02:00
|
|
|
const char *cp, *submit = NULL;
|
2004-07-23 01:42:03 +02:00
|
|
|
int reset_env = 1;
|
2007-10-28 02:48:59 +02:00
|
|
|
int poweroff = 0;
|
2005-03-31 17:22:41 +02:00
|
|
|
int interactive = 1;
|
2004-02-19 05:12:42 +01:00
|
|
|
|
2008-05-27 11:48:50 +02:00
|
|
|
if (!LoadStringA( 0, IDS_BUILD_ID, build_id, sizeof(build_id) )) build_id[0] = 0;
|
|
|
|
|
2004-09-07 21:33:52 +02:00
|
|
|
cmdLine = strtok (cmdLine, whitespace);
|
2004-02-19 05:12:42 +01:00
|
|
|
while (cmdLine) {
|
2004-03-25 00:40:06 +01:00
|
|
|
if (cmdLine[0] != '-' || cmdLine[2]) {
|
|
|
|
report (R_ERROR, "Not a single letter option: %s", cmdLine);
|
|
|
|
usage ();
|
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
switch (cmdLine[1]) {
|
|
|
|
case 'c':
|
|
|
|
report (R_TEXTMODE);
|
2005-03-31 17:22:41 +02:00
|
|
|
interactive = 0;
|
2004-03-25 00:40:06 +01:00
|
|
|
break;
|
2004-07-23 01:42:03 +02:00
|
|
|
case 'e':
|
|
|
|
reset_env = 0;
|
|
|
|
break;
|
2004-03-25 00:40:06 +01:00
|
|
|
case 'h':
|
2007-10-28 02:48:59 +02:00
|
|
|
case '?':
|
2004-03-25 00:40:06 +01:00
|
|
|
usage ();
|
|
|
|
exit (0);
|
2007-10-28 02:48:59 +02:00
|
|
|
case 'p':
|
|
|
|
poweroff = 1;
|
|
|
|
break;
|
2004-03-25 00:40:06 +01:00
|
|
|
case 'q':
|
|
|
|
report (R_QUIET);
|
2005-03-31 17:22:41 +02:00
|
|
|
interactive = 0;
|
2004-03-25 00:40:06 +01:00
|
|
|
break;
|
|
|
|
case 's':
|
2004-09-07 21:33:52 +02:00
|
|
|
submit = strtok (NULL, whitespace);
|
2004-07-23 01:42:03 +02:00
|
|
|
if (tag)
|
|
|
|
report (R_WARNING, "ignoring tag for submission");
|
2004-03-25 00:40:06 +01:00
|
|
|
send_file (submit);
|
|
|
|
break;
|
|
|
|
case 'o':
|
2004-09-07 21:33:52 +02:00
|
|
|
logname = strtok (NULL, whitespace);
|
2004-03-25 00:40:06 +01:00
|
|
|
break;
|
|
|
|
case 't':
|
2004-09-07 21:33:52 +02:00
|
|
|
tag = strtok (NULL, whitespace);
|
2005-04-11 18:10:01 +02:00
|
|
|
if (strlen (tag) > MAXTAGLEN)
|
|
|
|
report (R_FATAL, "tag is too long (maximum %d characters)",
|
|
|
|
MAXTAGLEN);
|
2005-04-18 11:54:24 +02:00
|
|
|
cp = findbadtagchar (tag);
|
2004-03-25 00:40:06 +01:00
|
|
|
if (cp) {
|
|
|
|
report (R_ERROR, "invalid char in tag: %c", *cp);
|
2004-02-19 05:12:42 +01:00
|
|
|
usage ();
|
|
|
|
exit (2);
|
|
|
|
}
|
2004-03-25 00:40:06 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
report (R_ERROR, "invalid option: -%c", cmdLine[1]);
|
|
|
|
usage ();
|
|
|
|
exit (2);
|
|
|
|
}
|
2004-09-07 21:33:52 +02:00
|
|
|
cmdLine = strtok (NULL, whitespace);
|
2004-02-19 05:12:42 +01:00
|
|
|
}
|
2004-07-23 01:42:03 +02:00
|
|
|
if (!submit) {
|
2005-03-31 17:22:41 +02:00
|
|
|
report (R_STATUS, "Starting up");
|
|
|
|
|
|
|
|
if (!running_on_visible_desktop ())
|
|
|
|
report (R_FATAL, "Tests must be run on a visible desktop");
|
2005-03-25 18:11:52 +01:00
|
|
|
|
2008-08-01 10:48:58 +02:00
|
|
|
if (reset_env)
|
|
|
|
{
|
|
|
|
SetEnvironmentVariableA( "WINETEST_PLATFORM", running_under_wine () ? "wine" : "windows" );
|
|
|
|
SetEnvironmentVariableA( "WINETEST_DEBUG", "1" );
|
|
|
|
SetEnvironmentVariableA( "WINETEST_INTERACTIVE", "0" );
|
|
|
|
SetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", "0" );
|
|
|
|
}
|
2004-07-23 01:42:03 +02:00
|
|
|
|
2008-09-04 10:06:46 +02:00
|
|
|
while (!tag) {
|
2005-03-31 17:22:41 +02:00
|
|
|
if (!interactive)
|
|
|
|
report (R_FATAL, "Please specify a tag (-t option) if "
|
|
|
|
"running noninteractive!");
|
|
|
|
if (guiAskTag () == IDABORT) exit (1);
|
|
|
|
}
|
|
|
|
report (R_TAG);
|
|
|
|
|
2008-05-27 11:48:50 +02:00
|
|
|
if (!build_id[0])
|
|
|
|
report( R_WARNING, "You won't be able to submit results without a valid build id.\n"
|
|
|
|
"To submit results, winetest needs to be built from a git checkout." );
|
|
|
|
|
2004-10-04 21:32:20 +02:00
|
|
|
if (!logname) {
|
2005-03-31 17:22:41 +02:00
|
|
|
logname = run_tests (NULL);
|
2008-05-27 11:48:50 +02:00
|
|
|
if (build_id[0] &&
|
|
|
|
report (R_ASK, MB_YESNO, "Do you want to submit the test results?") == IDYES)
|
2008-07-10 17:45:22 +02:00
|
|
|
if (!send_file (logname) && !DeleteFileA(logname))
|
|
|
|
report (R_WARNING, "Can't remove logfile: %u", GetLastError());
|
2005-03-31 17:22:41 +02:00
|
|
|
} else run_tests (logname);
|
2004-02-19 05:12:42 +01:00
|
|
|
report (R_STATUS, "Finished");
|
|
|
|
}
|
2007-10-28 02:48:59 +02:00
|
|
|
if (poweroff)
|
|
|
|
{
|
|
|
|
HANDLE hToken;
|
|
|
|
TOKEN_PRIVILEGES npr;
|
|
|
|
|
|
|
|
/* enable the shutdown privilege for the current process */
|
|
|
|
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
|
|
|
|
{
|
|
|
|
LookupPrivilegeValueA(0, SE_SHUTDOWN_NAME, &npr.Privileges[0].Luid);
|
|
|
|
npr.PrivilegeCount = 1;
|
|
|
|
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
|
|
|
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
|
|
|
|
CloseHandle(hToken);
|
|
|
|
}
|
|
|
|
ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);
|
|
|
|
}
|
2004-01-15 02:48:05 +01:00
|
|
|
exit (0);
|
2003-12-04 03:01:39 +01:00
|
|
|
}
|