winetest: Allow sending the report to another server.

This makes it possible to send the reports to both the official server
and a test server.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2017-02-10 16:42:48 +01:00 committed by Alexandre Julliard
parent 8d3af56904
commit a83c650362
3 changed files with 71 additions and 15 deletions

View File

@ -1227,6 +1227,7 @@ usage (void)
" -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"
" -S URL URL to submit the results to\n"
" -t TAG include TAG of characters [-.0-9a-zA-Z] in the report\n"
" -u URL include TestBot URL in the report\n"
" -x DIR Extract tests to DIR (default: .\\wct) and exit\n");
@ -1237,7 +1238,7 @@ int main( int argc, char *argv[] )
BOOL (WINAPI *pIsWow64Process)(HANDLE hProcess, PBOOL Wow64Process);
char *logname = NULL, *outdir = NULL;
const char *extract = NULL;
const char *cp, *submit = NULL;
const char *cp, *submit = NULL, *submiturl = NULL;
int reset_env = 1;
int poweroff = 0;
int interactive = 1;
@ -1308,9 +1309,13 @@ int main( int argc, char *argv[] )
usage();
exit( 2 );
}
if (tag)
report (R_WARNING, "ignoring tag for submission");
send_file (submit);
break;
case 'S':
if (!(submiturl = argv[++i]))
{
usage();
exit( 2 );
}
break;
case 'o':
if (!(logname = argv[++i]))
@ -1358,7 +1363,12 @@ int main( int argc, char *argv[] )
exit (2);
}
}
if (!submit && !extract) {
if (submit) {
if (tag)
report (R_WARNING, "ignoring tag for submission");
send_file (submiturl, submit);
} else if (!extract) {
int is_win9x = (GetVersion() & 0x80000000) != 0;
report (R_STATUS, "Starting up");
@ -1424,7 +1434,7 @@ int main( int argc, char *argv[] )
if (build_id[0] && nr_of_skips <= SKIP_LIMIT && failures <= FAILURES_LIMIT &&
!nr_native_dlls && !is_win9x &&
report (R_ASK, MB_YESNO, "Do you want to submit the test results?") == IDYES)
if (!send_file (logname) && !DeleteFileA(logname))
if (!send_file (submiturl, logname) && !DeleteFileA(logname))
report (R_WARNING, "Can't remove logfile: %u", GetLastError());
} else run_tests (logname, outdir);
report (R_STATUS, "Finished - %u failures", failures);

View File

@ -121,7 +121,7 @@ send_str (SOCKET s, ...)
}
static int
send_file_direct (const char *name)
send_file_direct (const char * url, const char *name)
{
SOCKET s;
HANDLE file;
@ -139,6 +139,11 @@ send_file_direct (const char *name)
CONTENT_HEADERS
"\r\n";
if (url) {
report (R_WARNING, "Can't submit to an alternative URL");
return 0;
}
s = open_http (SERVER_NAME);
if (s == INVALID_SOCKET) return 1;
@ -243,7 +248,7 @@ send_file_direct (const char *name)
}
static int
send_file_wininet (const char *name)
send_file_wininet (const char *url, const char *name)
{
int ret = 0;
HMODULE wininet_mod = NULL;
@ -264,6 +269,7 @@ send_file_wininet (const char *name)
HINTERNET request = NULL;
INTERNET_BUFFERSA buffers_in = { 0 };
char buffer[BUFLEN+1];
URL_COMPONENTSA uc = { 0 };
static const char extra_headers[] =
CONTENT_HEADERS;
@ -283,6 +289,38 @@ send_file_wininet (const char *name)
pInternetWriteFile == NULL || pInternetReadFile == NULL || pInternetCloseHandle == NULL) {
goto done;
}
if (url) {
BOOL (WINAPI *pInternetCrackUrlA)(const char *url, DWORD url_length, DWORD flags, URL_COMPONENTSA *ret_comp);
pInternetCrackUrlA = (void *)GetProcAddress(wininet_mod, "InternetCrackUrlA");
if (pInternetCrackUrlA == NULL)
goto done;
uc.dwStructSize = sizeof(uc);
uc.dwSchemeLength = uc.dwHostNameLength = uc.dwUserNameLength =
uc.dwPasswordLength = uc.dwUrlPathLength = uc.dwExtraInfoLength =
strlen(url) + 1;
uc.lpszScheme = heap_alloc (uc.dwSchemeLength);
uc.lpszHostName = heap_alloc (uc.dwHostNameLength);
uc.lpszUserName = heap_alloc (uc.dwUserNameLength);
uc.lpszPassword = heap_alloc (uc.dwPasswordLength);
uc.lpszUrlPath = heap_alloc (uc.dwUrlPathLength);
uc.lpszExtraInfo = heap_alloc (uc.dwExtraInfoLength);
if (!pInternetCrackUrlA(url, 0, 0, &uc)) {
report (R_WARNING, "Can't parse submit URL '%s'", url);
goto done;
}
if ((uc.nScheme != INTERNET_SCHEME_HTTP && uc.nScheme != INTERNET_SCHEME_HTTPS) || *uc.lpszExtraInfo) {
report (R_WARNING, "Can't submit report to scheme %s or extra info '%s'", uc.lpszScheme, uc.lpszExtraInfo);
goto done;
}
} else {
uc.nScheme = INTERNET_SCHEME_HTTP;
uc.lpszHostName = heap_strdup (SERVER_NAME);
uc.nPort = INTERNET_DEFAULT_HTTP_PORT;
uc.lpszUserName = heap_strdup ("");
uc.lpszPassword = heap_strdup ("");
uc.lpszUrlPath = heap_strdup (URL_PATH);
}
ret = 1;
@ -310,20 +348,22 @@ send_file_wininet (const char *name)
filesize = 1.5*1024*1024;
}
report (R_STATUS, "Opening HTTP connection to " SERVER_NAME);
report (R_STATUS, "Opening %s connection to %s:%d",
(uc.nScheme == INTERNET_SCHEME_HTTP ? "http" : "https"),
uc.lpszHostName, uc.nPort);
session = pInternetOpen (USER_AGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (session == NULL) {
report (R_WARNING, "Unable to open connection, error %u", GetLastError());
goto done;
}
connection = pInternetConnect (session, SERVER_NAME, INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0);
connection = pInternetConnect (session, uc.lpszHostName, uc.nPort, uc.lpszUserName, uc.lpszPassword, INTERNET_SERVICE_HTTP, 0, 0);
if (connection == NULL) {
report (R_WARNING, "Unable to connect, error %u", GetLastError());
goto done;
}
request = pHttpOpenRequest (connection, "POST", URL_PATH, NULL, NULL, NULL,
request = pHttpOpenRequest (connection, "POST", uc.lpszUrlPath, NULL, NULL, NULL,
INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI |
INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0);
INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD | (uc.nScheme == INTERNET_SCHEME_HTTPS ? INTERNET_FLAG_SECURE : 0), 0);
if (request == NULL) {
report (R_WARNING, "Unable to open request, error %u", GetLastError());
goto done;
@ -396,6 +436,12 @@ send_file_wininet (const char *name)
}
done:
heap_free (uc.lpszScheme);
heap_free (uc.lpszHostName);
heap_free (uc.lpszUserName);
heap_free (uc.lpszPassword);
heap_free (uc.lpszUrlPath);
heap_free (uc.lpszExtraInfo);
heap_free((void *)buffers_in.lpcszHeader);
heap_free(str);
if (pInternetCloseHandle != NULL && request != NULL)
@ -413,7 +459,7 @@ send_file_wininet (const char *name)
}
int
send_file (const char *name)
send_file (const char *url, const char *name)
{
return send_file_wininet( name ) || send_file_direct( name );
return send_file_wininet( url, name ) || send_file_direct( url, name );
}

View File

@ -34,7 +34,7 @@ char *strmake (size_t *lenp, ...);
int goodtagchar (char c);
const char *findbadtagchar (const char *tag);
int send_file (const char *name);
int send_file (const char *url, const char *name);
extern HANDLE logfile;