winetest gui feedback

Ferenc Wagner wferi at afavant.elte.hu
Fri Feb 20 18:28:37 CST 2004


ChangeLog: Report the error sent by the CGI script.
           Make progress bar selection explicit.

Index: gui.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/gui.c,v
retrieving revision 1.3
diff -u -r1.3 gui.c
--- gui.c	20 Feb 2004 01:09:31 -0000	1.3
+++ gui.c	21 Feb 2004 00:21:00 -0000
@@ -39,7 +39,7 @@
 
 /* Progress group counter for the gui* functions.
  */
-int progressGroup = -1;
+int progressGroup;
 
 char *
 renderString (va_list ap)
@@ -90,7 +90,7 @@
     return 0;
 }
 
-/* report (R_PROGRESS, steps) */
+/* report (R_PROGRESS, barnum, steps) */
 int
 textProgress (va_list ap)
 {
@@ -102,16 +102,18 @@
 int
 guiProgress (va_list ap)
 {
-    unsigned int max = va_arg (ap, int);
-    HWND pb = GetDlgItem (dialog, IDC_PB0 + ++progressGroup * 2);
+    unsigned int max;
+    HWND pb;
 
-    progressMax = max;
+    progressGroup = va_arg (ap, int);
+    progressMax = max = va_arg (ap, int);
     progressCurr = 0;
     if (max > 0xffff) {
         progressScale = (double)0xffff / max;
         max = 0xffff;
     }
     else progressScale = 1;
+    pb = GetDlgItem (dialog, IDC_PB0 + progressGroup * 2);
     SendMessage (pb, PBM_SETRANGE, 0, MAKELPARAM (0, max));
     SendMessage (pb, PBM_SETSTEP, (WPARAM)1, 0);
     return 0;
Index: main.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/main.c,v
retrieving revision 1.4
diff -u -r1.4 main.c
--- main.c	20 Feb 2004 19:56:29 -0000	1.4
+++ main.c	21 Feb 2004 00:21:00 -0000
@@ -311,7 +311,7 @@
     wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
 
     report (R_STATUS, "Extracting tests");
-    report (R_PROGRESS, nr_of_files);
+    report (R_PROGRESS, 0, 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;
@@ -319,7 +319,7 @@
     report (R_DELTA, 0, "Extracting: Done");
 
     report (R_STATUS, "Running tests");
-    report (R_PROGRESS, nr_of_tests);
+    report (R_PROGRESS, 1, nr_of_tests);
     for (i = 0; i < nr_of_files; i++) {
         struct wine_test *test = wine_tests + i;
         int j;
@@ -385,8 +385,7 @@
                 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);
+                send_file (submit);
                 break;
             case 'o':
                 logname = strtok (NULL, " ");
@@ -411,12 +410,10 @@
     if (!logname && !submit) {
         report (R_STATUS, "Starting up");
         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);
+        if (report (R_ASK, MB_YESNO, "Do you want to submit the "
+                    "test results?") == IDYES)
+            if (!send_file (logname) && remove (logname))
+                report (R_WARNING, "Can't remove logfile: %d.", errno);
         free (logname);
         report (R_STATUS, "Finished");
     }
Index: send.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/send.c,v
retrieving revision 1.2
diff -u -r1.2 send.c
--- send.c	15 Jan 2004 01:48:05 -0000	1.2
+++ send.c	21 Feb 2004 00:21:00 -0000
@@ -91,14 +91,15 @@
 {
     SOCKET s;
     FILE *f;
-    unsigned char buffer[8192];
+#define BUFLEN 8192
+    unsigned char *buffer;
     size_t bytes_read, total, filesize;
     char *str;
     int ret;
 
     /* RFC 2068 */
 #define SEP "-"
-    const char head[] = "POST /~wferi/cgi-bin/winetests.cgi HTTP/1.0\r\n"
+    const char head[] = "POST /~wferi/cgi-bin/winetest.cgi HTTP/1.0\r\n"
         "Host: afavant\r\n"
         "User-Agent: Winetests Shell\r\n"
         "Content-Type: multipart/form-data; boundary=" SEP "\r\n"
@@ -111,6 +112,7 @@
         "Upload File\r\n"
         "--" SEP "--\r\n";
 
+    buffer = xmalloc (BUFLEN + 1);
     s = open_http ("157.181.170.47");
     if (s == INVALID_SOCKET) {
         report (R_WARNING, "Can't open network connection: %d",
@@ -145,8 +147,8 @@
     }
 
     report (R_STATUS, "Sending %u bytes of data", filesize);
-    report (R_PROGRESS, filesize);
-    while ((bytes_read = fread (buffer, 1, sizeof buffer / 8, f))) {
+    report (R_PROGRESS, 2, filesize);
+    while ((bytes_read = fread (buffer, 1, BUFLEN / 8, f))) {
         if (send_buf (s, buffer, bytes_read)) {
             report (R_WARNING, "Error sending body: %d, %d",
                     errno, WSAGetLastError ());
@@ -164,15 +166,14 @@
     report (R_DELTA, 0, "Network transfer: Done");
 
     total = 0;
-    while ((bytes_read = recv (s, buffer + total,
-                               sizeof buffer - total, 0))) {
+    while ((bytes_read = recv (s, buffer+total, BUFLEN-total, 0))) {
         if ((signed)bytes_read == SOCKET_ERROR) {
             report (R_WARNING, "Error receiving reply: %d, %d",
                     errno, WSAGetLastError ());
             goto abort1;
         }
         total += bytes_read;
-        if (total == sizeof buffer) {
+        if (total == BUFLEN) {
             report (R_WARNING, "Buffer overflow");
             goto abort1;
         }
@@ -187,11 +188,20 @@
                    name, filesize);
     ret = memcmp (str, buffer + total - bytes_read, bytes_read);
     free (str);
-    return ret!=0;
+    if (ret) {
+        buffer[total] = 0;
+        str = strstr (buffer, "\r\n\r\n");
+        if (str) buffer = str + 4;
+        report (R_ERROR, "Can't submit logfile '%s'. "
+                "Server response: %s", name, buffer);
+    }
+    free (buffer);
+    return ret;
 
  abort2:
     fclose (f);
  abort1:
     close_http (s);
+    free (buffer);
     return 1;
 }



More information about the wine-patches mailing list