commit fea6bf18a105c03509caeae84030eff990baaec5
parent ab406a9e6a0568bcb607ff737397bdc5b0cf533b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 10 Apr 2017 20:00:02 +0300
HTTPS test fixes and improvements:
always skip tests if libcurl do not support HTTPS (instead of failing)
return 99 in case of global errors (MHD-unrelated)
print error result if test if failed
fixed ignored result of epoll test in test_https_get_select
allow compilation by C89 compiler
Diffstat:
13 files changed, 108 insertions(+), 50 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Apr 10 19:50:20 MSK 2017
+ HTTPS tests: skip tests instead of failing if HTTPS is not supported by
+ libcurl.
+ HTTPS tests: fixed return values so testsuite is able to correctly
+ interpret it.
+ Fixed ignored result of epoll test in test_https_get_select. -EG
+
Thu Apr 06 23:02:07 MSK 2017
Make zzuf tests compatible with *BSD platforms. -EG
diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c
@@ -201,10 +201,16 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return -1;
+ return 99;
+ }
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
}
if (0 != (errorCount = testInternalSelectGet ()))
- fprintf (stderr, "Fail: %d\n", errorCount);
+ fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
curl_global_cleanup ();
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c
@@ -109,7 +109,13 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return -1;
+ return 99;
+ }
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
}
if (curl_uses_nss_ssl() == 0)
@@ -126,5 +132,5 @@ main (int argc, char *const *argv)
curl_global_cleanup ();
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c
@@ -142,11 +142,16 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return -1;
+ return 99;
}
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ return 77;
+ }
if (curl_uses_nss_ssl() == 0)
- aes256_sha = "rsa_aes_256_sha";
+ aes256_sha = "rsa_aes_256_sha";
#ifdef EPOLL_SUPPORT
errorCount +=
test_wrap ("single threaded daemon, single client, epoll", &test_single_client,
@@ -181,5 +186,7 @@ main (int argc, char *const *argv)
srv_self_signed_cert_pem, MHD_OPTION_END);
curl_global_cleanup ();
- return errorCount != 0;
+ if (errorCount != 0)
+ fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c
@@ -144,21 +144,23 @@ main (int argc, char *const *argv)
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
srand (iseed);
- ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
- if (NULL == ssl_version)
- {
- fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
- return 0;
- }
- if (0 != strncmp (ssl_version, "GnuTLS", 6))
- {
- fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
- return 0;
- }
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return -1;
+ return 99;
+ }
+ ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
+ if (0 != strncmp (ssl_version, "GnuTLS", 6))
+ {
+ fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
+ curl_global_cleanup ();
+ return 77;
+ }
+ if (NULL == ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
}
char *aes256_sha = "AES256-SHA";
@@ -184,8 +186,8 @@ main (int argc, char *const *argv)
srv_self_signed_cert_pem, MHD_OPTION_END);
if (errorCount != 0)
- fprintf (stderr, "Failed test: %s.\n", argv[0]);
+ fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
curl_global_cleanup ();
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c
@@ -230,14 +230,21 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return -1;
+ return 99;
}
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
+ }
+
#ifdef EPOLL_SUPPORT
- if (0 != (errorCount = testExternalGet (MHD_USE_EPOLL)))
- fprintf (stderr, "Fail: %d\n", errorCount);
+ errorCount += testExternalGet (MHD_USE_EPOLL);
#endif
- if (0 != (errorCount = testExternalGet (0)))
- fprintf (stderr, "Fail: %d\n", errorCount);
+ errorCount += testExternalGet (0);
curl_global_cleanup ();
- return errorCount != 0;
+ if (errorCount != 0)
+ fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount);
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c
@@ -96,6 +96,7 @@ main (int argc, char *const *argv)
{
unsigned int errorCount = 0;
FILE *cert;
+ const char *aes256_sha = "AES256-SHA";
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
@@ -105,20 +106,26 @@ main (int argc, char *const *argv)
{
fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__,
__FUNCTION__);
- return -1;
+ return 99;
+ }
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
}
if ((cert = setup_ca_cert ()) == NULL)
{
fprintf (stderr, MHD_E_TEST_FILE_CREAT);
- return -1;
+ curl_global_cleanup ();
+ return 99;
}
- const char *aes256_sha = "AES256-SHA";
if (curl_uses_nss_ssl() == 0)
{
aes256_sha = "rsa_aes_256_sha";
}
-
+
errorCount +=
test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);
@@ -130,5 +137,5 @@ main (int argc, char *const *argv)
fprintf (stderr,
"Failed to remove `%s'\n",
ca_cert_file_name);
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
@@ -180,18 +180,20 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error (code: %u)\n", errorCount);
- return -1;
+ return 99;
}
ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version;
if (NULL == ssl_version)
{
fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
return 77;
}
if (0 != strncmp (ssl_version, "GnuTLS", 6))
{
fprintf (stderr, "This test can be run only with libcurl-gnutls.\n");
+ curl_global_cleanup ();
return 77;
}
#if LIBCURL_VERSION_NUM >= 0x072200
@@ -199,7 +201,5 @@ main (int argc, char *const *argv)
#endif
print_test_result (errorCount, argv[0]);
curl_global_cleanup ();
- if (errorCount > 0)
- fprintf (stderr, "Error (code: %u)\n", errorCount);
- return errorCount;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_sni.c b/src/testcurl/https/test_https_sni.c
@@ -256,8 +256,15 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
+ return 99;
+ }
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
return 77;
}
+
load_keys ("host1", ABS_SRCDIR "/host1.crt", ABS_SRCDIR "/host1.key");
load_keys ("host2", ABS_SRCDIR "/host2.crt", ABS_SRCDIR "/host2.key");
d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG,
@@ -278,6 +285,8 @@ main (int argc, char *const *argv)
MHD_stop_daemon (d);
curl_global_cleanup ();
+ if (error_count != 0)
+ fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], error_count);
return (0 != error_count) ? 1 : 0;
}
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c
@@ -143,5 +143,5 @@ main (int argc, char *const *argv)
MHD_stop_daemon (d);
gnutls_global_deinit ();
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c
@@ -73,24 +73,31 @@ int
main (int argc, char *const *argv)
{
unsigned int errorCount = 0;
+ char *aes256_sha = "AES256-SHA";
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
#ifdef GCRYCTL_INITIALIZATION_FINISHED
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
- if (setup_ca_cert () == NULL)
+ if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
- fprintf (stderr, MHD_E_TEST_FILE_CREAT);
- return -1;
+ fprintf (stderr, "Error (code: %u)\n", errorCount);
+ return 99;
+ }
+ if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
+ {
+ fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
+ curl_global_cleanup ();
+ return 77;
}
- if (0 != curl_global_init (CURL_GLOBAL_ALL))
+ if (setup_ca_cert () == NULL)
{
- fprintf (stderr, "Error (code: %u)\n", errorCount);
- return -1;
+ fprintf (stderr, MHD_E_TEST_FILE_CREAT);
+ curl_global_cleanup ();
+ return 99;
}
- char *aes256_sha = "AES256-SHA";
if (curl_uses_nss_ssl() == 0)
{
aes256_sha = "rsa_aes_256_sha";
@@ -106,5 +113,5 @@ main (int argc, char *const *argv)
fprintf (stderr,
"Failed to remove `%s'\n",
ca_cert_file_name);
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c
@@ -109,7 +109,7 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_ALL))
{
fprintf (stderr, "Error: %s\n", strerror (errno));
- return 77;
+ return 99;
}
const char *aes128_sha = "AES128-SHA";
@@ -151,5 +151,5 @@ main (int argc, char *const *argv)
}
curl_global_cleanup ();
- return errorCount != 0;
+ return errorCount != 0 ? 1 : 0;
}
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
@@ -139,9 +139,9 @@ test_daemon_get (void *cls,
void
print_test_result (int test_outcome, char *test_name)
{
-#if 0
if (test_outcome != 0)
- fprintf (stderr, "running test: %s [fail]\n", test_name);
+ fprintf (stderr, "running test: %s [fail: %u]\n", test_name, (unsigned int)test_outcome);
+#if 0
else
fprintf (stdout, "running test: %s [pass]\n", test_name);
#endif