Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Wine Conformance Test EXE |
| 3 | * |
Jakob Eriksson | 580bce7 | 2004-12-22 14:50:50 +0000 | [diff] [blame] | 4 | * Copyright 2003, 2004 Jakob Eriksson (for Solid Form Sweden AB) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 5 | * Copyright 2003 Dimitrie O. Paun |
| 6 | * Copyright 2003 Ferenc Wagner |
| 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2.1 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 21 | * |
| 22 | * This program is dedicated to Anna Lindh, |
| 23 | * Swedish Minister of Foreign Affairs. |
| 24 | * Anna was murdered September 11, 2003. |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include "config.h" |
| 29 | #include "wine/port.h" |
| 30 | |
| 31 | #include <stdio.h> |
| 32 | #include <stdlib.h> |
Dmitry Timoshkov | 454c1b7 | 2005-03-10 17:17:35 +0000 | [diff] [blame] | 33 | #include <assert.h> |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 34 | #include <errno.h> |
| 35 | #ifdef HAVE_UNISTD_H |
| 36 | # include <unistd.h> |
| 37 | #endif |
| 38 | #include <windows.h> |
| 39 | |
| 40 | #include "winetest.h" |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 41 | #include "resource.h" |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 42 | |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 43 | struct wine_test |
| 44 | { |
| 45 | char *name; |
| 46 | int resource; |
| 47 | int subtest_count; |
| 48 | char **subtests; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 49 | char *exename; |
| 50 | }; |
| 51 | |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 52 | struct rev_info |
| 53 | { |
| 54 | const char* file; |
| 55 | const char* rev; |
| 56 | }; |
| 57 | |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 58 | char *tag = NULL; |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 59 | static struct wine_test *wine_tests; |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 60 | static struct rev_info *rev_infos = NULL; |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 61 | static const char whitespace[] = " \t\r\n"; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 62 | |
Jakob Eriksson | 82c191f | 2004-04-23 00:06:57 +0000 | [diff] [blame] | 63 | static int running_under_wine () |
| 64 | { |
| 65 | HMODULE module = GetModuleHandleA("ntdll.dll"); |
| 66 | |
| 67 | if (!module) return 0; |
Alexandre Julliard | 9db147e | 2004-04-23 02:46:18 +0000 | [diff] [blame] | 68 | return (GetProcAddress(module, "wine_server_call") != NULL); |
Jakob Eriksson | 82c191f | 2004-04-23 00:06:57 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Jakob Eriksson | 580bce7 | 2004-12-22 14:50:50 +0000 | [diff] [blame] | 71 | static int running_on_visible_desktop () |
| 72 | { |
Dmitry Timoshkov | 097df18 | 2005-03-14 10:06:22 +0000 | [diff] [blame] | 73 | HWND desktop; |
| 74 | HMODULE huser32 = GetModuleHandle("user32.dll"); |
| 75 | FARPROC pGetProcessWindowStation = GetProcAddress(huser32, "GetProcessWindowStation"); |
| 76 | FARPROC pGetUserObjectInformationA = GetProcAddress(huser32, "GetUserObjectInformationA"); |
Dmitry Timoshkov | b5c358b | 2005-03-07 10:58:37 +0000 | [diff] [blame] | 77 | |
Dmitry Timoshkov | 097df18 | 2005-03-14 10:06:22 +0000 | [diff] [blame] | 78 | desktop = GetDesktopWindow(); |
| 79 | if (!GetWindowLongPtrW(desktop, GWLP_WNDPROC)) /* Win9x */ |
| 80 | return IsWindowVisible(desktop); |
| 81 | |
| 82 | if (pGetProcessWindowStation && pGetUserObjectInformationA) |
Dmitry Timoshkov | 454c1b7 | 2005-03-10 17:17:35 +0000 | [diff] [blame] | 83 | { |
| 84 | DWORD len; |
| 85 | HWINSTA wstation; |
| 86 | USEROBJECTFLAGS uoflags; |
Dmitry Timoshkov | b5c358b | 2005-03-07 10:58:37 +0000 | [diff] [blame] | 87 | |
Dmitry Timoshkov | 454c1b7 | 2005-03-10 17:17:35 +0000 | [diff] [blame] | 88 | wstation = (HWINSTA)pGetProcessWindowStation(); |
| 89 | assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len)); |
| 90 | return (uoflags.dwFlags & WSF_VISIBLE) != 0; |
| 91 | } |
Dmitry Timoshkov | 097df18 | 2005-03-14 10:06:22 +0000 | [diff] [blame] | 92 | return IsWindowVisible(desktop); |
Jakob Eriksson | 580bce7 | 2004-12-22 14:50:50 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 95 | void print_version () |
| 96 | { |
| 97 | OSVERSIONINFOEX ver; |
| 98 | BOOL ext; |
| 99 | |
| 100 | ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
| 101 | if (!(ext = GetVersionEx ((OSVERSIONINFO *) &ver))) |
| 102 | { |
| 103 | ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
| 104 | if (!GetVersionEx ((OSVERSIONINFO *) &ver)) |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 105 | report (R_FATAL, "Can't get OS version."); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Ferenc Wagner | 21b8503 | 2004-04-23 02:52:21 +0000 | [diff] [blame] | 108 | xprintf (" bRunningUnderWine=%d\n", running_under_wine ()); |
Jakob Eriksson | 580bce7 | 2004-12-22 14:50:50 +0000 | [diff] [blame] | 109 | xprintf (" bRunningOnVisibleDesktop=%d\n", running_on_visible_desktop ()); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 110 | xprintf (" dwMajorVersion=%ld\n dwMinorVersion=%ld\n" |
| 111 | " dwBuildNumber=%ld\n PlatformId=%ld\n szCSDVersion=%s\n", |
| 112 | ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber, |
| 113 | ver.dwPlatformId, ver.szCSDVersion); |
| 114 | |
| 115 | if (!ext) return; |
| 116 | |
| 117 | xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n" |
| 118 | " wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n", |
| 119 | ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask, |
| 120 | ver.wProductType, ver.wReserved); |
| 121 | } |
| 122 | |
| 123 | static inline int is_dot_dir(const char* x) |
| 124 | { |
| 125 | return ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0)))); |
| 126 | } |
| 127 | |
| 128 | void remove_dir (const char *dir) |
| 129 | { |
| 130 | HANDLE hFind; |
| 131 | WIN32_FIND_DATA wfd; |
| 132 | char path[MAX_PATH]; |
| 133 | size_t dirlen = strlen (dir); |
| 134 | |
| 135 | /* Make sure the directory exists before going further */ |
| 136 | memcpy (path, dir, dirlen); |
| 137 | strcpy (path + dirlen++, "\\*"); |
| 138 | hFind = FindFirstFile (path, &wfd); |
| 139 | if (hFind == INVALID_HANDLE_VALUE) return; |
| 140 | |
| 141 | do { |
| 142 | char *lp = wfd.cFileName; |
| 143 | |
| 144 | if (!lp[0]) lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */ |
| 145 | if (is_dot_dir (lp)) continue; |
| 146 | strcpy (path + dirlen, lp); |
| 147 | if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) |
| 148 | remove_dir(path); |
| 149 | else if (!DeleteFile (path)) |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 150 | report (R_WARNING, "Can't delete file %s: error %d", |
| 151 | path, GetLastError ()); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 152 | } while (FindNextFile (hFind, &wfd)); |
| 153 | FindClose (hFind); |
| 154 | if (!RemoveDirectory (dir)) |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 155 | report (R_WARNING, "Can't remove directory %s: error %d", |
| 156 | dir, GetLastError ()); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 159 | const char* get_test_source_file(const char* test, const char* subtest) |
| 160 | { |
| 161 | static const char* special_dirs[][2] = { |
| 162 | { "gdi32", "gdi"}, { "kernel32", "kernel" }, |
Ferenc Wagner | 70cd740 | 2004-05-05 19:00:34 +0000 | [diff] [blame] | 163 | { "msacm32", "msacm" }, |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 164 | { "user32", "user" }, { "winspool.drv", "winspool" }, |
| 165 | { "ws2_32", "winsock" }, { 0, 0 } |
| 166 | }; |
| 167 | static char buffer[MAX_PATH]; |
| 168 | int i; |
| 169 | |
| 170 | for (i = 0; special_dirs[i][0]; i++) { |
| 171 | if (strcmp(test, special_dirs[i][0]) == 0) { |
| 172 | test = special_dirs[i][1]; |
| 173 | break; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | snprintf(buffer, sizeof(buffer), "dlls/%s/tests/%s.c", test, subtest); |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 178 | return buffer; |
| 179 | } |
| 180 | |
| 181 | const char* get_file_rev(const char* file) |
| 182 | { |
| 183 | const struct rev_info* rev; |
| 184 | |
| 185 | for(rev = rev_infos; rev->file; rev++) { |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 186 | if (strcmp(rev->file, file) == 0) return rev->rev; |
| 187 | } |
| 188 | |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 189 | return "-"; |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | void extract_rev_infos () |
| 193 | { |
| 194 | char revinfo[256], *p; |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 195 | int size = 0, i, len; |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 196 | HMODULE module = GetModuleHandle (NULL); |
| 197 | |
| 198 | for (i = 0; TRUE; i++) { |
| 199 | if (i >= size) { |
| 200 | size += 100; |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 201 | rev_infos = xrealloc (rev_infos, size * sizeof (*rev_infos)); |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 202 | } |
| 203 | memset(rev_infos + i, 0, sizeof(rev_infos[i])); |
| 204 | |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 205 | len = LoadStringA (module, REV_INFO+i, revinfo, sizeof(revinfo)); |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 206 | if (len == 0) break; /* end of revision info */ |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 207 | if (len >= sizeof(revinfo) - 1) |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 208 | report (R_FATAL, "Revision info too long."); |
| 209 | if(!(p = strrchr(revinfo, ':'))) |
| 210 | report (R_FATAL, "Revision info malformed (i=%d)", i); |
| 211 | *p = 0; |
| 212 | rev_infos[i].file = strdup(revinfo); |
| 213 | rev_infos[i].rev = strdup(p + 1); |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 214 | } |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 215 | } |
| 216 | |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 217 | void* extract_rcdata (int id, int type, DWORD* size) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 218 | { |
| 219 | HRSRC rsrc; |
| 220 | HGLOBAL hdl; |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 221 | LPVOID addr; |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 222 | |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 223 | if (!(rsrc = FindResource (NULL, (LPTSTR)id, MAKEINTRESOURCE(type))) || |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 224 | !(*size = SizeofResource (0, rsrc)) || |
| 225 | !(hdl = LoadResource (0, rsrc)) || |
| 226 | !(addr = LockResource (hdl))) |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 227 | return NULL; |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 228 | return addr; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 231 | /* Fills in the name and exename fields */ |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 232 | void |
| 233 | extract_test (struct wine_test *test, const char *dir, int id) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 234 | { |
| 235 | BYTE* code; |
| 236 | DWORD size; |
| 237 | FILE* fout; |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 238 | int strlen, bufflen = 128; |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 239 | char *exepos; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 240 | |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 241 | code = extract_rcdata (id, TESTRES, &size); |
| 242 | if (!code) report (R_FATAL, "Can't find test resource %d: %d", |
| 243 | id, GetLastError ()); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 244 | test->name = xmalloc (bufflen); |
| 245 | while ((strlen = LoadStringA (NULL, id, test->name, bufflen)) |
| 246 | == bufflen - 1) { |
| 247 | bufflen *= 2; |
| 248 | test->name = xrealloc (test->name, bufflen); |
| 249 | } |
| 250 | if (!strlen) report (R_FATAL, "Can't read name of test %d.", id); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 251 | test->exename = strmake (NULL, "%s/%s", dir, test->name); |
Ferenc Wagner | 8387770 | 2004-03-19 01:54:10 +0000 | [diff] [blame] | 252 | exepos = strstr (test->name, "_test.exe"); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 253 | if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name); |
| 254 | *exepos = 0; |
| 255 | test->name = xrealloc (test->name, exepos - test->name + 1); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 256 | report (R_STEP, "Extracting: %s", test->name); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 257 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 258 | if (!(fout = fopen (test->exename, "wb")) || |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 259 | (fwrite (code, size, 1, fout) != 1) || |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 260 | fclose (fout)) report (R_FATAL, "Failed to write file %s.", |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 261 | test->exename); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 264 | /* Run a command for MS milliseconds. If OUT != NULL, also redirect |
| 265 | stdout to there. |
| 266 | |
| 267 | Return the exit status, -2 if can't create process or the return |
| 268 | value of WaitForSingleObject. |
| 269 | */ |
| 270 | int |
| 271 | run_ex (char *cmd, const char *out, DWORD ms) |
| 272 | { |
| 273 | STARTUPINFO si; |
| 274 | PROCESS_INFORMATION pi; |
| 275 | int fd, oldstdout = -1; |
| 276 | DWORD wait, status; |
| 277 | |
| 278 | GetStartupInfo (&si); |
| 279 | si.wShowWindow = SW_HIDE; |
| 280 | si.dwFlags = STARTF_USESHOWWINDOW; |
| 281 | |
| 282 | if (out) { |
| 283 | fd = open (out, O_WRONLY | O_CREAT, 0666); |
| 284 | if (-1 == fd) |
| 285 | report (R_FATAL, "Can't open '%s': %d", out, errno); |
| 286 | oldstdout = dup (1); |
| 287 | if (-1 == oldstdout) |
| 288 | report (R_FATAL, "Can't save stdout: %d", errno); |
| 289 | if (-1 == dup2 (fd, 1)) |
| 290 | report (R_FATAL, "Can't redirect stdout: %d", errno); |
| 291 | close (fd); |
| 292 | } |
| 293 | |
| 294 | if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, 0, |
| 295 | NULL, NULL, &si, &pi)) { |
| 296 | status = -2; |
| 297 | } else { |
| 298 | CloseHandle (pi.hThread); |
| 299 | wait = WaitForSingleObject (pi.hProcess, ms); |
| 300 | if (wait == WAIT_OBJECT_0) { |
| 301 | GetExitCodeProcess (pi.hProcess, &status); |
| 302 | } else { |
| 303 | switch (wait) { |
| 304 | case WAIT_FAILED: |
| 305 | report (R_ERROR, "Wait for '%s' failed: %d", cmd, |
| 306 | GetLastError ()); |
| 307 | break; |
| 308 | case WAIT_TIMEOUT: |
| 309 | report (R_ERROR, "Process '%s' timed out.", cmd); |
| 310 | break; |
| 311 | default: |
| 312 | report (R_ERROR, "Wait returned %d", wait); |
| 313 | } |
| 314 | status = wait; |
| 315 | if (!TerminateProcess (pi.hProcess, 257)) |
| 316 | report (R_ERROR, "TerminateProcess failed: %d", |
| 317 | GetLastError ()); |
| 318 | wait = WaitForSingleObject (pi.hProcess, 5000); |
| 319 | switch (wait) { |
| 320 | case WAIT_FAILED: |
| 321 | report (R_ERROR, |
| 322 | "Wait for termination of '%s' failed: %d", |
| 323 | cmd, GetLastError ()); |
| 324 | break; |
| 325 | case WAIT_OBJECT_0: |
| 326 | break; |
| 327 | case WAIT_TIMEOUT: |
| 328 | report (R_ERROR, "Can't kill process '%s'", cmd); |
| 329 | break; |
| 330 | default: |
| 331 | report (R_ERROR, "Waiting for termination: %d", |
| 332 | wait); |
| 333 | } |
| 334 | } |
| 335 | CloseHandle (pi.hProcess); |
| 336 | } |
| 337 | |
| 338 | if (out) { |
| 339 | close (1); |
| 340 | if (-1 == dup2 (oldstdout, 1)) |
| 341 | report (R_FATAL, "Can't recover stdout: %d", errno); |
| 342 | close (oldstdout); |
| 343 | } |
| 344 | return status; |
| 345 | } |
| 346 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 347 | void |
| 348 | get_subtests (const char *tempdir, struct wine_test *test, int id) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 349 | { |
| 350 | char *subname; |
| 351 | FILE *subfile; |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 352 | size_t total; |
| 353 | char buffer[8192], *index; |
Francois Gouget | cfc3943 | 2004-05-04 04:13:05 +0000 | [diff] [blame] | 354 | static const char header[] = "Valid test names:"; |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 355 | int allocated; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 356 | |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 357 | test->subtest_count = 0; |
| 358 | |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 359 | subname = tempnam (0, "sub"); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 360 | if (!subname) report (R_FATAL, "Can't name subtests file."); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 361 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 362 | extract_test (test, tempdir, id); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 363 | run_ex (test->exename, subname, 5000); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 364 | |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 365 | subfile = fopen (subname, "r"); |
| 366 | if (!subfile) { |
| 367 | report (R_ERROR, "Can't open subtests output of %s: %d", |
| 368 | test->name, errno); |
| 369 | goto quit; |
| 370 | } |
| 371 | total = fread (buffer, 1, sizeof buffer, subfile); |
| 372 | fclose (subfile); |
| 373 | if (sizeof buffer == total) { |
| 374 | report (R_ERROR, "Subtest list of %s too big.", |
| 375 | test->name, sizeof buffer); |
| 376 | goto quit; |
| 377 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 378 | buffer[total] = 0; |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 379 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 380 | index = strstr (buffer, header); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 381 | if (!index) { |
| 382 | report (R_ERROR, "Can't parse subtests output of %s", |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 383 | test->name); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 384 | goto quit; |
| 385 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 386 | index += sizeof header; |
| 387 | |
| 388 | allocated = 10; |
| 389 | test->subtests = xmalloc (allocated * sizeof(char*)); |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 390 | index = strtok (index, whitespace); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 391 | while (index) { |
| 392 | if (test->subtest_count == allocated) { |
| 393 | allocated *= 2; |
| 394 | test->subtests = xrealloc (test->subtests, |
| 395 | allocated * sizeof(char*)); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 396 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 397 | test->subtests[test->subtest_count++] = strdup (index); |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 398 | index = strtok (NULL, whitespace); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 399 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 400 | test->subtests = xrealloc (test->subtests, |
| 401 | test->subtest_count * sizeof(char*)); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 402 | |
| 403 | quit: |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 404 | if (remove (subname)) |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 405 | report (R_WARNING, "Can't delete file '%s': %d", |
| 406 | subname, errno); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 407 | free (subname); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 410 | void |
| 411 | run_test (struct wine_test* test, const char* subtest) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 412 | { |
| 413 | int status; |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 414 | const char* file = get_test_source_file(test->name, subtest); |
| 415 | const char* rev = get_file_rev(file); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 416 | char *cmd = strmake (NULL, "%s %s", test->exename, subtest); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 417 | |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 418 | xprintf ("%s:%s start %s %s\n", test->name, subtest, file, rev); |
Ferenc Wagner | 90baafe | 2004-04-20 04:00:07 +0000 | [diff] [blame] | 419 | status = run_ex (cmd, NULL, 120000); |
| 420 | free (cmd); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 421 | xprintf ("%s:%s done (%d)\n", test->name, subtest, status); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 422 | } |
| 423 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 424 | BOOL CALLBACK |
| 425 | EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType, |
| 426 | LPTSTR lpszName, LONG_PTR lParam) |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 427 | { |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 428 | (*(int*)lParam)++; |
| 429 | return TRUE; |
| 430 | } |
| 431 | |
Ferenc Wagner | 8c4a4df | 2004-02-20 19:56:29 +0000 | [diff] [blame] | 432 | char * |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 433 | run_tests (char *logname) |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 434 | { |
| 435 | int nr_of_files = 0, nr_of_tests = 0, i; |
Ferenc Wagner | 96812eb | 2005-03-29 19:51:49 +0000 | [diff] [blame] | 436 | char *tempdir, *shorttempdir; |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 437 | int logfile; |
| 438 | char *strres, *eol, *nextline; |
| 439 | DWORD strsize; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 440 | |
Ferenc Wagner | f8dba77 | 2004-07-06 21:03:22 +0000 | [diff] [blame] | 441 | SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 442 | |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 443 | if (!logname) { |
| 444 | logname = tempnam (0, "res"); |
| 445 | if (!logname) report (R_FATAL, "Can't name logfile."); |
| 446 | } |
| 447 | report (R_OUT, logname); |
| 448 | |
| 449 | logfile = open (logname, O_WRONLY | O_CREAT | O_EXCL | O_APPEND, |
| 450 | 0666); |
| 451 | if (-1 == logfile) { |
| 452 | if (EEXIST == errno) |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 453 | report (R_FATAL, "File %s already exists.", logname); |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 454 | else report (R_FATAL, "Could not open logfile: %d", errno); |
| 455 | } |
| 456 | if (-1 == dup2 (logfile, 1)) |
| 457 | report (R_FATAL, "Can't redirect stdout: %d", errno); |
| 458 | close (logfile); |
| 459 | |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 460 | tempdir = tempnam (0, "wct"); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 461 | if (!tempdir) |
| 462 | report (R_FATAL, "Can't name temporary dir (check %%TEMP%%)."); |
Ferenc Wagner | 96812eb | 2005-03-29 19:51:49 +0000 | [diff] [blame] | 463 | shorttempdir = strdup (tempdir); |
| 464 | if (shorttempdir) { /* try stable path for ZoneAlarm */ |
| 465 | strstr (shorttempdir, "wct")[3] = 0; |
| 466 | if (CreateDirectoryA (shorttempdir, NULL)) { |
| 467 | free (tempdir); |
| 468 | tempdir = shorttempdir; |
| 469 | } else free (shorttempdir); |
| 470 | } |
| 471 | if (tempdir != shorttempdir && !CreateDirectoryA (tempdir, NULL)) |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 472 | report (R_FATAL, "Could not create directory: %s", tempdir); |
Ferenc Wagner | 96812eb | 2005-03-29 19:51:49 +0000 | [diff] [blame] | 473 | report (R_DIR, tempdir); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 474 | |
Ferenc Wagner | 1fb75dc | 2004-04-22 23:43:54 +0000 | [diff] [blame] | 475 | xprintf ("Version 3\n"); |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 476 | strres = extract_rcdata (WINE_BUILD, STRINGRES, &strsize); |
| 477 | xprintf ("Tests from build "); |
| 478 | if (strres) xprintf ("%.*s", strsize, strres); |
| 479 | else xprintf ("-\n"); |
| 480 | strres = extract_rcdata (TESTS_URL, STRINGRES, &strsize); |
| 481 | xprintf ("Archive: "); |
| 482 | if (strres) xprintf ("%.*s", strsize, strres); |
| 483 | else xprintf ("-\n"); |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 484 | xprintf ("Tag: %s\n", tag); |
Ferenc Wagner | 21b8503 | 2004-04-23 02:52:21 +0000 | [diff] [blame] | 485 | xprintf ("Build info:\n"); |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 486 | strres = extract_rcdata (BUILD_INFO, STRINGRES, &strsize); |
| 487 | while (strres) { |
| 488 | eol = memchr (strres, '\n', strsize); |
| 489 | if (!eol) { |
| 490 | nextline = NULL; |
| 491 | eol = strres + strsize; |
| 492 | } else { |
| 493 | strsize -= eol - strres + 1; |
| 494 | nextline = strsize?eol+1:NULL; |
| 495 | if (eol > strres && *(eol-1) == '\r') eol--; |
| 496 | } |
| 497 | xprintf (" %.*s\n", eol-strres, strres); |
| 498 | strres = nextline; |
| 499 | } |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 500 | xprintf ("Operating system version:\n"); |
| 501 | print_version (); |
| 502 | xprintf ("Test output:\n" ); |
| 503 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 504 | report (R_STATUS, "Counting tests"); |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 505 | if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES), |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 506 | EnumTestFileProc, (LPARAM)&nr_of_files)) |
| 507 | report (R_FATAL, "Can't enumerate test files: %d", |
| 508 | GetLastError ()); |
| 509 | wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 510 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 511 | report (R_STATUS, "Extracting tests"); |
Ferenc Wagner | feaad96 | 2004-02-21 04:01:56 +0000 | [diff] [blame] | 512 | report (R_PROGRESS, 0, nr_of_files); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 513 | for (i = 0; i < nr_of_files; i++) { |
Ferenc Wagner | 24624f6 | 2004-06-15 22:45:15 +0000 | [diff] [blame] | 514 | get_subtests (tempdir, wine_tests+i, i); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 515 | nr_of_tests += wine_tests[i].subtest_count; |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 516 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 517 | report (R_DELTA, 0, "Extracting: Done"); |
| 518 | |
| 519 | report (R_STATUS, "Running tests"); |
Ferenc Wagner | feaad96 | 2004-02-21 04:01:56 +0000 | [diff] [blame] | 520 | report (R_PROGRESS, 1, nr_of_tests); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 521 | for (i = 0; i < nr_of_files; i++) { |
| 522 | struct wine_test *test = wine_tests + i; |
| 523 | int j; |
| 524 | |
| 525 | for (j = 0; j < test->subtest_count; j++) { |
Ferenc Wagner | 8387770 | 2004-03-19 01:54:10 +0000 | [diff] [blame] | 526 | report (R_STEP, "Running: %s:%s", test->name, |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 527 | test->subtests[j]); |
| 528 | run_test (test, test->subtests[j]); |
| 529 | } |
| 530 | } |
| 531 | report (R_DELTA, 0, "Running: Done"); |
| 532 | |
| 533 | report (R_STATUS, "Cleaning up"); |
| 534 | close (1); |
| 535 | remove_dir (tempdir); |
| 536 | free (tempdir); |
| 537 | free (wine_tests); |
| 538 | |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 539 | return logname; |
| 540 | } |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 541 | |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 542 | void |
| 543 | usage () |
| 544 | { |
| 545 | fprintf (stderr, "\ |
| 546 | Usage: winetest [OPTION]...\n\n\ |
| 547 | -c console mode, no GUI\n\ |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 548 | -e preserve the environment\n\ |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 549 | -h print this message and exit\n\ |
| 550 | -q quiet mode, no output at all\n\ |
| 551 | -o FILE put report into FILE, do not submit\n\ |
| 552 | -s FILE submit FILE, do not run tests\n\ |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 553 | -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"); |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 554 | } |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 555 | |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 556 | int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, |
| 557 | LPSTR cmdLine, int cmdShow) |
| 558 | { |
Ferenc Wagner | 8c4a4df | 2004-02-20 19:56:29 +0000 | [diff] [blame] | 559 | char *logname = NULL; |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 560 | const char *cp, *submit = NULL; |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 561 | int reset_env = 1; |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 562 | int interactive = 1; |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 563 | |
Dimitrie O. Paun | cbe0e49 | 2004-03-20 19:21:39 +0000 | [diff] [blame] | 564 | /* initialize the revision information first */ |
| 565 | extract_rev_infos(); |
| 566 | |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 567 | cmdLine = strtok (cmdLine, whitespace); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 568 | while (cmdLine) { |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 569 | if (cmdLine[0] != '-' || cmdLine[2]) { |
| 570 | report (R_ERROR, "Not a single letter option: %s", cmdLine); |
| 571 | usage (); |
| 572 | exit (2); |
| 573 | } |
| 574 | switch (cmdLine[1]) { |
| 575 | case 'c': |
| 576 | report (R_TEXTMODE); |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 577 | interactive = 0; |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 578 | break; |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 579 | case 'e': |
| 580 | reset_env = 0; |
| 581 | break; |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 582 | case 'h': |
| 583 | usage (); |
| 584 | exit (0); |
| 585 | case 'q': |
| 586 | report (R_QUIET); |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 587 | interactive = 0; |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 588 | break; |
| 589 | case 's': |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 590 | submit = strtok (NULL, whitespace); |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 591 | if (tag) |
| 592 | report (R_WARNING, "ignoring tag for submission"); |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 593 | send_file (submit); |
| 594 | break; |
| 595 | case 'o': |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 596 | logname = strtok (NULL, whitespace); |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 597 | break; |
| 598 | case 't': |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 599 | tag = strtok (NULL, whitespace); |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 600 | cp = badtagchar (tag); |
| 601 | if (cp) { |
| 602 | report (R_ERROR, "invalid char in tag: %c", *cp); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 603 | usage (); |
| 604 | exit (2); |
| 605 | } |
Ferenc Wagner | a122499 | 2004-03-24 23:40:06 +0000 | [diff] [blame] | 606 | break; |
| 607 | default: |
| 608 | report (R_ERROR, "invalid option: -%c", cmdLine[1]); |
| 609 | usage (); |
| 610 | exit (2); |
| 611 | } |
Ferenc Wagner | cb10a70 | 2004-09-07 19:33:52 +0000 | [diff] [blame] | 612 | cmdLine = strtok (NULL, whitespace); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 613 | } |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 614 | if (!submit) { |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 615 | report (R_STATUS, "Starting up"); |
| 616 | |
| 617 | if (!running_on_visible_desktop ()) |
| 618 | report (R_FATAL, "Tests must be run on a visible desktop"); |
Ferenc Wagner | a703343 | 2005-03-25 17:11:52 +0000 | [diff] [blame] | 619 | |
Ferenc Wagner | 2d0d484 | 2004-07-22 23:42:03 +0000 | [diff] [blame] | 620 | if (reset_env && (putenv ("WINETEST_PLATFORM=windows") || |
| 621 | putenv ("WINETEST_DEBUG=1") || |
| 622 | putenv ("WINETEST_INTERACTIVE=0") || |
| 623 | putenv ("WINETEST_REPORT_SUCCESS=0"))) |
| 624 | report (R_FATAL, "Could not reset environment: %d", errno); |
| 625 | |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 626 | if (!tag) { |
| 627 | if (!interactive) |
| 628 | report (R_FATAL, "Please specify a tag (-t option) if " |
| 629 | "running noninteractive!"); |
| 630 | if (guiAskTag () == IDABORT) exit (1); |
| 631 | } |
| 632 | report (R_TAG); |
| 633 | |
Ferenc Wagner | fbf77db | 2004-10-04 19:32:20 +0000 | [diff] [blame] | 634 | if (!logname) { |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 635 | logname = run_tests (NULL); |
Ferenc Wagner | fbf77db | 2004-10-04 19:32:20 +0000 | [diff] [blame] | 636 | if (report (R_ASK, MB_YESNO, "Do you want to submit the " |
| 637 | "test results?") == IDYES) |
| 638 | if (!send_file (logname) && remove (logname)) |
| 639 | report (R_WARNING, "Can't remove logfile: %d.", errno); |
| 640 | free (logname); |
Ferenc Wagner | 30dcc6b | 2005-03-31 15:22:41 +0000 | [diff] [blame^] | 641 | } else run_tests (logname); |
Ferenc Wagner | efc6725 | 2004-02-19 04:12:42 +0000 | [diff] [blame] | 642 | report (R_STATUS, "Finished"); |
| 643 | } |
Ferenc Wagner | 354f662 | 2004-01-15 01:48:05 +0000 | [diff] [blame] | 644 | exit (0); |
Alexandre Julliard | 9f71bd9 | 2003-12-04 02:01:39 +0000 | [diff] [blame] | 645 | } |