winetest progress bars

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ChangeLog: Add graphical feedback.

New files:
? programs/winetest/binary.rc
? programs/winetest/gui.c
? programs/winetest/gui.h
? programs/winetest/gui.rc
? programs/winetest/guires.h

Feri.

Index: programs/winetest/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/winetest/Makefile.in,v
retrieving revision 1.18
diff -u -r1.18 Makefile.in
--- programs/winetest/Makefile.in	4 Dec 2003 02:01:39 -0000	1.18
+++ programs/winetest/Makefile.in	13 Jan 2004 03:57:01 -0000
@@ -4,14 +4,17 @@
 VPATH     = @srcdir@
 MODULE    = winetest.exe
 APPMODE   = gui
-IMPORTS   = user32 wsock32
+IMPORTS   = comctl32 user32 wsock32
 
 C_SRCS = \
 	main.c \
 	send.c \
-	util.c
+	util.c \
+	gui.c
 
 RC_SRCS = winetest.rc
+RC_BINSRC = binary.rc
+RC_BINARIES = wine.ico 
 
 TESTS = \
 	advapi32 \
Index: programs/winetest/main.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/main.c,v
retrieving revision 1.1
diff -u -r1.1 main.c
--- programs/winetest/main.c	4 Dec 2003 02:01:39 -0000	1.1
+++ programs/winetest/main.c	13 Jan 2004 03:57:02 -0000
@@ -36,6 +36,9 @@
 #include <windows.h>
 
 #include "winetest.h"
+#include "gui.h"
+
+#define TESTRESOURCE "USERDATA"
 
 struct wine_test
 {
@@ -47,7 +50,7 @@
     char *exename;
 };
 
-static struct wine_test wine_tests[32];
+static struct wine_test *wine_tests;
 
 static const char *wineloader;
 
@@ -61,7 +64,7 @@
     {
 	ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 	if (!GetVersionEx ((OSVERSIONINFO *) &ver))
-	    fatal("Can't get OS version.");
+	    report (R_FATAL, "Can't get OS version.");
     }
 
     xprintf ("    dwMajorVersion=%ld\n    dwMinorVersion=%ld\n"
@@ -104,155 +107,158 @@
         if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
             remove_dir(path);
         else if (!DeleteFile (path))
-            warning (strmake (NULL, "Can't delete file %s: error %d", path, GetLastError ()));
+            report (R_WARNING, "Can't delete file %s: error %d",
+                    path, GetLastError ());
     } while (FindNextFile (hFind, &wfd));
     FindClose (hFind);
     if (!RemoveDirectory (dir))
-        warning (strmake (NULL, "Can't remove directory %s: error %d", dir, GetLastError ()));
+        report (R_WARNING, "Can't remove directory %s: error %d",
+                dir, GetLastError ());
 }
 
 void* extract_rcdata (int id, DWORD* size)
 {
     HRSRC rsrc;
     HGLOBAL hdl;
-
-    rsrc = FindResource (0, (LPTSTR)(id + 1), "USERDATA");
-    if (!rsrc) return 0;
-    *size = SizeofResource (0, rsrc);
-    if (!*size) return 0;
-    hdl = LoadResource (0, rsrc);
-    if (!hdl) return 0;
-    return LockResource (hdl);
+    LPVOID addr = NULL;
+    
+    if (!(rsrc = FindResource (0, (LPTSTR)id, TESTRESOURCE)) ||
+        !(*size = SizeofResource (0, rsrc)) ||
+        !(hdl = LoadResource (0, rsrc)) ||
+        !(addr = LockResource (hdl)))
+        report (R_FATAL, "Can't extract test file of id %d: %d",
+                id, GetLastError ());
+    return addr;
 }
 
-int extract_test (const char *dir, int id)
+/* Fills out the name, is_elf and exename fields */
+void
+extract_test (struct wine_test *test, const char *dir, int id)
 {
     BYTE* code;
     DWORD size;
     FILE* fout;
-    char buffer[128];
-    int len;
-    struct wine_test *test;
-
-    if (id >= sizeof(wine_tests)/sizeof(wine_tests[0])-1) fatal("Too many tests\n");
+    int strlen, bufflen = 128;
 
     code = extract_rcdata (id, &size);
-    if (!code) return 0;
-
-    test = &wine_tests[id];
-    len = LoadStringA(0, id + 1, buffer, sizeof(buffer) );
-    test->name = xmalloc( len + 1 );
-    memcpy( test->name, buffer, len + 1 );
-    test->is_elf = (code[1] == 'E' && code[2] == 'L' && code[3] == 'F');
-    test->exename = strmake(NULL, "%s/%s", dir, test->name);
+    test->name = xmalloc (bufflen);
+    while ((strlen = LoadStringA (NULL, id, test->name, bufflen))
+           == bufflen - 1) {
+        bufflen *= 2;
+        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);
+    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")) ||
+    if (!(fout = fopen (test->exename, "wb")) ||
         (fwrite (code, size, 1, fout) != 1) ||
-        fclose (fout)) fatal (strmake (NULL, "Failed to write file %s.", test->name));
-    return 1;
+        fclose (fout)) report (R_FATAL, "Failed to write file %s.",
+                               test->name);
 }
 
-int get_subtests (struct wine_test tests[])
+void
+get_subtests (const char *tempdir, struct wine_test *test, int id)
 {
     char *subname;
     FILE *subfile;
     size_t subsize, bytes_read, total;
-    char buffer[8000], *index;
+    char *buffer, *index;
     const char header[] = "Valid test names:", seps[] = " \r\n";
     int oldstdout;
     const char *argv[] = {"wine", NULL, NULL};
-    struct wine_test* test;
-    int allocated, all_subtests = 0;
+    int allocated;
 
     subname = tempnam (0, "sub");
-    if (!subname) fatal ("Can't name subtests file.");
+    if (!subname) report (R_FATAL, "Can't name subtests file.");
     oldstdout = dup (1);
-    if (-1 == oldstdout) fatal ("Can't preserve stdout.");
+    if (-1 == oldstdout) report (R_FATAL, "Can't preserve stdout.");
     subfile = fopen (subname, "w+b");
-    if (!subfile) fatal ("Can't open subtests file.");
+    if (!subfile) report (R_FATAL, "Can't open subtests file.");
     if (-1 == dup2 (fileno (subfile), 1))
-        fatal ("Can't redirect output to subtests.");
+        report (R_FATAL, "Can't redirect output to subtests.");
     fclose (subfile);
 
-    for (test = tests; test->name; test++) {
-        lseek (1, 0, SEEK_SET);
-        argv[1] = test->exename;
-        if (test->is_elf)
-            spawnvp (_P_WAIT, wineloader, argv);
-        else
-            spawnvp (_P_WAIT, test->exename, argv+1);
-        subsize = lseek (1, 0, SEEK_CUR);
-        if (subsize >= sizeof buffer) {
-            fprintf (stderr, "Subtests output too big: %s.\n",
-                     test->name);
-            continue;
-        }
-
-        lseek (1, 0, SEEK_SET);
-        total = 0;
-        while ((bytes_read = read (1, buffer + total, subsize - total))
+    extract_test (test, tempdir, id);
+    argv[1] = test->exename;
+    if (test->is_elf)
+        spawnvp (_P_WAIT, wineloader, argv);
+    else
+        spawnvp (_P_WAIT, test->exename, argv+1);
+    subsize = lseek (1, 0, SEEK_CUR);
+    buffer = xmalloc (subsize+1);
+
+    lseek (1, 0, SEEK_SET);
+    total = 0;
+    while ((bytes_read = read (1, buffer + total, subsize - total))
                && (signed)bytes_read != -1)
             total += bytes_read;
-        if (bytes_read) {
-            fprintf (stderr, "Error reading %s.\n", test->name);
-            continue;
-        }
-        buffer[total] = 0;
-        index = strstr (buffer, header);
-        if (!index) {
-            fprintf (stderr, "Can't parse subtests output of %s.\n",
-                     test->name);
-            continue;
+    if (bytes_read)
+        report (R_FATAL, "Can't get subtests of %s", test->name);
+    buffer[total] = 0;
+    index = strstr (buffer, header);
+    if (!index)
+        report (R_FATAL, "Can't parse subtests output of %s",
+                test->name);
+    index += sizeof header;
+
+    allocated = 10;
+    test->subtests = xmalloc (allocated * sizeof(char*));
+    test->subtest_count = 0;
+    index = strtok (index, seps);
+    while (index) {
+        if (test->subtest_count == allocated) {
+            allocated *= 2;
+            test->subtests = xrealloc (test->subtests,
+                                       allocated * sizeof(char*));
         }
-        index += sizeof(header);
-        allocated = 10;
-        test->subtests = xmalloc (allocated * sizeof (char*));
-        test->subtest_count = 0;
-        index = strtok (index, seps);
-        while (index) {
-            if (test->subtest_count == allocated) {
-                allocated *= 2;
-                test->subtests = xrealloc (test->subtests,
-                                           allocated * sizeof (char*));
-            }
-            test->subtests[test->subtest_count++] = strdup (index);
-            index = strtok (NULL, seps);
-        }
-        test->subtests = xrealloc (test->subtests,
-                                   test->subtest_count * sizeof (char*));
-        all_subtests += test->subtest_count;
+        test->subtests[test->subtest_count++] = strdup (index);
+        index = strtok (NULL, seps);
     }
+    test->subtests = xrealloc (test->subtests,
+                               test->subtest_count * sizeof(char*));
+    free (buffer);
     close (1);
-
-    if (-1 == dup2 (oldstdout, 1)) fatal ("Can't recover old stdout.");
+    if (-1 == dup2 (oldstdout, 1))
+        report (R_FATAL, "Can't recover old stdout.");
     close (oldstdout);
-
-    if (remove (subname)) fatal ("Can't remove subtests file.");
+    if (remove (subname))
+        report (R_FATAL, "Can't remove subtests file.");
     free (subname);
-
-    return all_subtests;
 }
 
-void run_test (struct wine_test* test, const char* subtest)
+/* Return number of failures, -1 if couldn't spawn process. */
+int run_test (struct wine_test* test, const char* subtest)
 {
     int status;
     const char *argv[] = {"wine", test->exename, subtest, NULL};
 
-    fprintf (stderr, "Running %s:%s\n", test->name, subtest);
     xprintf ("%s:%s start\n", test->name, subtest);
     if (test->is_elf)
         status = spawnvp (_P_WAIT, wineloader, argv);
     else
         status = spawnvp (_P_WAIT, test->exename, argv+1);
     if (status == -1)
-        xprintf ("Can't run: %d, errno=%d: %s\n", status, errno, strerror (errno));
-    xprintf ("%s:%s done (%x)\n", test->name, subtest, status);
+        xprintf ("Can't run: %d, errno=%d: %s\n",
+                 status, errno, strerror (errno));
+    xprintf ("%s:%s done (%d)\n", test->name, subtest, status);
+    return status;
+}
+
+BOOL CALLBACK
+EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType,
+                  LPTSTR lpszName, LONG_PTR lParam)
+{
+    (*(int*)lParam)++;
+    return TRUE;
 }
 
-int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
+void
+run_tests ()
 {
-    struct wine_test* test;
-    int nr_of_tests, subtest, i;
+    int nr_of_files = 0, nr_of_tests = 0, i;
     char *tempdir, *logname;
     FILE *logfile;
     char build_tag[128];
@@ -260,51 +266,87 @@
     SetErrorMode (SEM_FAILCRITICALERRORS);
 
     if (!(wineloader = getenv("WINELOADER"))) wineloader = "wine";
-    if (setvbuf (stdout, NULL, _IONBF, 0)) fatal ("Can't unbuffer output.");
+    if (setvbuf (stdout, NULL, _IONBF, 0))
+        report (R_FATAL, "Can't unbuffer output.");
 
     tempdir = tempnam (0, "wct");
-    if (!tempdir) fatal ("Can't name temporary dir (check TMP).");
-    fprintf (stderr, "tempdir=%s\n", tempdir);
-    if (!CreateDirectory (tempdir, NULL)) fatal (strmake (NULL, "Could not create directory: %s", tempdir));
+    if (!tempdir)
+        report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
+    report (R_DIR, tempdir);
+    if (!CreateDirectory (tempdir, NULL))
+        report (R_FATAL, "Could not create directory: %s", tempdir);
 
     logname = tempnam (0, "res");
-    if (!logname) fatal ("Can't name logfile.");
-    fprintf (stderr, "logname=%s\n", logname);
+    if (!logname) report (R_FATAL, "Can't name logfile.");
+    report (R_OUT, logname);
 
-    logfile = fopen (logname, "ab");
-    if (!logfile) fatal ("Could not open logfile.");
-    if (-1 == dup2 (fileno (logfile), 1)) fatal ("Can't redirect stdout.");
+    logfile = fopen (logname, "a");
+    if (!logfile) report (R_FATAL, "Could not open logfile.");
+    if (-1 == dup2 (fileno (logfile), 1))
+        report (R_FATAL, "Can't redirect stdout.");
     fclose (logfile);
 
-    LoadStringA( 0, 0, build_tag, sizeof(build_tag) );
+    xprintf ("Version 1\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 ("Operating system version:\n");
     print_version ();
     xprintf ("Test output:\n" );
 
-    i = 0;
-    while (extract_test (tempdir, i)) i++;
-
-    nr_of_tests = get_subtests (wine_tests);
+    report (R_STATUS, "Counting tests");
+    if (!EnumResourceNames (NULL, TESTRESOURCE,
+                            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");
+    report (R_PROGRESS, nr_of_files);
+    for (i = 0; i < nr_of_files; i++) {
+        get_subtests (tempdir, wine_tests+i, i+1);
+        nr_of_tests += wine_tests[i].subtest_count;
+    }
+    report (R_DELTA, 0, "Extracting: Done");
 
-    for (test = wine_tests; test->name; test++)
-	for (subtest = 0; subtest < test->subtest_count; subtest++)
-	    run_test (test, test->subtests[subtest]);
+    report (R_STATUS, "Running tests");
+    report (R_PROGRESS, nr_of_tests);
+    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++) {
+            report (R_STEP, "Running: %s: %s", test->name,
+                    test->subtests[j]);
+	    run_test (test, test->subtests[j]);
+        }
+    }
+    report (R_DELTA, 0, "Running: Done");
 
+    report (R_STATUS, "Cleaning up");
     close (1);
-
     remove_dir (tempdir);
+    free (tempdir);
+    free (wine_tests);
 
-    /* FIXME: add an explanation of what is going on */
-    if (MessageBoxA( 0, "Do you want to submit the test results?", "Confirmation",
-                     MB_YESNO | MB_ICONQUESTION ) == IDYES)
-    {
+    if (report (R_ASK, MB_YESNO,
+                "Do you want to submit the test results?") == IDYES)
         if (send_file (logname))
-            fatal ("Can't submit logfile (network of file error).");
-    }
+            report (R_FATAL, "Can't submit logfile '%s'", logname);
 
     if (remove (logname))
-        warning (strmake (NULL, "Can't remove logfile: %d.", errno));
+        report (R_WARNING, "Can't remove logfile: %d.", errno);
+    free (logname);
+}
 
-    return 0;
+int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
+                    LPSTR cmdLine, int cmdShow)
+{
+    report (R_STATUS, "Starting up");
+    run_tests ();
+    report (R_STATUS, "Finished");
+    exit (0);
 }
Index: programs/winetest/maketest
===================================================================
RCS file: /home/wine/wine/programs/winetest/maketest,v
retrieving revision 1.2
diff -u -r1.2 maketest
--- programs/winetest/maketest	30 Dec 2003 19:09:25 -0000	1.2
+++ programs/winetest/maketest	13 Jan 2004 03:57:02 -0000
@@ -6,6 +6,7 @@
 fi
 
 echo "/* Automatically generated -- do not edit! */"
+echo "#include \"gui.rc\""
 echo "STRINGTABLE {"
 echo "0 \"$WINE_BUILD\""
 
Index: programs/winetest/send.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/send.c,v
retrieving revision 1.1
diff -u -r1.1 send.c
--- programs/winetest/send.c	4 Dec 2003 02:01:39 -0000	1.1
+++ programs/winetest/send.c	13 Jan 2004 03:57:02 -0000
@@ -19,8 +19,10 @@
  */
 #include <winsock.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "winetest.h"
+#include "gui.h"
 
 SOCKET
 open_http (const char *ipnum)
@@ -29,6 +31,7 @@
     struct sockaddr_in sa;
     SOCKET s;
 
+    report (R_STATUS, "Opening HTTP connection to %s", ipnum);
     if (WSAStartup (MAKEWORD (2,2), &wsad)) return INVALID_SOCKET;
 
     s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -68,15 +71,15 @@
 }
 
 int
-send_str (SOCKET s, const char *fmt, ...)
+send_str (SOCKET s, ...)
 {
     va_list ap;
     char *p;
     int ret;
     size_t len;
 
-    va_start (ap, fmt);
-    p = vstrmake (&len, fmt, ap);
+    va_start (ap, s);
+    p = vstrmake (&len, ap);
     va_end (ap);
     if (!p) return 1;
     ret = send_buf (s, p, len);
@@ -111,55 +114,73 @@
 
     s = open_http ("157.181.170.47");
     if (s == INVALID_SOCKET) {
-        fprintf (stderr, "Can't open connection: %x.\n",
-                 WSAGetLastError ());
+        report (R_WARNING, "Can't open network connection: %d",
+                WSAGetLastError ());
         return 1;
     }
 
     f = fopen (name, "rb");
-    if (!f) goto abort1;
+    if (!f) {
+        report (R_WARNING, "Can't open file '%s': %d", name, errno);
+        goto abort1;
+    }
     fseek (f, 0, SEEK_END);
     filesize = ftell (f);
-    if (filesize > 1024*1024) goto abort2;
+    if (filesize > 1024*1024) {
+        report (R_WARNING,
+                "File too big (%d > 1 MB), copy and submit manually",
+                filesize);
+        goto abort2;
+    }
     fseek (f, 0, SEEK_SET);
 
+    report (R_STATUS, "Sending header");
     str = strmake (&total, body1, name);
     ret = send_str (s, head, filesize + total + sizeof body2 - 1) ||
         send_buf (s, str, total);
     free (str);
     if (ret) {
-        fprintf (stderr, "Can't send header.\n");
+        report (R_WARNING, "Error sending header: %d, %d",
+                errno, WSAGetLastError ());
         goto abort2;
     }
 
-    while ((bytes_read = fread (buffer, 1, sizeof buffer, f)))
+    report (R_STATUS, "Sending %u bytes of data", filesize);
+    report (R_PROGRESS, filesize);
+    while ((bytes_read = fread (buffer, 1, sizeof buffer / 8, f))) {
         if (send_buf (s, buffer, bytes_read)) {
-            fprintf (stderr, "Can't send body.\n");
+            report (R_WARNING, "Error sending body: %d, %d",
+                    errno, WSAGetLastError ());
             goto abort2;
         }
+        report (R_DELTA, bytes_read, "Network transfer: In progress");
+    }
     fclose (f);
 
     if (send_buf (s, body2, sizeof body2 - 1)) {
-        fprintf (stderr, "Can't send trailer.\n");
+        report (R_WARNING, "Error sending trailer: %d, %d",
+                errno, WSAGetLastError ());
         goto abort2;
     }
+    report (R_DELTA, 0, "Network transfer: Done");
 
     total = 0;
     while ((bytes_read = recv (s, buffer + total,
                                sizeof buffer - total, 0))) {
         if ((signed)bytes_read == SOCKET_ERROR) {
-            fprintf (stderr, "Error receiving response: %d.\n",
-                     WSAGetLastError ());
+            report (R_WARNING, "Error receiving reply: %d, %d",
+                    errno, WSAGetLastError ());
             goto abort1;
         }
         total += bytes_read;
         if (total == sizeof buffer) {
-            fprintf (stderr, "Buffer overflow.\n");
+            report (R_WARNING, "Buffer overflow");
             goto abort1;
         }
     }
     if (close_http (s)) {
-        fprintf (stderr, "Error closing connection.\n");
+        report (R_WARNING, "Error closing connection: %d, %d",
+                errno, WSAGetLastError ());
         return 1;
     }
 
Index: programs/winetest/util.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/util.c,v
retrieving revision 1.1
diff -u -r1.1 util.c
--- programs/winetest/util.c	4 Dec 2003 02:01:39 -0000	1.1
+++ programs/winetest/util.c	13 Jan 2004 03:57:02 -0000
@@ -21,23 +21,13 @@
 #include <windows.h>
 
 #include "winetest.h"
-
-void fatal (const char* msg)
-{
-    MessageBox (NULL, msg, "Fatal Error", MB_ICONERROR | MB_OK);
-    exit (1);
-}
-
-void warning (const char* msg)
-{
-    MessageBox (NULL, msg, "Warning", MB_ICONWARNING | MB_OK);
-}
+#include "gui.h"
 
 void *xmalloc (size_t len)
 {
     void *p = malloc (len);
 
-    if (!p) fatal ("Out of memory.");
+    if (!p) report (R_FATAL, "Out of memory.");
     return p;
 }
 
@@ -45,7 +35,7 @@
 {
     void *p = realloc (op, len);
 
-    if (!p) fatal ("Out of memory.");
+    if (!p) report (R_FATAL, "Out of memory.");
     return p;
 }
 
@@ -54,18 +44,20 @@
     va_list ap;
 
     va_start (ap, fmt);
-    if (vprintf (fmt, ap) < 0) fatal ("Can't write logs.");
+    if (vprintf (fmt, ap) < 0) report (R_FATAL, "Can't write logs.");
     va_end (ap);
 }
 
-char *vstrmake (size_t *lenp, const char *fmt, va_list ap)
+char *vstrmake (size_t *lenp, va_list ap)
 {
+    char *fmt;
     size_t size = 1000;
     char *p, *q;
     int n;
 
     p = malloc (size);
     if (!p) return NULL;
+    fmt = va_arg (ap, char*);
     while (1) {
         n = vsnprintf (p, size, fmt, ap);
         if (n < 0) size *= 2;   /* Windows */
@@ -82,14 +74,14 @@
     return p;
 }
 
-char *strmake (size_t *lenp, const char *fmt, ...)
+char *strmake (size_t *lenp, ...)
 {
     va_list ap;
     char *p;
 
-    va_start (ap, fmt);
-    p = vstrmake (lenp, fmt, ap);
-    if (!p) fatal ("Out of memory.");
+    va_start (ap, lenp);
+    p = vstrmake (lenp, ap);
+    if (!p) report (R_FATAL, "Out of memory.");
     va_end (ap);
     return p;
 }
Index: programs/winetest/winetest.h
===================================================================
RCS file: /home/wine/wine/programs/winetest/winetest.h,v
retrieving revision 1.1
diff -u -r1.1 winetest.h
--- programs/winetest/winetest.h	4 Dec 2003 02:01:39 -0000	1.1
+++ programs/winetest/winetest.h	13 Jan 2004 03:57:02 -0000
@@ -31,8 +31,8 @@
 void *xmalloc (size_t len);
 void *xrealloc (void *op, size_t len);
 void xprintf (const char *fmt, ...);
-char *vstrmake (size_t *lenp, const char *fmt, va_list ap);
-char *strmake (size_t *lenp, const char *fmt, ...);
+char *vstrmake (size_t *lenp, va_list ap);
+char *strmake (size_t *lenp, ...);
 
 int send_file (const char *name);
 
--- /dev/null	Fri Mar 29 18:19:48 2002
+++ programs/winetest/binary.rc	Mon Jan  5 18:52:39 2004
@@ -0,0 +1,71 @@
+/* BINRES wine.ico */
+{
+ '00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02'
+ '00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01'
+ '00 00 0E 03 00 00 28 00 00 00 20 00 00 00 40 00'
+ '00 00 01 00 04 00 00 00 00 00 00 02 00 00 00 00'
+ '00 00 00 00 00 00 10 00 00 00 00 00 00 00 39 02'
+ 'B1 00 23 02 6C 00 0F 03 29 00 1B 02 51 00 FF FF'
+ 'FF 00 1B 1A 1B 00 1E 02 63 00 33 02 A1 00 08 08'
+ '08 00 14 03 3C 00 0C 04 1E 00 2E 02 8E 00 10 0F'
+ '10 00 2A 02 82 00 29 02 7D 00 03 02 04 00 44 44'
+ '44 44 44 44 44 44 55 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 8F FF 84 44 44 44 44 44 44 44 44 44'
+ '44 44 44 8F F8 F8 44 44 44 44 44 44 44 44 44 44'
+ '44 44 8F FF F5 44 44 44 44 44 44 44 44 44 44 44'
+ '44 5C F8 C8 F5 44 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 85 44 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 4C 44 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 4C 44 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 45 54 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 45 F4 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 45 FF 44 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 48 FF F4 44 44 44 44 44 44 44 44 44'
+ '44 44 44 44 48 23 9A 84 44 44 44 44 44 44 44 44'
+ '44 44 44 44 42 B7 7E AF 44 44 44 44 44 44 44 44'
+ '44 44 44 44 49 00 00 EA C4 44 44 44 44 44 44 44'
+ '44 44 44 44 46 00 00 01 F4 44 44 44 44 44 44 44'
+ '44 44 44 44 46 00 00 00 9F 44 44 44 44 44 44 44'
+ '44 44 44 44 46 00 70 00 EF 44 44 44 44 44 44 44'
+ '44 44 44 44 43 00 00 00 79 F4 44 44 44 44 44 44'
+ '44 44 44 44 49 00 00 00 0E F4 44 44 44 44 44 44'
+ '44 44 44 44 42 00 00 00 07 24 44 44 44 44 44 44'
+ '44 44 44 44 43 B0 00 00 00 34 44 44 44 44 44 44'
+ '44 44 44 44 4C 30 00 00 00 1F 44 44 44 44 44 44'
+ '44 44 44 44 48 27 E1 1D B1 2C 44 44 44 44 44 44'
+ '44 44 44 44 44 A9 CC CF F8 48 C4 44 44 44 44 44'
+ '44 44 44 44 44 58 44 44 44 45 C4 44 44 44 44 44'
+ '44 44 44 44 44 4C 44 44 44 44 84 44 44 44 44 44'
+ '44 44 44 44 44 48 44 44 44 44 C4 44 44 44 44 44'
+ '44 44 44 44 44 48 C4 44 44 44 C4 44 44 44 44 44'
+ '44 44 44 44 44 44 F4 44 44 4C C4 44 44 44 44 44'
+ '44 44 44 44 44 44 84 44 F8 84 44 44 44 44 44 44'
+ '44 44 44 44 44 44 48 F8 44 44 44 44 44 44 FF FF'
+ '3F FF FF F0 7F FF FF C0 FF FF FF 03 FF FF FC 03'
+ 'FF FF FF F3 FF FF FF FB FF FF FF FB FF FF FF F9'
+ 'FF FF FF F9 FF FF FF F8 FF FF FF F8 7F FF FF F8'
+ '1F FF FF F8 0F FF FF F8 07 FF FF F8 07 FF FF F8'
+ '03 FF FF F8 03 FF FF F8 01 FF FF F8 01 FF FF F8'
+ '01 FF FF F8 01 FF FF F8 00 FF FF F8 00 FF FF FC'
+ '02 7F FF FC FE 7F FF FE FF 7F FF FE FF 7F FF FE'
+ '7F 7F FF FF 7E 7F FF FF 71 FF FF FF 8F FF 28 00'
+ '00 00 10 00 00 00 20 00 00 00 01 00 04 00 00 00'
+ '00 00 80 00 00 00 00 00 00 00 00 00 00 00 10 00'
+ '00 00 00 00 00 00 3A 02 B1 00 0A 06 14 00 12 03'
+ '33 00 FF FF FF 00 12 12 12 00 0B 0B 0B 00 1B 1B'
+ '1B 00 25 02 6F 00 2E 02 92 00 1A 02 52 00 36 02'
+ 'A6 00 15 03 3E 00 04 04 05 00 13 11 19 00 1E 02'
+ '62 00 2A 02 82 00 33 33 33 CC 43 33 33 33 33 33'
+ 'CC 5C 33 33 33 33 33 36 C5 53 33 33 33 33 33 33'
+ '33 43 33 33 33 33 33 33 33 65 33 33 33 33 33 33'
+ '33 DC 33 33 33 33 33 33 33 17 EC 33 33 33 33 33'
+ '33 B0 07 53 33 33 33 33 33 90 00 B3 33 33 33 33'
+ '33 B0 00 FC 33 33 33 33 33 BA 00 A2 33 33 33 33'
+ '33 C7 88 82 33 33 33 33 33 3D D5 14 43 33 33 33'
+ '33 35 33 33 53 33 33 33 33 33 53 33 53 33 33 33'
+ '33 33 C5 5C 33 33 FC 7F 00 00 F0 FF 00 00 E1 FF'
+ '00 00 FD FF 00 00 FC FF 00 00 FC FF 00 00 FC 3F'
+ '00 00 FC 1F 00 00 FC 1F 00 00 FC 0F 00 00 FC 0F'
+ '00 00 FC 0F 00 00 FE 07 00 00 FE F7 00 00 FF 77'
+ '00 00 FF 0F 00 00'
+}
--- /dev/null	Fri Mar 29 18:19:48 2002
+++ programs/winetest/gui.c	Fri Jan  9 03:34:42 2004
@@ -0,0 +1,392 @@
+#include <windows.h>
+#include <commctrl.h>
+
+#include "gui.h"
+#include "guires.h"
+#include "winetest.h"
+
+/* Event object to signal successful window creation to main thread.
+ */
+HANDLE initEvent;
+
+/* Dialog handle
+ */
+HWND dialog;
+
+/* Progress data for the text* functions and for scaling.
+ */
+unsigned int progressMax, progressCurr;
+double progressScale;
+
+/* Progress group counter for the gui* functions.
+ */
+int progressGroup = -1;
+
+char *
+renderString (va_list ap)
+{
+    const char *fmt = va_arg (ap, char*);
+    static char buffer[128];
+
+    vsnprintf (buffer, sizeof buffer, fmt, ap);
+    return buffer;
+}
+
+/* report (R_STATUS, fmt, ...) */
+int
+textStatus (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    fputs (str, stderr);
+    fputc ('\n', stderr);
+    free (str);
+    return 0;
+}
+
+int
+guiStatus (va_list ap)
+{
+    size_t len;
+    char *str = vstrmake (&len, ap);
+
+    if (len > 128) str[129] = 0;
+    SetDlgItemText (dialog, IDC_SB, str);
+    free (str);
+    return 0;
+}
+
+/* report (R_PROGRESS, steps) */
+int
+textProgress (va_list ap)
+{
+    progressMax = va_arg (ap, int);
+    progressCurr = 0;
+    return 0;
+}
+
+int
+guiProgress (va_list ap)
+{
+    unsigned int max = va_arg (ap, int);
+    HWND pb = GetDlgItem (dialog, IDC_PB0 + ++progressGroup * 2);
+
+    progressMax = max;
+    progressCurr = 0;
+    if (max > 0xffff) {
+        progressScale = (double)0xffff / max;
+        max = 0xffff;
+    }
+    else progressScale = 1;
+    SendMessage (pb, PBM_SETRANGE, 0, MAKELPARAM (0, max));
+    SendMessage (pb, PBM_SETSTEP, (WPARAM)1, 0);
+    return 0;
+}
+
+/* report (R_STEP, fmt, ...) */
+int
+textStep (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    progressCurr++;
+    fputs (str, stderr);
+    fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
+    free (str);
+    return 0;
+}
+
+int
+guiStep (va_list ap)
+{
+    const int pgID = IDC_ST0 + progressGroup * 2;
+    char *str = vstrmake (NULL, ap);
+    
+    progressCurr++;
+    SetDlgItemText (dialog, pgID, str);
+    SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
+                        (WPARAM)(progressScale * progressCurr), 0);
+    free (str);
+    return 0;
+}
+
+/* report (R_DELTA, inc, fmt, ...) */
+int
+textDelta (va_list ap)
+{
+    const int inc = va_arg (ap, int);
+    char *str = vstrmake (NULL, ap);
+
+    progressCurr += inc;
+    fputs (str, stderr);
+    fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
+    free (str);
+    return 0;
+}
+
+int
+guiDelta (va_list ap)
+{
+    const int inc = va_arg (ap, int);
+    const int pgID = IDC_ST0 + progressGroup * 2;
+    char *str = vstrmake (NULL, ap);
+
+    progressCurr += inc;
+    SetDlgItemText (dialog, pgID, str);
+    SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
+                        (WPARAM)(progressScale * progressCurr), 0);
+    free (str);
+    return 0;
+}
+
+/* report (R_DIR, fmt, ...) */
+int
+textDir (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    fputs ("Temporary directory: ", stderr);
+    fputs (str, stderr);
+    fputc ('\n', stderr);
+    free (str);
+    return 0;
+}
+
+int
+guiDir (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    SetDlgItemText (dialog, IDC_DIR, str);
+    free (str);
+    return 0;
+}
+
+/* report (R_OUT, fmt, ...) */
+int
+textOut (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    fputs ("Log file: ", stderr);
+    fputs (str, stderr);
+    fputc ('\n', stderr);
+    free (str);
+    return 0;
+}
+
+int
+guiOut (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    SetDlgItemText (dialog, IDC_OUT, str);
+    free (str);
+    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);
+    return 0;
+}
+
+int
+guiWarning (va_list ap)
+{
+    char *str = vstrmake (NULL, ap);
+
+    MessageBox (dialog, str, "Warning", MB_ICONWARNING | MB_OK);
+    free (str);
+    return 0;
+}
+
+/* report (R_ASK, type, fmt, ...) */
+int
+textAsk (va_list ap)
+{
+    int uType = va_arg (ap, int);
+    char *str = vstrmake (NULL, ap);
+
+    fprintf (stderr, "Question of type %d: %s\n!FIXME, stub\n",
+             uType, str);
+    free (str);
+    return 0;
+}
+
+int
+guiAsk (va_list ap)
+{
+    int uType = va_arg (ap, int);
+    char *str = vstrmake (NULL, ap);
+    int ret = MessageBox (dialog, str, "Question",
+                          MB_ICONQUESTION | uType);
+
+    free (str);
+    return ret;
+}
+
+BOOL CALLBACK
+AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg) {
+    case WM_COMMAND:
+        switch (LOWORD (wParam)) {
+        case IDCANCEL:
+            EndDialog (hwnd, IDCANCEL);
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
+BOOL CALLBACK
+DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg) {
+    case WM_INITDIALOG:
+        SendMessage (hwnd, WM_SETICON, ICON_SMALL,
+                     (LPARAM)LoadIcon (GetModuleHandle (NULL),
+                                       MAKEINTRESOURCE (IDI_WINE)));
+        SendMessage (hwnd, WM_SETICON, ICON_BIG,
+                     (LPARAM)LoadIcon (GetModuleHandle (NULL),
+                                       MAKEINTRESOURCE (IDI_WINE)));
+        dialog = hwnd;
+        if (!SetEvent (initEvent)) {
+            report (R_STATUS, "Can't signal main thread: %d",
+                    GetLastError ());
+            EndDialog (hwnd, 2);
+        }
+        return TRUE;
+    case WM_CLOSE:
+        EndDialog (hwnd, 3);
+        return TRUE;
+    case WM_COMMAND:
+        switch (LOWORD (wParam)) {
+        case IDHELP:
+            DialogBox (GetModuleHandle (NULL),
+                       MAKEINTRESOURCE (IDD_ABOUT), hwnd, AboutProc);
+            return TRUE;
+        case IDABORT:
+            report (R_WARNING, "Not implemented");
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
+DWORD WINAPI
+DlgThreadProc ()
+{
+    int ret;
+
+    InitCommonControls ();
+    ret = DialogBox (GetModuleHandle (NULL),
+                     MAKEINTRESOURCE (IDD_STATUS),
+                     NULL, DlgProc);
+    switch (ret) {
+    case 0:
+        report (R_WARNING, "Invalid parent handle");
+        break;
+    case 1:
+        report (R_WARNING, "DialogBox failed: %d",
+                GetLastError ());
+        break;
+    case 3:
+        exit (0);
+    default:
+        report (R_STATUS, "Dialog exited: %d", ret);
+    }
+    return 0;
+}
+
+int
+report (enum report_type t, ...)
+{
+    typedef int r_fun_t (va_list);
+
+    va_list ap;
+    int ret = 0;
+    static r_fun_t * const text_funcs[] =
+        {textStatus, textProgress, textStep, textDelta,
+         textDir, textOut, textFatal, textWarning, textAsk};
+    static r_fun_t * const GUI_funcs[] =
+        {guiStatus, guiProgress, guiStep, guiDelta,
+         guiDir, guiOut, guiFatal, guiWarning, guiAsk};
+    static r_fun_t * const * funcs = NULL;
+
+    if (!funcs) {
+        HANDLE DlgThread;
+        DWORD DlgThreadID;
+
+        funcs = text_funcs;
+        initEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+        if (!initEvent)
+            report (R_STATUS, "Can't create event object: %d",
+                    GetLastError ());
+        else {
+            DlgThread = CreateThread (NULL, 0, DlgThreadProc,
+                                      NULL, 0, &DlgThreadID);
+            if (!DlgThread)
+                report (R_STATUS, "Can't create GUI thread: %d",
+                        GetLastError ());
+            else {
+                DWORD ret = WaitForSingleObject (initEvent, INFINITE);
+                switch (ret) {
+                case WAIT_OBJECT_0:
+                    funcs = GUI_funcs;
+                    break;
+                case WAIT_TIMEOUT:
+                    report (R_STATUS, "GUI creation timed out");
+                    break;
+                case WAIT_FAILED:
+                    report (R_STATUS, "Wait for GUI failed: %d",
+                            GetLastError ());
+                    break;
+                default:
+                    report (R_STATUS, "Wait returned %d",
+                            ret);
+                    break;
+                }
+            }
+        }
+    }
+        
+    va_start (ap, t);
+    if (t < sizeof text_funcs / sizeof text_funcs[0] &&
+        t < sizeof GUI_funcs / sizeof GUI_funcs[0] &&
+        t >= 0) ret = funcs[t](ap);
+    else report (R_WARNING, "unimplemented report type: %d", t);
+    va_end (ap);
+    return ret;
+}
--- /dev/null	Fri Mar 29 18:19:48 2002
+++ programs/winetest/gui.h	Fri Jan  9 03:11:34 2004
@@ -0,0 +1,20 @@
+#ifndef __GUI_H
+#define __GUI_H
+
+#include <windows.h>
+
+enum report_type {
+    R_STATUS = 0,
+    R_PROGRESS,
+    R_STEP,
+    R_DELTA,
+    R_DIR,
+    R_OUT,
+    R_FATAL,
+    R_WARNING,
+    R_ASK
+};
+
+int report (enum report_type t, ...);
+
+#endif /* __GUI_H */
--- /dev/null	Fri Mar 29 18:19:48 2002
+++ programs/winetest/gui.rc	Fri Jan  9 03:28:20 2004
@@ -0,0 +1,40 @@
+#include <windows.h>
+#include <winres.h>
+#include "guires.h"
+
+IDD_STATUS DIALOG 0, 0, 160, 140
+STYLE WS_OVERLAPPEDWINDOW
+CAPTION "Wine Test Shell"
+BEGIN
+    LTEXT   "Extracting:",       IDC_ST0,        10,   5, 140, 10
+    CONTROL "PB0", IDC_PB0, PROGRESS_CLASS, 0,    5,  15, 150, 10
+    LTEXT   "Running:",          IDC_ST1,        10,  30, 140, 10
+    CONTROL "PB1", IDC_PB1, PROGRESS_CLASS, 0,    5,  40, 150, 15
+    LTEXT   "Network transfer:", IDC_ST2,        10,  60, 140, 10
+    CONTROL "PB2", IDC_PB2, PROGRESS_CLASS, 0,    5,  70, 150, 10
+                                               
+    LTEXT   "Working directory:", IDC_STATIC,    10,  89, 100, 10
+    EDITTEXT                      IDC_DIR,       71,  88,  79, 10,
+             ES_READONLY | ES_AUTOHSCROLL
+    LTEXT   "Output file:",       IDC_STATIC,    10, 100, 100, 10
+    EDITTEXT                      IDC_OUT,       46,  99, 104, 10,
+             ES_READONLY | ES_AUTOHSCROLL
+
+    DEFPUSHBUTTON "About", IDHELP,               20, 113,  30, 14
+    PUSHBUTTON    "Edit",  IDCANCEL,             65, 113,  30, 14,
+                   WS_DISABLED
+    PUSHBUTTON    "Stop",  IDABORT,             110, 113,  30, 14
+
+    CONTROL "Created", IDC_SB, STATUSCLASSNAME, 0, 0,0,0,0
+END
+
+IDD_ABOUT DIALOG 0, 0, 150, 55
+STYLE WS_POPUP
+CAPTION "About Wine Test Shell"
+BEGIN
+    CTEXT "This program extracts and runs a\r\nseries of tests which check Wine's\r\nconformance to Microsoft Windows.",
+        IDC_STATIC, 10, 5, 130, 30
+    DEFPUSHBUTTON "Close", IDCANCEL, 55, 35, 40, 14
+END
+
+IDI_WINE ICON "wine.ico"
--- /dev/null	Fri Mar 29 18:19:48 2002
+++ programs/winetest/guires.h	Tue Jan  6 19:55:24 2004
@@ -0,0 +1,19 @@
+#define IDI_WINE 1
+
+#define IDD_STATUS 100
+#define IDD_ABOUT  101
+
+#define IDC_ST0 1000
+#define IDC_PB0 1001
+#define IDC_ST1 1002
+#define IDC_PB1 1003
+#define IDC_ST2 1004
+#define IDC_PB2 1005
+
+#define IDC_DIR 2000
+#define IDC_OUT 2001
+
+#define IDC_SB  3000
+
+#define IDC_EDIT  4000
+#define IDC_ABOUT 4001


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux