libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 81a04f09ce93a13f717d0029c05736bb56672eb2
parent e7cd19c3419eaf2c8ed6a4b9b4749836915b8edb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 20 Jul 2013 10:03:53 +0000

-expanded HTTPS testcases to also cover epoll

Diffstat:
Msrc/testcurl/https/test_https_get.c | 26++++++++++++++++----------
Msrc/testcurl/https/test_https_get_parallel.c | 31++++++++++++++++++++++++-------
Msrc/testcurl/https/test_https_get_select.c | 19+++++++++++--------
3 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c @@ -19,7 +19,7 @@ */ /** - * @file mhds_get_test.c + * @file test_https_get.c * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir */ @@ -37,8 +37,11 @@ extern const char srv_self_signed_cert_pem[]; extern const char srv_signed_cert_pem[]; extern const char srv_signed_key_pem[]; + static int -test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version) +test_cipher_option (FILE * test_fd, + const char *cipher_suite, + int proto_version) { int ret; @@ -62,9 +65,12 @@ test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version) return ret; } + /* perform a HTTP GET request via SSL/TLS */ -int -test_secure_get (FILE * test_fd, char *cipher_suite, int proto_version) +static int +test_secure_get (FILE * test_fd, + const char *cipher_suite, + int proto_version) { int ret; struct MHD_Daemon *d; @@ -88,10 +94,15 @@ test_secure_get (FILE * test_fd, char *cipher_suite, int proto_version) return ret; } + int main (int argc, char *const *argv) { unsigned int errorCount = 0; + const char *aes256_sha_tlsv1 = "AES256-SHA"; + const char *aes256_sha_sslv3 = "AES256-SHA"; + const char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA"; + if (!gcry_check_version (GCRYPT_VERSION)) abort (); @@ -101,13 +112,9 @@ main (int argc, char *const *argv) return -1; } - char *aes256_sha_tlsv1 = "AES256-SHA"; - char *aes256_sha_sslv3 = "AES256-SHA"; - char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA"; - if (curl_uses_nss_ssl() == 0) { - aes256_sha_tlsv1 = "rsa_aes_256_sha"; + aes256_sha_tlsv1 = "rsa_aes_256_sha"; aes256_sha_sslv3 = "rsa_aes_256_sha"; des_cbc3_sha_tlsv1 = "rsa_aes_128_sha"; } @@ -118,7 +125,6 @@ main (int argc, char *const *argv) test_secure_get (NULL, aes256_sha_sslv3, CURL_SSLVERSION_SSLv3); errorCount += test_cipher_option (NULL, des_cbc3_sha_tlsv1, CURL_SSLVERSION_TLSv1); - print_test_result (errorCount, argv[0]); curl_global_cleanup (); diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c @@ -19,7 +19,7 @@ */ /** - * @file tls_thread_mode_test.c + * @file test_https_get_parallel.c * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir * @author Christian Grothoff @@ -38,6 +38,7 @@ extern const char srv_self_signed_cert_pem[]; int curl_check_version (const char *req_version, ...); + /** * used when spawning multiple threads executing curl server requests * @@ -58,6 +59,7 @@ https_transfer_thread_adapter (void *args) return &nonnull; } + /** * Test non-parallel requests. * @@ -79,6 +81,7 @@ test_single_client (void *cls, const char *cipher_suite, return 0; } + /** * Test parallel request handling. * @@ -124,6 +127,7 @@ int main (int argc, char *const *argv) { unsigned int errorCount = 0; + const char *aes256_sha = "AES256-SHA"; /* initialize random seed used by curl clients */ unsigned int iseed = (unsigned int) time (NULL); @@ -135,12 +139,17 @@ main (int argc, char *const *argv) return -1; } - char *aes256_sha = "AES256-SHA"; if (curl_uses_nss_ssl() == 0) - { - aes256_sha = "rsa_aes_256_sha"; - } - + aes256_sha = "rsa_aes_256_sha"; +#if LINUX + errorCount += + test_wrap ("single threaded daemon, single client, epoll", &test_single_client, + NULL, + MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG | MHD_USE_EPOLL_LINUX_ONLY, + aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, + srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, + srv_self_signed_cert_pem, MHD_OPTION_END); +#endif errorCount += test_wrap ("single threaded daemon, single client", &test_single_client, NULL, @@ -148,7 +157,15 @@ main (int argc, char *const *argv) aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); - +#if LINUX + errorCount += + test_wrap ("single threaded daemon, parallel clients, epoll", + &test_parallel_clients, NULL, + MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG | MHD_USE_EPOLL_LINUX_ONLY, + aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, + srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, + srv_self_signed_cert_pem, MHD_OPTION_END); +#endif errorCount += test_wrap ("single threaded daemon, parallel clients", &test_parallel_clients, NULL, diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c @@ -19,7 +19,7 @@ */ /** - * @file mhds_get_test.c + * @file test_https_get_select.c * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir */ @@ -71,8 +71,9 @@ ahc_echo (void *cls, return ret; } + static int -testExternalGet () +testExternalGet (int flags) { struct MHD_Daemon *d; CURL *c; @@ -88,12 +89,13 @@ testExternalGet () struct CURLMsg *msg; time_t start; struct timeval tv; + const char *aes256_sha = "AES256-SHA"; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; - d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL, + d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL | flags, 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, @@ -101,11 +103,8 @@ testExternalGet () if (d == NULL) return 256; - char *aes256_sha = "AES256-SHA"; if (curl_uses_nss_ssl() == 0) - { - aes256_sha = "rsa_aes_256_sha"; - } + aes256_sha = "rsa_aes_256_sha"; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1:1082/hello_world"); @@ -222,7 +221,11 @@ main (int argc, char *const *argv) fprintf (stderr, "Error: %s\n", strerror (errno)); return -1; } - if (0 != (errorCount = testExternalGet ())) +#if LINUX + if (0 != (errorCount = testExternalGet (MHD_USE_EPOLL_LINUX_ONLY))) + fprintf (stderr, "Fail: %d\n", errorCount); +#endif + if (0 != (errorCount = testExternalGet (0))) fprintf (stderr, "Fail: %d\n", errorCount); curl_global_cleanup (); return errorCount != 0;