ReactOS  0.4.13-dev-563-g0561610
main.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <windows.h>
#include "winetest.h"
#include "resource.h"
#include <reason.h>
Include dependency graph for main.c:

Go to the source code of this file.

Classes

struct  wine_test
 
struct  rev_info
 

Functions

static charget_file_version (char *file_name)
 
static int running_under_wine (void)
 
static int running_on_visible_desktop (void)
 
static void print_version (void)
 
static int is_dot_dir (const char *x)
 
static void remove_dir (const char *dir)
 
static const charget_test_source_file (const char *test, const char *subtest)
 
static const charget_file_rev (const char *file)
 
static void extract_rev_infos (void)
 
static voidextract_rcdata (LPTSTR name, int type, DWORD *size)
 
static void extract_test (struct wine_test *test, const char *dir, LPTSTR res_name)
 
static int run_ex (char *cmd, const char *out, const char *tempdir, DWORD ms)
 
static void get_subtests (const char *tempdir, struct wine_test *test, LPTSTR res_name)
 
static void run_test (struct wine_test *test, const char *subtest, const char *tempdir)
 
static BOOL CALLBACK EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
 
static BOOL CALLBACK extract_test_proc (HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
 
static charrun_tests (char *logname)
 
static void usage (void)
 
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int cmdShow)
 

Variables

chartag = NULL
 
static struct wine_testwine_tests
 
static int nr_of_files
 
static int nr_of_tests
 
static struct rev_inforev_infos = NULL
 
static const char whitespace [] = " \t\r\n"
 
static const char testexe [] = "_test.exe"
 

Function Documentation

◆ EnumTestFileProc()

static BOOL CALLBACK EnumTestFileProc ( HMODULE  hModule,
LPCTSTR  lpszType,
LPTSTR  lpszName,
LONG_PTR  lParam 
)
static

Definition at line 462 of file main.c.

464 {
465  (*(int*)lParam)++;
466  return TRUE;
467 }
#define TRUE
Definition: types.h:120
LPARAM lParam
Definition: combotst.c:139

Referenced by run_tests().

◆ extract_rcdata()

static void* extract_rcdata ( LPTSTR  name,
int  type,
DWORD size 
)
static

Definition at line 260 of file main.c.

261 {
262  HRSRC rsrc;
263  HGLOBAL hdl;
264  LPVOID addr;
265 
266  if (!(rsrc = FindResource (NULL, name, MAKEINTRESOURCE(type))) ||
267  !(*size = SizeofResource (0, rsrc)) ||
268  !(hdl = LoadResource (0, rsrc)) ||
269  !(addr = LockResource (hdl)))
270  return NULL;
271  return addr;
272 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define FindResource
Definition: winbase.h:3607
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLvoid * addr
Definition: glext.h:9621
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
Definition: name.c:36

Referenced by extract_test(), and run_tests().

◆ extract_rev_infos()

static void extract_rev_infos ( void  )
static

Definition at line 234 of file main.c.

235 {
236  char revinfo[256], *p;
237  int size = 0, i;
238  unsigned int len;
240 
241  for (i = 0; TRUE; i++) {
242  if (i >= size) {
243  size += 100;
244  rev_infos = xrealloc (rev_infos, size * sizeof (*rev_infos));
245  }
246  memset(rev_infos + i, 0, sizeof(rev_infos[i]));
247 
248  len = LoadStringA (module, REV_INFO+i, revinfo, sizeof(revinfo));
249  if (len == 0) break; /* end of revision info */
250  if (len >= sizeof(revinfo) - 1)
251  report (R_FATAL, "Revision info too long.");
252  if(!(p = strrchr(revinfo, ':')))
253  report (R_FATAL, "Revision info malformed (i=%d)", i);
254  *p = 0;
255  rev_infos[i].file = strdup(revinfo);
256  rev_infos[i].rev = strdup(p + 1);
257  }
258 }
#define TRUE
Definition: types.h:120
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
smooth NULL
Definition: ftsmooth.c:416
REVINFO revinfo
Definition: log2lines.c:37
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
#define GetModuleHandle
Definition: winbase.h:3641
#define REV_INFO
Definition: resource.h:59
GLfloat GLfloat p
Definition: glext.h:8902
#define memset(x, y, z)
Definition: compat.h:39
static struct rev_info * rev_infos
Definition: main.c:62

Referenced by WinMain().

◆ extract_test()

static void extract_test ( struct wine_test test,
const char dir,
LPTSTR  res_name 
)
static

Definition at line 276 of file main.c.

277 {
278  BYTE* code;
279  DWORD size;
280  FILE* fout;
281  char *exepos;
282 
283  code = extract_rcdata (res_name, TESTRES, &size);
284  if (!code) report (R_FATAL, "Can't find test resource %s: %d",
285  res_name, GetLastError ());
286  test->name = xstrdup( res_name );
287  test->exename = strmake (NULL, "%s/%s", dir, test->name);
288  exepos = strstr (test->name, testexe);
289  if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
290  *exepos = 0;
291  test->name = xrealloc (test->name, exepos - test->name + 1);
292  report (R_STEP, "Extracting: %s", test->name);
293 
294  if (!(fout = fopen (test->exename, "wb")) ||
295  (fwrite (code, size, 1, fout) != 1) ||
296  fclose (fout)) report (R_FATAL, "Failed to write file %s.",
297  test->exename);
298 }
char * name
Definition: wpp.c:36
static void * extract_rcdata(LPTSTR name, int type, DWORD *size)
Definition: main.c:260
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
smooth NULL
Definition: ftsmooth.c:416
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
unsigned int dir
Definition: maze.c:112
char * strmake(size_t *lenp,...)
Definition: util.c:82
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define TESTRES
Definition: resource.h:49
static const char testexe[]
Definition: main.c:64
int code
Definition: main.c:75
char * xstrdup(const char *s)
Definition: uimain.c:768

Referenced by get_subtests().

◆ extract_test_proc()

static BOOL CALLBACK extract_test_proc ( HMODULE  hModule,
LPCTSTR  lpszType,
LPTSTR  lpszName,
LONG_PTR  lParam 
)
static

Definition at line 470 of file main.c.

472 {
473  const char *tempdir = (const char *)lParam;
474  char dllname[MAX_PATH];
475  HMODULE dll;
476 
477  /* Check if the main dll is present on this system */
478  CharLowerA(lpszName);
479  strcpy(dllname, lpszName);
480  *strstr(dllname, testexe) = 0;
481 
483  if (!dll) {
484  xprintf (" %s=dll is missing\n", dllname);
485  return TRUE;
486  }
487  FreeLibrary(dll);
488 
489  xprintf (" %s=%s\n", dllname, get_file_version(dllname));
490 
491  get_subtests( tempdir, &wine_tests[nr_of_files], lpszName );
492  nr_of_tests += wine_tests[nr_of_files].subtest_count;
493  nr_of_files++;
494  return TRUE;
495 }
static int nr_of_files
Definition: main.c:61
#define TRUE
Definition: types.h:120
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
static struct wine_test * wine_tests
Definition: main.c:60
LPSTR WINAPI CharLowerA(_Inout_ LPSTR)
static HMODULE dll
Definition: str.c:188
static int nr_of_tests
Definition: main.c:61
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
#define MAX_PATH
Definition: compat.h:26
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
static const char testexe[]
Definition: main.c:64
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static char * get_file_version(char *file_name)
Definition: main.c:66
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:157
LPARAM lParam
Definition: combotst.c:139
void xprintf(const char *fmt,...)
Definition: shimdbg.c:16
static void get_subtests(const char *tempdir, struct wine_test *test, LPTSTR res_name)
Definition: main.c:383

Referenced by run_tests().

◆ get_file_rev()

static const char* get_file_rev ( const char file)
static

Definition at line 223 of file main.c.

224 {
225  const struct rev_info* rev;
226 
227  for(rev = rev_infos; rev->file; rev++) {
228  if (strcmp(rev->file, file) == 0) return rev->rev;
229  }
230 
231  return "-";
232 }
Definition: main.c:53
int rev
Definition: sort.c:17
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static struct rev_info * rev_infos
Definition: main.c:62
Definition: fci.c:126

Referenced by run_test().

◆ get_file_version()

static char* get_file_version ( char file_name)
static

Definition at line 66 of file main.c.

67 {
68  static char version[32];
69  DWORD size;
70  DWORD handle;
71 
73  if (size) {
74  char * data = xmalloc(size);
75  if (data) {
77  static char backslash[] = "\\";
78  VS_FIXEDFILEINFO *pFixedVersionInfo;
79  UINT len;
80  if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) {
81  sprintf(version, "%d.%d.%d.%d",
82  pFixedVersionInfo->dwFileVersionMS >> 16,
83  pFixedVersionInfo->dwFileVersionMS & 0xffff,
84  pFixedVersionInfo->dwFileVersionLS >> 16,
85  pFixedVersionInfo->dwFileVersionLS & 0xffff);
86  } else
87  sprintf(version, "version not available");
88  } else
89  sprintf(version, "unknown");
90  free(data);
91  } else
92  sprintf(version, "failed");
93  } else
94  sprintf(version, "version not available");
95 
96  return version;
97 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define free
Definition: debug_ros.c:5
BOOL WINAPI VerQueryValueA(LPCVOID pBlock, LPCSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:998
#define sprintf(buf, format,...)
Definition: sprintf.c:55
void * xmalloc(int size)
Definition: uimain.c:747
static const WCHAR version[]
Definition: asmname.c:64
GLsizeiptr size
Definition: glext.h:5919
DWORD WINAPI GetFileVersionInfoSizeA(LPCSTR filename, LPDWORD handle)
Definition: version.c:624
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BOOL WINAPI GetFileVersionInfoA(LPCSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:858
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
static LPCWSTR file_name
Definition: protocol.c:146

Referenced by extract_test_proc().

◆ get_subtests()

static void get_subtests ( const char tempdir,
struct wine_test test,
LPTSTR  res_name 
)
static

Definition at line 383 of file main.c.

384 {
385  char *subname, *cmd;
386  FILE *subfile;
387  size_t total;
388  char buffer[8192], *index;
389  static const char header[] = "Valid test names:";
390  int allocated;
391 
392  test->subtest_count = 0;
393 
394  subname = tempnam (0, "sub");
395  if (!subname) report (R_FATAL, "Can't name subtests file.");
396 
397  extract_test (test, tempdir, res_name);
398  cmd = strmake (NULL, "%s --list", test->exename);
399  run_ex (cmd, subname, tempdir, 5000);
400  free (cmd);
401 
402  subfile = fopen (subname, "r");
403  if (!subfile) {
404  report (R_ERROR, "Can't open subtests output of %s: %d",
405  test->name, errno);
406  goto quit;
407  }
408  total = fread (buffer, 1, sizeof buffer, subfile);
409  fclose (subfile);
410  if (sizeof buffer == total) {
411  report (R_ERROR, "Subtest list of %s too big.",
412  test->name, sizeof buffer);
413  goto quit;
414  }
415  buffer[total] = 0;
416 
417  index = strstr (buffer, header);
418  if (!index) {
419  report (R_ERROR, "Can't parse subtests output of %s",
420  test->name);
421  goto quit;
422  }
423  index += sizeof header;
424 
425  allocated = 10;
426  test->subtests = xmalloc (allocated * sizeof(char*));
428  while (index) {
429  if (test->subtest_count == allocated) {
430  allocated *= 2;
431  test->subtests = xrealloc (test->subtests,
432  allocated * sizeof(char*));
433  }
434  test->subtests[test->subtest_count++] = strdup (index);
436  }
437  test->subtests = xrealloc (test->subtests,
438  test->subtest_count * sizeof(char*));
439 
440  quit:
441  if (remove (subname))
442  report (R_WARNING, "Can't delete file '%s': %d",
443  subname, errno);
444  free (subname);
445 }
char * name
Definition: wpp.c:36
Definition: ftp_var.h:139
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define free
Definition: debug_ros.c:5
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
GLuint buffer
Definition: glext.h:5915
char * cmd
Definition: vfdcmd.c:85
#define test
Definition: rosglue.h:37
int errno
_CRTIMP char *__cdecl tempnam(_In_opt_z_ const char *_Directory, _In_opt_z_ const char *_FilePrefix)
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
void * xmalloc(int size)
Definition: uimain.c:747
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
smooth NULL
Definition: ftsmooth.c:416
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLuint index
Definition: glext.h:6031
char * strmake(size_t *lenp,...)
Definition: util.c:82
static void extract_test(struct wine_test *test, const char *dir, LPTSTR res_name)
Definition: main.c:276
#define index(s, c)
Definition: various.h:29
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
static int run_ex(char *cmd, const char *out, const char *tempdir, DWORD ms)
Definition: main.c:307
static const char whitespace[]
Definition: main.c:63
int remove
Definition: msacm.c:1353
struct CFHEADER header
Definition: fdi.c:109

Referenced by extract_test_proc().

◆ get_test_source_file()

static const char* get_test_source_file ( const char test,
const char subtest 
)
static

Definition at line 204 of file main.c.

205 {
206  static const char* special_dirs[][2] = {
207  { 0, 0 }
208  };
209  static char buffer[MAX_PATH];
210  int i;
211 
212  for (i = 0; special_dirs[i][0]; i++) {
213  if (strcmp(test, special_dirs[i][0]) == 0) {
214  test = special_dirs[i][1];
215  break;
216  }
217  }
218 
219  snprintf(buffer, sizeof(buffer), "dlls/%s/tests/%s.c", test, subtest);
220  return buffer;
221 }
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
#define test
Definition: rosglue.h:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MAX_PATH
Definition: compat.h:26
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by run_test().

◆ is_dot_dir()

static int is_dot_dir ( const char x)
inlinestatic

Definition at line 168 of file main.c.

169 {
170  return ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))));
171 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by remove_dir().

◆ print_version()

static void print_version ( void  )
static

Definition at line 131 of file main.c.

132 {
133  OSVERSIONINFOEX ver;
134  BOOL ext;
135  int is_win2k3_r2;
136  const char *(*wine_get_build_id)(void);
137 
138  ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
139  if (!(ext = GetVersionEx ((OSVERSIONINFO *) &ver)))
140  {
141  ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
142  if (!GetVersionEx ((OSVERSIONINFO *) &ver))
143  report (R_FATAL, "Can't get OS version.");
144  }
145 
146  xprintf (" bRunningUnderWine=%d\n", running_under_wine ());
147  xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ());
148  xprintf (" dwMajorVersion=%ld\n dwMinorVersion=%ld\n"
149  " dwBuildNumber=%ld\n PlatformId=%ld\n szCSDVersion=%s\n",
151  ver.dwPlatformId, ver.szCSDVersion);
152 
153  wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
154  if (wine_get_build_id) xprintf( " WineBuild=%s\n", wine_get_build_id() );
155 
156  is_win2k3_r2 = GetSystemMetrics(SM_SERVERR2);
157  if(is_win2k3_r2)
158  xprintf(" R2 build number=%d\n", is_win2k3_r2);
159 
160  if (!ext) return;
161 
162  xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
163  " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
164  ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask,
165  ver.wProductType, ver.wReserved);
166 }
ULONG dwMajorVersion
Definition: rtltypes.h:234
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static int running_under_wine(void)
Definition: main.c:99
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:289
unsigned int BOOL
Definition: ntddk_ex.h:94
char ext[3]
Definition: mkdosfs.c:358
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
static int running_on_visible_desktop(void)
Definition: main.c:107
ULONG dwBuildNumber
Definition: rtltypes.h:236
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:251
int WINAPI GetSystemMetrics(_In_ int)
ULONG dwMinorVersion
Definition: rtltypes.h:235
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
ULONG dwPlatformId
Definition: rtltypes.h:237
#define GetVersionEx
Definition: winbase.h:3666
OSVERSIONINFOEXA OSVERSIONINFOEX
Definition: rtltypes.h:286
#define GetProcAddress(x, y)
Definition: compat.h:410
CHAR szCSDVersion[128]
Definition: rtltypes.h:238
void xprintf(const char *fmt,...)
Definition: shimdbg.c:16

Referenced by run_tests().

◆ remove_dir()

static void remove_dir ( const char dir)
static

Definition at line 173 of file main.c.

174 {
175  HANDLE hFind;
176  WIN32_FIND_DATA wfd;
177  char path[MAX_PATH];
178  size_t dirlen = strlen (dir);
179 
180  /* Make sure the directory exists before going further */
181  memcpy (path, dir, dirlen);
182  strcpy (path + dirlen++, "\\*");
183  hFind = FindFirstFile (path, &wfd);
184  if (hFind == INVALID_HANDLE_VALUE) return;
185 
186  do {
187  char *lp = wfd.cFileName;
188 
189  if (!lp[0]) lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */
190  if (is_dot_dir (lp)) continue;
191  strcpy (path + dirlen, lp);
192  if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
193  remove_dir(path);
194  else if (!DeleteFile (path))
195  report (R_WARNING, "Can't delete file %s: error %d",
196  path, GetLastError ());
197  } while (FindNextFile (hFind, &wfd));
198  FindClose (hFind);
199  if (!RemoveDirectory (dir))
200  report (R_WARNING, "Can't remove directory %s: error %d",
201  dir, GetLastError ());
202 }
static int is_dot_dir(const char *x)
Definition: main.c:168
static void remove_dir(const char *dir)
Definition: main.c:173
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define RemoveDirectory
Definition: winbase.h:3709
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define DeleteFile
Definition: winbase.h:3578
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
unsigned int dir
Definition: maze.c:112
#define FindFirstFile
Definition: winbase.h:3596
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define FindNextFile
Definition: winbase.h:3602
#define MAX_PATH
Definition: compat.h:26
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: services.c:325
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by run_tests().

◆ run_ex()

static int run_ex ( char cmd,
const char out,
const char tempdir,
DWORD  ms 
)
static

Definition at line 307 of file main.c.

308 {
309  STARTUPINFO si;
311  int fd, oldstdout = -1;
312  DWORD wait, status;
313 
314  GetStartupInfo (&si);
315  si.dwFlags = 0;
316 
317  if (out) {
318  fd = open (out, O_WRONLY | O_CREAT, 0666);
319  if (-1 == fd)
320  report (R_FATAL, "Can't open '%s': %d", out, errno);
321  oldstdout = dup (1);
322  if (-1 == oldstdout)
323  report (R_FATAL, "Can't save stdout: %d", errno);
324  if (-1 == dup2 (fd, 1))
325  report (R_FATAL, "Can't redirect stdout: %d", errno);
326  close (fd);
327  }
328 
330  NULL, tempdir, &si, &pi)) {
331  status = -2;
332  } else {
333  CloseHandle (pi.hThread);
334  wait = WaitForSingleObject (pi.hProcess, ms);
335  if (wait == WAIT_OBJECT_0) {
336  GetExitCodeProcess (pi.hProcess, &status);
337  } else {
338  switch (wait) {
339  case WAIT_FAILED:
340  report (R_ERROR, "Wait for '%s' failed: %d", cmd,
341  GetLastError ());
342  break;
343  case WAIT_TIMEOUT:
344  report (R_ERROR, "Process '%s' timed out.", cmd);
345  break;
346  default:
347  report (R_ERROR, "Wait returned %d", wait);
348  }
349  status = wait;
350  if (!TerminateProcess (pi.hProcess, 257))
351  report (R_ERROR, "TerminateProcess failed: %d",
352  GetLastError ());
353  wait = WaitForSingleObject (pi.hProcess, 5000);
354  switch (wait) {
355  case WAIT_FAILED:
356  report (R_ERROR,
357  "Wait for termination of '%s' failed: %d",
358  cmd, GetLastError ());
359  break;
360  case WAIT_OBJECT_0:
361  break;
362  case WAIT_TIMEOUT:
363  report (R_ERROR, "Can't kill process '%s'", cmd);
364  break;
365  default:
366  report (R_ERROR, "Waiting for termination: %d",
367  wait);
368  }
369  }
370  CloseHandle (pi.hProcess);
371  }
372 
373  if (out) {
374  close (1);
375  if (-1 == dup2 (oldstdout, 1))
376  report (R_FATAL, "Can't recover stdout: %d", errno);
377  close (oldstdout);
378  }
379  return status;
380 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define open
Definition: acwin.h:71
Definition: ftp_var.h:139
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1198
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static int fd
Definition: io.c:51
DWORD dwFlags
Definition: winbase.h:807
#define CREATE_DEFAULT_ERROR_MODE
Definition: winbase.h:194
int errno
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define O_WRONLY
Definition: acwin.h:85
smooth NULL
Definition: ftsmooth.c:416
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
#define WAIT_OBJECT_0
Definition: winbase.h:387
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4772
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_FAILED
Definition: winbase.h:394
#define WAIT_TIMEOUT
Definition: dderror.h:14
static DWORD pi
Definition: protocol.c:150
#define close
Definition: acwin.h:74
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
_Check_return_ _CRTIMP int __cdecl dup(_In_ int _FileHandle)
#define GetStartupInfo
Definition: winbase.h:3655
static SERVICE_STATUS status
Definition: service.c:31
#define O_CREAT
Definition: acwin.h:84
Definition: ps.c:97

Referenced by get_subtests(), and run_test().

◆ run_test()

static void run_test ( struct wine_test test,
const char subtest,
const char tempdir 
)
static

Definition at line 448 of file main.c.

449 {
450  int status;
451  const char* file = get_test_source_file(test->name, subtest);
452  const char* rev = get_file_rev(file);
453  char *cmd = strmake (NULL, "%s %s", test->exename, subtest);
454 
455  xprintf ("%s:%s start %s %s\n", test->name, subtest, file, rev);
456  status = run_ex (cmd, NULL, tempdir, 120000);
457  free (cmd);
458  xprintf ("%s:%s done (%d)\n", test->name, subtest, status);
459 }
char * name
Definition: wpp.c:36
Definition: ftp_var.h:139
#define free
Definition: debug_ros.c:5
#define test
Definition: rosglue.h:37
static const char * get_file_rev(const char *file)
Definition: main.c:223
smooth NULL
Definition: ftsmooth.c:416
char * strmake(size_t *lenp,...)
Definition: util.c:82
int rev
Definition: sort.c:17
static const char * get_test_source_file(const char *test, const char *subtest)
Definition: main.c:204
static int run_ex(char *cmd, const char *out, const char *tempdir, DWORD ms)
Definition: main.c:307
static SERVICE_STATUS status
Definition: service.c:31
void xprintf(const char *fmt,...)
Definition: shimdbg.c:16
Definition: fci.c:126
Definition: ps.c:97

Referenced by DllMain(), and run_tests().

◆ run_tests()

static char* run_tests ( char logname)
static

Definition at line 498 of file main.c.

499 {
500  int i;
501  char *tempdir, *shorttempdir;
502  int logfile;
503  char *strres, *eol, *nextline;
504  DWORD strsize;
505  char build[64];
506 
508 
509  if (!logname) {
510  logname = tempnam (0, "res");
511  if (!logname) report (R_FATAL, "Can't name logfile.");
512  }
513  report (R_OUT, logname);
514 
515  logfile = open (logname, O_WRONLY | O_CREAT | O_EXCL | O_APPEND,
516  0666);
517  if (-1 == logfile) {
518  if (EEXIST == errno)
519  report (R_FATAL, "File %s already exists.", logname);
520  else report (R_FATAL, "Could not open logfile: %d", errno);
521  }
522  if (-1 == dup2 (logfile, 1))
523  report (R_FATAL, "Can't redirect stdout: %d", errno);
524  close (logfile);
525 
526  tempdir = tempnam (0, "wct");
527  if (!tempdir)
528  report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
529  shorttempdir = strdup (tempdir);
530  if (shorttempdir) { /* try stable path for ZoneAlarm */
531  strstr (shorttempdir, "wct")[3] = 0;
532  if (CreateDirectoryA (shorttempdir, NULL)) {
533  free (tempdir);
534  tempdir = shorttempdir;
535  } else free (shorttempdir);
536  }
537  if (tempdir != shorttempdir && !CreateDirectoryA (tempdir, NULL))
538  report (R_FATAL, "Could not create directory: %s", tempdir);
539  report (R_DIR, tempdir);
540 
541  xprintf ("Version 4\n");
542  strres = extract_rcdata (MAKEINTRESOURCE(WINE_BUILD), STRINGRES, &strsize);
543  xprintf ("Tests from build ");
544  if (LoadStringA( 0, IDS_BUILD_ID, build, sizeof(build) )) xprintf( "%s\n", build );
545  else if (strres) xprintf ("%.*s", strsize, strres);
546  else xprintf ("-\n");
547  strres = extract_rcdata (MAKEINTRESOURCE(TESTS_URL), STRINGRES, &strsize);
548  xprintf ("Archive: ");
549  if (strres) xprintf ("%.*s", strsize, strres);
550  else xprintf ("-\n");
551  xprintf ("Tag: %s\n", tag);
552  xprintf ("Build info:\n");
553  strres = extract_rcdata (MAKEINTRESOURCE(BUILD_INFO), STRINGRES, &strsize);
554  while (strres) {
555  eol = memchr (strres, '\n', strsize);
556  if (!eol) {
557  nextline = NULL;
558  eol = strres + strsize;
559  } else {
560  strsize -= eol - strres + 1;
561  nextline = strsize?eol+1:NULL;
562  if (eol > strres && *(eol-1) == '\r') eol--;
563  }
564  xprintf (" %.*s\n", eol-strres, strres);
565  strres = nextline;
566  }
567  xprintf ("Operating system version:\n");
568  print_version ();
569  xprintf ("Dll info:\n" );
570 
571  report (R_STATUS, "Counting tests");
574  report (R_FATAL, "Can't enumerate test files: %d",
575  GetLastError ());
576  wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
577 
578  report (R_STATUS, "Extracting tests");
580  nr_of_files = 0;
581  nr_of_tests = 0;
583  extract_test_proc, (LPARAM)tempdir))
584  report (R_FATAL, "Can't enumerate test files: %d",
585  GetLastError ());
586 
587  xprintf ("Test output:\n" );
588 
589  report (R_DELTA, 0, "Extracting: Done");
590 
591  report (R_STATUS, "Running tests");
593  for (i = 0; i < nr_of_files; i++) {
594  struct wine_test *test = wine_tests + i;
595  int j;
596 
597  for (j = 0; j < test->subtest_count; j++) {
598  report (R_STEP, "Running: %s:%s", test->name,
599  test->subtests[j]);
600  run_test (test, test->subtests[j], tempdir);
601  }
602  }
603  report (R_DELTA, 0, "Running: Done");
604 
605  report (R_STATUS, "Cleaning up");
606  close (1);
607  remove_dir (tempdir);
608  free (tempdir);
609  free (wine_tests);
610 
611  return logname;
612 }
Definition: main.c:44
char * name
Definition: wpp.c:36
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
#define MAKEINTRESOURCE
Definition: winuser.h:591
static int nr_of_files
Definition: main.c:61
#define EnumResourceNames
Definition: winbase.h:3586
static void remove_dir(const char *dir)
Definition: main.c:173
#define STRINGRES
Definition: resource.h:50
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
#define memchr(s, c, n)
Definition: mkisofs.h:875
static void * extract_rcdata(LPTSTR name, int type, DWORD *size)
Definition: main.c:260
#define open
Definition: acwin.h:71
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define free
Definition: debug_ros.c:5
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
Definition: ecma_167.h:138
#define test
Definition: rosglue.h:37
int errno
_CRTIMP char *__cdecl tempnam(_In_opt_z_ const char *_Directory, _In_opt_z_ const char *_FilePrefix)
#define EEXIST
Definition: acclib.h:88
static struct wine_test * wine_tests
Definition: main.c:60
static BOOL CALLBACK EnumTestFileProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
Definition: main.c:462
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void * xmalloc(int size)
Definition: uimain.c:747
#define O_WRONLY
Definition: acwin.h:85
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
static int nr_of_tests
Definition: main.c:61
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
#define O_EXCL
Definition: fcntl.h:40
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TESTS_URL
Definition: resource.h:56
#define WINE_BUILD
Definition: resource.h:54
static void print_version(void)
Definition: main.c:131
Definition: winetest.h:52
#define IDS_BUILD_ID
Definition: resource.h:45
#define close
Definition: acwin.h:74
#define SEM_NOGPFAULTERRORBOX
Definition: rtltypes.h:70
#define BUILD_INFO
Definition: resource.h:55
Definition: winetest.h:53
#define TESTRES
Definition: resource.h:49
static void run_test(struct wine_test *test, const char *subtest, const char *tempdir)
Definition: main.c:448
static BOOL CALLBACK extract_test_proc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
Definition: main.c:470
#define O_CREAT
Definition: acwin.h:84
void xprintf(const char *fmt,...)
Definition: shimdbg.c:16
#define O_APPEND
Definition: fcntl.h:37

Referenced by WinMain().

◆ running_on_visible_desktop()

static int running_on_visible_desktop ( void  )
static

Definition at line 107 of file main.c.

108 {
109  HWND desktop;
110  HMODULE huser32 = GetModuleHandle("user32.dll");
111  FARPROC pGetProcessWindowStation = GetProcAddress(huser32, "GetProcessWindowStation");
112  FARPROC pGetUserObjectInformationA = GetProcAddress(huser32, "GetUserObjectInformationA");
113 
114  desktop = GetDesktopWindow();
115  if (!GetWindowLongPtrW(desktop, GWLP_WNDPROC)) /* Win9x */
116  return IsWindowVisible(desktop);
117 
118  if (pGetProcessWindowStation && pGetUserObjectInformationA)
119  {
120  DWORD len;
121  HWINSTA wstation;
122  USEROBJECTFLAGS uoflags;
123 
124  wstation = (HWINSTA)pGetProcessWindowStation();
125  assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len));
126  return (uoflags.dwFlags & WSF_VISIBLE) != 0;
127  }
128  return IsWindowVisible(desktop);
129 }
#define assert(x)
Definition: debug.h:53
#define GetWindowLongPtrW
Definition: winuser.h:4698
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
static HMODULE huser32
Definition: profile.c:34
#define WSF_VISIBLE
Definition: winuser.h:2406
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GetModuleHandle
Definition: winbase.h:3641
#define UOI_FLAGS
Definition: winuser.h:1073
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define GetProcAddress(x, y)
Definition: compat.h:410
int(* FARPROC)()
Definition: compat.h:28

Referenced by print_version(), and WinMain().

◆ running_under_wine()

static int running_under_wine ( void  )
static

Definition at line 99 of file main.c.

100 {
101  HMODULE module = GetModuleHandleA("ntdll.dll");
102 
103  if (!module) return 0;
104  return (GetProcAddress(module, "wine_server_call") != NULL);
105 }
smooth NULL
Definition: ftsmooth.c:416
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by print_version(), and WinMain().

◆ usage()

static void usage ( void  )
static

Definition at line 615 of file main.c.

616 {
617  fprintf (stderr,
618 "Usage: winetest [OPTION]...\n\n"
619 " -c console mode, no GUI\n"
620 " -e preserve the environment\n"
621 " -h print this message and exit\n"
622 " -p shutdown when the tests are done\n"
623 " -q quiet mode, no output at all\n"
624 " -o FILE put report into FILE, do not submit\n"
625 " -s FILE submit FILE, do not run tests\n"
626 " -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n");
627 }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
FILE * stderr

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInst,
HINSTANCE  hPrevInst,
LPSTR  cmdLine,
int  cmdShow 
)

Definition at line 629 of file main.c.

631 {
632  char *logname = NULL;
633  const char *cp, *submit = NULL;
634  int reset_env = 1;
635  int poweroff = 0;
636  int interactive = 1;
637 
638  /* initialize the revision information first */
640 
641  cmdLine = strtok (cmdLine, whitespace);
642  while (cmdLine) {
643  if (cmdLine[0] != '-' || cmdLine[2]) {
644  report (R_ERROR, "Not a single letter option: %s", cmdLine);
645  usage ();
646  exit (2);
647  }
648  switch (cmdLine[1]) {
649  case 'c':
650  report (R_TEXTMODE);
651  interactive = 0;
652  break;
653  case 'e':
654  reset_env = 0;
655  break;
656  case 'h':
657  case '?':
658  usage ();
659  exit (0);
660  case 'p':
661  poweroff = 1;
662  break;
663  case 'q':
664  report (R_QUIET);
665  interactive = 0;
666  break;
667  case 's':
668  submit = strtok (NULL, whitespace);
669  if (tag)
670  report (R_WARNING, "ignoring tag for submission");
671  send_file (submit);
672  break;
673  case 'o':
674  logname = strtok (NULL, whitespace);
675  break;
676  case 't':
677  tag = strtok (NULL, whitespace);
678  if (strlen (tag) > MAXTAGLEN)
679  report (R_FATAL, "tag is too long (maximum %d characters)",
680  MAXTAGLEN);
681  cp = findbadtagchar (tag);
682  if (cp) {
683  report (R_ERROR, "invalid char in tag: %c", *cp);
684  usage ();
685  exit (2);
686  }
687  break;
688  default:
689  report (R_ERROR, "invalid option: -%c", cmdLine[1]);
690  usage ();
691  exit (2);
692  }
693  cmdLine = strtok (NULL, whitespace);
694  }
695  if (!submit) {
696  static CHAR platform_windows[] = "WINETEST_PLATFORM=windows",
697  platform_wine[] = "WINETEST_PLATFORM=wine",
698  debug_yes[] = "WINETEST_DEBUG=1",
699  interactive_no[] = "WINETEST_INTERACTIVE=0",
700  report_success_no[] = "WINETEST_REPORT_SUCCESS=0";
701  CHAR *platform;
702 
703  report (R_STATUS, "Starting up");
704 
706  report (R_FATAL, "Tests must be run on a visible desktop");
707 
708  platform = running_under_wine () ? platform_wine : platform_windows;
709 
710  if (reset_env && (putenv (platform) ||
711  putenv (debug_yes) ||
712  putenv (interactive_no) ||
713  putenv (report_success_no)))
714  report (R_FATAL, "Could not reset environment: %d", errno);
715 
716  if (!tag) {
717  if (!interactive)
718  report (R_FATAL, "Please specify a tag (-t option) if "
719  "running noninteractive!");
720  if (guiAskTag () == IDABORT) exit (1);
721  }
722  report (R_TAG);
723 
724  if (!logname) {
725  logname = run_tests (NULL);
726  if (report (R_ASK, MB_YESNO, "Do you want to submit the "
727  "test results?") == IDYES)
728  if (!send_file (logname) && remove (logname))
729  report (R_WARNING, "Can't remove logfile: %d.", errno);
730  free (logname);
731  } else run_tests (logname);
732  report (R_STATUS, "Finished");
733  }
734  if (poweroff)
735  {
736  HANDLE hToken;
737  TOKEN_PRIVILEGES npr;
738 
739  /* enable the shutdown privilege for the current process */
741  {
743  npr.PrivilegeCount = 1;
745  AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
746  CloseHandle(hToken);
747  }
748  ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);
749  }
750  exit (0);
751 }
const char * findbadtagchar(const char *tag)
Definition: util.c:124
_Check_return_ _CRTIMP int __cdecl putenv(_In_z_ const char *_EnvString)
#define CloseHandle
Definition: compat.h:398
int send_file(const char *name)
Definition: send.c:105
#define IDABORT
Definition: winuser.h:826
static int running_under_wine(void)
Definition: main.c:99
#define IDYES
Definition: winuser.h:829
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
int usage(char *argv0)
Definition: main.c:44
$ULONG PrivilegeCount
Definition: setypes.h:969
Definition: ecma_167.h:138
int errno
Definition: winetest.h:51
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define MB_YESNO
Definition: winuser.h:811
#define EWX_SHUTDOWN
Definition: winuser.h:634
#define MAXTAGLEN
Definition: winetest.h:62
smooth NULL
Definition: ftsmooth.c:416
static char * run_tests(char *logname)
Definition: main.c:498
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
static int running_on_visible_desktop(void)
Definition: main.c:107
#define EWX_POWEROFF
Definition: winuser.h:632
platform
Definition: msipriv.h:356
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
int interactive
Definition: main.c:63
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
Definition: winetest.h:57
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
int guiAskTag(void)
Definition: gui.c:353
POINT cp
Definition: magnifier.c:59
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:383
static void extract_rev_infos(void)
Definition: main.c:234
static const char whitespace[]
Definition: main.c:63
void exit(int exitcode)
Definition: _exit.c:33
int remove
Definition: msacm.c:1353
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
BOOL WINAPI LookupPrivilegeValueA(LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid)
Definition: misc.c:732

Variable Documentation

◆ nr_of_files

int nr_of_files
static

Definition at line 61 of file main.c.

Referenced by extract_test_proc(), and run_tests().

◆ nr_of_tests

int nr_of_tests
static

Definition at line 61 of file main.c.

Referenced by extract_test_proc(), and run_tests().

◆ rev_infos

struct rev_info* rev_infos = NULL
static

Definition at line 62 of file main.c.

Referenced by extract_rev_infos(), and get_file_rev().

◆ tag

Definition at line 59 of file main.c.

Referenced by _test_elem_tag(), _TIFFCreateAnonField(), _TIFFVGetField(), _TIFFVSetField(), add_expand_text(), ber_parse_header(), check_tiff_format(), check_type1_format(), count_tags(), CRYPT_AsnEncodeAltNameEntry(), CRYPT_AsnEncodeStringCoerce(), CRYPT_AsnEncodeUnicodeStringCoerce(), d3dx9_base_effect_init(), Decompose_Curve(), do_one_pass(), dump_tiff(), dxbc_add_section(), dxbc_parse(), findbadtagchar(), FT_Outline_Decompose(), FT_Stroker_ParseOutline(), get_font_size(), get_GSUB_Indic2(), get_reparse_tag(), get_reparse_tag_fcb(), XMLStorage::Buffer::get_tag(), getDataType(), HTMLElement_Create(), HTMLElementCollection_tags(), is_elem_tag(), jsstr_init(), ldap_parse_page_controlW(), licence_process(), nfs_encode_compound(), parse_data_type(), parseabbrevs(), PredictorVGetField(), PredictorVSetField(), PropertyStorage_ReadProperty(), read_pfb_tag(), SdbFindNextTag(), SdbpGetString(), SdbpSetDWORDAttr(), SdbpSetQWORDAttr(), SdbpSetStringAttr(), SdbpSetStringAttrFromAnsiString(), sec_parse_crypt_info(), sec_process_mcs_data(), SeiBuildShimRefArray(), set_reparse_point2(), sfnt_open_font(), T1_Get_Private_Dict(), T1_New_Parser(), tag_to_vt(), test_color_formats(), test_elem_from_point(), test_GetColorProfileElementTag(), test_IsColorProfileTagPresent(), test_primary_secondary(), test_primary_secondary8(), test_Sdb(), test_secondary(), test_secondary8(), test_tiff_color_formats(), test_write_ex(), TIFFFindField(), TIFFWriteDirectoryTagData(), tt_face_load_hmtx(), UDFReadTagged(), UDFSetUpTag(), UniataAhciBeginTransaction(), UniataAhciEndTransaction(), UniataAhciSendCommand(), usp10_script_add_language(), usp10_script_add_language_list(), usp10_script_cache_add_script(), usp10_script_cache_add_script_list(), and ValidateShim().

◆ testexe

const char testexe[] = "_test.exe"
static

Definition at line 64 of file main.c.

Referenced by extract_test(), and extract_test_proc().

◆ whitespace

const char whitespace[] = " \t\r\n"
static

Definition at line 63 of file main.c.

Referenced by get_subtests(), and WinMain().

◆ wine_tests

struct wine_test* wine_tests
static

Definition at line 60 of file main.c.

Referenced by extract_test_proc(), and run_tests().