mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-15 06:41:38 +00:00
- command line handling (GUI will follow)
- strip .exe[.so] from test names - version 2 output
This commit is contained in:
parent
87bef514db
commit
efc67253fd
|
@ -51,6 +51,21 @@ renderString (va_list ap)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
int
|
||||
MBdefault (int uType)
|
||||
{
|
||||
static const int matrix[][4] = {{IDOK, 0, 0, 0},
|
||||
{IDOK, IDCANCEL, 0, 0},
|
||||
{IDABORT, IDRETRY, IDIGNORE, 0},
|
||||
{IDYES, IDNO, IDCANCEL, 0},
|
||||
{IDYES, IDNO, 0, 0},
|
||||
{IDRETRY, IDCANCEL, 0, 0}};
|
||||
int type = uType & MB_TYPEMASK;
|
||||
int def = (uType & MB_DEFMASK) / MB_DEFBUTTON2;
|
||||
|
||||
return matrix[type][def];
|
||||
}
|
||||
|
||||
/* report (R_STATUS, fmt, ...) */
|
||||
int
|
||||
textStatus (va_list ap)
|
||||
|
@ -204,39 +219,12 @@ guiOut (va_list ap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* report (R_FATAL, fmt, ...) */
|
||||
int
|
||||
textFatal (va_list ap)
|
||||
{
|
||||
char *str = vstrmake (NULL, ap);
|
||||
|
||||
fputs ("Fatal error: ", stderr);
|
||||
fputs (str, stderr);
|
||||
fputc ('\n', stderr);
|
||||
free (str);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
guiFatal (va_list ap)
|
||||
{
|
||||
char *str = vstrmake (NULL, ap);
|
||||
|
||||
MessageBox (dialog, str, "Fatal Error", MB_ICONERROR | MB_OK);
|
||||
free (str);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* report (R_WARNING, fmt, ...) */
|
||||
int
|
||||
textWarning (va_list ap)
|
||||
{
|
||||
char *str = vstrmake (NULL, ap);
|
||||
|
||||
fputs ("Warning: ", stderr);
|
||||
fputs (str, stderr);
|
||||
fputc ('\n', stderr);
|
||||
free (str);
|
||||
textStatus (ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -250,17 +238,52 @@ guiWarning (va_list ap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* report (R_ERROR, fmt, ...) */
|
||||
int
|
||||
textError (va_list ap)
|
||||
{
|
||||
fputs ("Error: ", stderr);
|
||||
textStatus (ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
guiError (va_list ap)
|
||||
{
|
||||
char *str = vstrmake (NULL, ap);
|
||||
|
||||
MessageBox (dialog, str, "Error", MB_ICONERROR | MB_OK);
|
||||
free (str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* report (R_FATAL, fmt, ...) */
|
||||
int
|
||||
textFatal (va_list ap)
|
||||
{
|
||||
textError (ap);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
guiFatal (va_list ap)
|
||||
{
|
||||
guiError (ap);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* report (R_ASK, type, fmt, ...) */
|
||||
int
|
||||
textAsk (va_list ap)
|
||||
{
|
||||
int uType = va_arg (ap, int);
|
||||
int ret = MBdefault (uType);
|
||||
char *str = vstrmake (NULL, ap);
|
||||
|
||||
fprintf (stderr, "Question of type %d: %s\n!FIXME, stub\n",
|
||||
uType, str);
|
||||
fprintf (stderr, "Question of type %d: %s\n"
|
||||
"Returning default: %d\n", uType, str, ret);
|
||||
free (str);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -275,6 +298,25 @@ guiAsk (va_list ap)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Quiet functions */
|
||||
int
|
||||
qNoOp (va_list ap)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
qFatal (va_list ap)
|
||||
{
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
qAsk (va_list ap)
|
||||
{
|
||||
return MBdefault (va_arg (ap, int));
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -362,8 +404,21 @@ report (enum report_type t, ...)
|
|||
static r_fun_t * const GUI_funcs[] =
|
||||
{guiStatus, guiProgress, guiStep, guiDelta,
|
||||
guiDir, guiOut, guiFatal, guiWarning, guiAsk};
|
||||
static r_fun_t * const quiet_funcs[] =
|
||||
{qNoOp, qNoOp, qNoOp, qNoOp,
|
||||
qNoOp, qNoOp, qFatal, qNoOp, qAsk};
|
||||
static r_fun_t * const * funcs = NULL;
|
||||
|
||||
switch (t) {
|
||||
case R_TEXTMODE:
|
||||
funcs = text_funcs;
|
||||
return 0;
|
||||
case R_QUIET:
|
||||
funcs = quiet_funcs;
|
||||
return 0;
|
||||
default:
|
||||
}
|
||||
|
||||
if (!funcs) {
|
||||
HANDLE DlgThread;
|
||||
DWORD DlgThreadID;
|
||||
|
|
|
@ -138,6 +138,7 @@ extract_test (struct wine_test *test, const char *dir, int id)
|
|||
DWORD size;
|
||||
FILE* fout;
|
||||
int strlen, bufflen = 128;
|
||||
char *exepos;
|
||||
|
||||
code = extract_rcdata (id, &size);
|
||||
test->name = xmalloc (bufflen);
|
||||
|
@ -147,15 +148,18 @@ extract_test (struct wine_test *test, const char *dir, int id)
|
|||
test->name = xrealloc (test->name, bufflen);
|
||||
}
|
||||
if (!strlen) report (R_FATAL, "Can't read name of test %d.", id);
|
||||
test->name = xrealloc (test->name, strlen+1);
|
||||
test->exename = strmake (NULL, "%s/%s", dir, test->name);
|
||||
exepos = strstr (test->name, ".exe");
|
||||
if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
|
||||
*exepos = 0;
|
||||
test->name = xrealloc (test->name, exepos - test->name + 1);
|
||||
report (R_STEP, "Extracting: %s", test->name);
|
||||
test->is_elf = !memcmp (code+1, "ELF", 3);
|
||||
test->exename = strmake (NULL, "%s/%s", dir, test->name);
|
||||
|
||||
if (!(fout = fopen (test->exename, "wb")) ||
|
||||
(fwrite (code, size, 1, fout) != 1) ||
|
||||
fclose (fout)) report (R_FATAL, "Failed to write file %s.",
|
||||
test->name);
|
||||
test->exename);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -254,11 +258,11 @@ EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
run_tests ()
|
||||
static const char *
|
||||
run_tests (const char *logname, const char *tag)
|
||||
{
|
||||
int nr_of_files = 0, nr_of_tests = 0, i;
|
||||
char *tempdir, *logname;
|
||||
char *tempdir;
|
||||
FILE *logfile;
|
||||
char build_tag[128];
|
||||
|
||||
|
@ -275,8 +279,10 @@ run_tests ()
|
|||
if (!CreateDirectory (tempdir, NULL))
|
||||
report (R_FATAL, "Could not create directory: %s", tempdir);
|
||||
|
||||
if (!logname) {
|
||||
logname = tempnam (0, "res");
|
||||
if (!logname) report (R_FATAL, "Can't name logfile.");
|
||||
}
|
||||
report (R_OUT, logname);
|
||||
|
||||
logfile = fopen (logname, "a");
|
||||
|
@ -285,13 +291,14 @@ run_tests ()
|
|||
report (R_FATAL, "Can't redirect stdout.");
|
||||
fclose (logfile);
|
||||
|
||||
xprintf ("Version 1\n");
|
||||
xprintf ("Version 2\n");
|
||||
i = LoadStringA (GetModuleHandle (NULL), 0,
|
||||
build_tag, sizeof build_tag);
|
||||
if (i == 0) report (R_FATAL, "Build descriptor not found.");
|
||||
if (i >= sizeof build_tag)
|
||||
report (R_FATAL, "Build descriptor too long.");
|
||||
xprintf ("Tests from build %s\n", build_tag);
|
||||
xprintf ("Tag: %s", tag?tag:"");
|
||||
xprintf ("Operating system version:\n");
|
||||
print_version ();
|
||||
xprintf ("Test output:\n" );
|
||||
|
@ -331,21 +338,86 @@ run_tests ()
|
|||
free (tempdir);
|
||||
free (wine_tests);
|
||||
|
||||
if (report (R_ASK, MB_YESNO,
|
||||
"Do you want to submit the test results?") == IDYES)
|
||||
if (send_file (logname))
|
||||
report (R_FATAL, "Can't submit logfile '%s'", logname);
|
||||
return logname;
|
||||
}
|
||||
|
||||
if (remove (logname))
|
||||
report (R_WARNING, "Can't remove logfile: %d.", errno);
|
||||
free (logname);
|
||||
void
|
||||
usage ()
|
||||
{
|
||||
fprintf (stderr, "\
|
||||
Usage: winetest [OPTION]...\n\n\
|
||||
-c console mode, no GUI\n\
|
||||
-h print this message and exit\n\
|
||||
-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");
|
||||
}
|
||||
|
||||
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
|
||||
LPSTR cmdLine, int cmdShow)
|
||||
{
|
||||
const char *logname = NULL;
|
||||
char *tag = NULL, *cp;
|
||||
char *submit = NULL;
|
||||
|
||||
cmdLine = strtok (cmdLine, " ");
|
||||
while (cmdLine) {
|
||||
if (*cmdLine == '-')
|
||||
if (cmdLine[2]) {
|
||||
report (R_ERROR, "Not a single letter option: %s",
|
||||
cmdLine);
|
||||
usage ();
|
||||
exit (2);
|
||||
}
|
||||
cmdLine++;
|
||||
switch (*cmdLine) {
|
||||
case 'c':
|
||||
report (R_TEXTMODE);
|
||||
break;
|
||||
case 'h':
|
||||
usage ();
|
||||
exit (0);
|
||||
case 'q':
|
||||
report (R_QUIET);
|
||||
break;
|
||||
case 's':
|
||||
submit = strtok (NULL, " ");
|
||||
if (tag)
|
||||
report (R_WARNING, "ignoring tag for submit");
|
||||
if (send_file (submit))
|
||||
report (R_ERROR, "can't submit file %s", submit);
|
||||
break;
|
||||
case 'o':
|
||||
logname = strtok (NULL, " ");
|
||||
run_tests (logname, tag);
|
||||
break;
|
||||
case 't':
|
||||
tag = strtok (NULL, " ");
|
||||
cp = badtagchar (tag);
|
||||
if (cp) {
|
||||
report (R_ERROR, "invalid char in tag: %c", *cp);
|
||||
usage ();
|
||||
exit (2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
report (R_ERROR, "invalid option: -%c", *cmdLine);
|
||||
usage ();
|
||||
exit (2);
|
||||
}
|
||||
cmdLine = strtok (NULL, " ");
|
||||
}
|
||||
if (!logname && !submit) {
|
||||
report (R_STATUS, "Starting up");
|
||||
run_tests ();
|
||||
logname = run_tests (NULL, tag);
|
||||
if (report (R_ASK, MB_YESNO,
|
||||
"Do you want to submit the test results?") == IDYES)
|
||||
if (send_file (logname))
|
||||
report (R_FATAL, "Can't submit logfile '%s'", logname);
|
||||
if (remove (logname))
|
||||
report (R_WARNING, "Can't remove logfile: %d.", errno);
|
||||
report (R_STATUS, "Finished");
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$WINE_BUILD" ]; then
|
||||
WINE_BUILD="`date`"
|
||||
WINE_BUILD="`date +%Y%m%d.%H%M-auto`"
|
||||
echo "warning: using automatically generated BUILD tag: $WINE_BUILD" 1>&2
|
||||
fi
|
||||
|
||||
|
|
|
@ -84,3 +84,16 @@ char *strmake (size_t *lenp, ...)
|
|||
va_end (ap);
|
||||
return p;
|
||||
}
|
||||
|
||||
char *
|
||||
badtagchar (char *tag)
|
||||
{
|
||||
while (*tag)
|
||||
if (('a'<=*tag && *tag<='z') ||
|
||||
('A'<=*tag && *tag<='Z') ||
|
||||
('0'<=*tag && *tag<='9') ||
|
||||
*tag=='-' || *tag=='.')
|
||||
tag++;
|
||||
else return tag;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ void *xrealloc (void *op, size_t len);
|
|||
void xprintf (const char *fmt, ...);
|
||||
char *vstrmake (size_t *lenp, va_list ap);
|
||||
char *strmake (size_t *lenp, ...);
|
||||
char *badtagchar (char *tag);
|
||||
|
||||
int send_file (const char *name);
|
||||
|
||||
|
@ -47,9 +48,12 @@ enum report_type {
|
|||
R_DELTA,
|
||||
R_DIR,
|
||||
R_OUT,
|
||||
R_FATAL,
|
||||
R_WARNING,
|
||||
R_ASK
|
||||
R_ERROR,
|
||||
R_FATAL,
|
||||
R_ASK,
|
||||
R_TEXTMODE,
|
||||
R_QUIET
|
||||
};
|
||||
|
||||
int report (enum report_type t, ...);
|
||||
|
|
Loading…
Reference in a new issue