Module: wine Branch: master Commit: 0d50168570e77f917abbefd16a7209ae3644741a URL: http://source.winehq.org/git/wine.git/?a=commit;h=0d50168570e77f917abbefd16a...
Author: Hans Leidekker hans@codeweavers.com Date: Tue Dec 9 12:44:38 2014 +0100
winhttp/tests: Handle more potential connection failures.
---
dlls/winhttp/tests/notification.c | 36 ++++++++++++++++++++++++++++++++++++ dlls/winhttp/tests/winhttp.c | 13 +++---------- 2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index ffbea03..e14af6d 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -186,6 +186,11 @@ static void test_connection_cache( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError());
setup_test( &info, winhttp_receive_response, __LINE__ ); @@ -209,6 +214,11 @@ static void test_connection_cache( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError());
setup_test( &info, winhttp_receive_response, __LINE__ ); @@ -253,6 +263,11 @@ static void test_connection_cache( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError());
setup_test( &info, winhttp_receive_response, __LINE__ ); @@ -276,6 +291,11 @@ static void test_connection_cache( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError());
setup_test( &info, winhttp_receive_response, __LINE__ ); @@ -288,6 +308,7 @@ static void test_connection_cache( void ) ok(status == 200, "request failed unexpectedly %u\n", status);
setup_test( &info, winhttp_close_handle, __LINE__ ); +done: WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses ); @@ -353,6 +374,11 @@ static void test_redirect( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError());
setup_test( &info, winhttp_receive_response, __LINE__ ); @@ -365,6 +391,7 @@ static void test_redirect( void ) ok(status == 200, "request failed unexpectedly %u\n", status);
setup_test( &info, winhttp_close_handle, __LINE__ ); +done: WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses ); @@ -435,6 +462,15 @@ static void test_async( void )
setup_test( &info, winhttp_send_request, __LINE__ ); ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + WinHttpCloseHandle( req ); + WinHttpCloseHandle( con ); + WinHttpCloseHandle( ses ); + CloseHandle( info.wait ); + return; + } ok(ret, "failed to send request %u\n", GetLastError());
WaitForSingleObject( info.wait, INFINITE ); diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 1c56923..eda83e4 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -954,7 +954,7 @@ static void test_request_parameter_defaults(void) ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); - if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + if (!ret && (GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT || GetLastError() == ERROR_WINHTTP_TIMEOUT)) { skip("connection failed, skipping\n"); goto done; @@ -3044,12 +3044,8 @@ static void test_WinHttpGetProxyForUrl(void) options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DNS_A;
memset( &info, 0, sizeof(info) ); - SetLastError(0xdeadbeef); ret = WinHttpGetProxyForUrl( session, urlW, &options, &info ); - error = GetLastError(); - if (!ret) ok( error == ERROR_WINHTTP_AUTODETECTION_FAILED || - error == ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT, "got %u\n", error ); - else + if (ret) { trace("Proxy.AccessType=%u\n", info.dwAccessType); trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy)); @@ -3063,11 +3059,8 @@ static void test_WinHttpGetProxyForUrl(void) options.lpszAutoConfigUrl = wpadW;
memset( &info, 0, sizeof(info) ); - SetLastError(0xdeadbeef); ret = WinHttpGetProxyForUrl( session, urlW, &options, &info ); - error = GetLastError(); - if (!ret) ok( error == ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT, "got %u\n", error ); - else + if (ret) { trace("Proxy.AccessType=%u\n", info.dwAccessType); trace("Proxy.Proxy=%s\n", wine_dbgstr_w(info.lpszProxy));