mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-29 04:09:31 +03:00
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
This commit is contained in:
13 files changed
+109
-51
No files matched your search
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
fprintf (stderr, MHD_E_TEST_FILE_CREAT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != curl_global_init (CURL_GLOBAL_ALL))
|
||||
{
|
||||
fprintf (stderr, "Error (code: %u)\n", errorCount);
|
||||
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 (setup_ca_cert () == NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user