aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-07-20 10:03:53 +0000
committerChristian Grothoff <christian@grothoff.org>2013-07-20 10:03:53 +0000
commit81a04f09ce93a13f717d0029c05736bb56672eb2 (patch)
tree34532687bcc3b7dcc0174eea3f29e2b9aad59fa3
parente7cd19c3419eaf2c8ed6a4b9b4749836915b8edb (diff)
downloadlibmicrohttpd-81a04f09ce93a13f717d0029c05736bb56672eb2.tar.gz
libmicrohttpd-81a04f09ce93a13f717d0029c05736bb56672eb2.zip
-expanded HTTPS testcases to also cover epoll
-rw-r--r--src/testcurl/https/test_https_get.c26
-rw-r--r--src/testcurl/https/test_https_get_parallel.c31
-rw-r--r--src/testcurl/https/test_https_get_select.c19
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
index f279ac9f..f076cac4 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -19,7 +19,7 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file mhds_get_test.c 22 * @file test_https_get.c
23 * @brief Testcase for libmicrohttpd HTTPS GET operations 23 * @brief Testcase for libmicrohttpd HTTPS GET operations
24 * @author Sagie Amir 24 * @author Sagie Amir
25 */ 25 */
@@ -37,8 +37,11 @@ extern const char srv_self_signed_cert_pem[];
37extern const char srv_signed_cert_pem[]; 37extern const char srv_signed_cert_pem[];
38extern const char srv_signed_key_pem[]; 38extern const char srv_signed_key_pem[];
39 39
40
40static int 41static int
41test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version) 42test_cipher_option (FILE * test_fd,
43 const char *cipher_suite,
44 int proto_version)
42{ 45{
43 46
44 int ret; 47 int ret;
@@ -62,9 +65,12 @@ test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version)
62 return ret; 65 return ret;
63} 66}
64 67
68
65/* perform a HTTP GET request via SSL/TLS */ 69/* perform a HTTP GET request via SSL/TLS */
66int 70static int
67test_secure_get (FILE * test_fd, char *cipher_suite, int proto_version) 71test_secure_get (FILE * test_fd,
72 const char *cipher_suite,
73 int proto_version)
68{ 74{
69 int ret; 75 int ret;
70 struct MHD_Daemon *d; 76 struct MHD_Daemon *d;
@@ -88,10 +94,15 @@ test_secure_get (FILE * test_fd, char *cipher_suite, int proto_version)
88 return ret; 94 return ret;
89} 95}
90 96
97
91int 98int
92main (int argc, char *const *argv) 99main (int argc, char *const *argv)
93{ 100{
94 unsigned int errorCount = 0; 101 unsigned int errorCount = 0;
102 const char *aes256_sha_tlsv1 = "AES256-SHA";
103 const char *aes256_sha_sslv3 = "AES256-SHA";
104 const char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA";
105
95 106
96 if (!gcry_check_version (GCRYPT_VERSION)) 107 if (!gcry_check_version (GCRYPT_VERSION))
97 abort (); 108 abort ();
@@ -101,13 +112,9 @@ main (int argc, char *const *argv)
101 return -1; 112 return -1;
102 } 113 }
103 114
104 char *aes256_sha_tlsv1 = "AES256-SHA";
105 char *aes256_sha_sslv3 = "AES256-SHA";
106 char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA";
107
108 if (curl_uses_nss_ssl() == 0) 115 if (curl_uses_nss_ssl() == 0)
109 { 116 {
110 aes256_sha_tlsv1 = "rsa_aes_256_sha"; 117 aes256_sha_tlsv1 = "rsa_aes_256_sha";
111 aes256_sha_sslv3 = "rsa_aes_256_sha"; 118 aes256_sha_sslv3 = "rsa_aes_256_sha";
112 des_cbc3_sha_tlsv1 = "rsa_aes_128_sha"; 119 des_cbc3_sha_tlsv1 = "rsa_aes_128_sha";
113 } 120 }
@@ -118,7 +125,6 @@ main (int argc, char *const *argv)
118 test_secure_get (NULL, aes256_sha_sslv3, CURL_SSLVERSION_SSLv3); 125 test_secure_get (NULL, aes256_sha_sslv3, CURL_SSLVERSION_SSLv3);
119 errorCount += 126 errorCount +=
120 test_cipher_option (NULL, des_cbc3_sha_tlsv1, CURL_SSLVERSION_TLSv1); 127 test_cipher_option (NULL, des_cbc3_sha_tlsv1, CURL_SSLVERSION_TLSv1);
121
122 print_test_result (errorCount, argv[0]); 128 print_test_result (errorCount, argv[0]);
123 129
124 curl_global_cleanup (); 130 curl_global_cleanup ();
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c
index 4a9dd9dc..32f34ec0 100644
--- a/src/testcurl/https/test_https_get_parallel.c
+++ b/src/testcurl/https/test_https_get_parallel.c
@@ -19,7 +19,7 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file tls_thread_mode_test.c 22 * @file test_https_get_parallel.c
23 * @brief Testcase for libmicrohttpd HTTPS GET operations 23 * @brief Testcase for libmicrohttpd HTTPS GET operations
24 * @author Sagie Amir 24 * @author Sagie Amir
25 * @author Christian Grothoff 25 * @author Christian Grothoff
@@ -38,6 +38,7 @@ extern const char srv_self_signed_cert_pem[];
38 38
39int curl_check_version (const char *req_version, ...); 39int curl_check_version (const char *req_version, ...);
40 40
41
41/** 42/**
42 * used when spawning multiple threads executing curl server requests 43 * used when spawning multiple threads executing curl server requests
43 * 44 *
@@ -58,6 +59,7 @@ https_transfer_thread_adapter (void *args)
58 return &nonnull; 59 return &nonnull;
59} 60}
60 61
62
61/** 63/**
62 * Test non-parallel requests. 64 * Test non-parallel requests.
63 * 65 *
@@ -79,6 +81,7 @@ test_single_client (void *cls, const char *cipher_suite,
79 return 0; 81 return 0;
80} 82}
81 83
84
82/** 85/**
83 * Test parallel request handling. 86 * Test parallel request handling.
84 * 87 *
@@ -124,6 +127,7 @@ int
124main (int argc, char *const *argv) 127main (int argc, char *const *argv)
125{ 128{
126 unsigned int errorCount = 0; 129 unsigned int errorCount = 0;
130 const char *aes256_sha = "AES256-SHA";
127 131
128 /* initialize random seed used by curl clients */ 132 /* initialize random seed used by curl clients */
129 unsigned int iseed = (unsigned int) time (NULL); 133 unsigned int iseed = (unsigned int) time (NULL);
@@ -135,12 +139,17 @@ main (int argc, char *const *argv)
135 return -1; 139 return -1;
136 } 140 }
137 141
138 char *aes256_sha = "AES256-SHA";
139 if (curl_uses_nss_ssl() == 0) 142 if (curl_uses_nss_ssl() == 0)
140 { 143 aes256_sha = "rsa_aes_256_sha";
141 aes256_sha = "rsa_aes_256_sha"; 144#if LINUX
142 } 145 errorCount +=
143 146 test_wrap ("single threaded daemon, single client, epoll", &test_single_client,
147 NULL,
148 MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG | MHD_USE_EPOLL_LINUX_ONLY,
149 aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY,
150 srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT,
151 srv_self_signed_cert_pem, MHD_OPTION_END);
152#endif
144 errorCount += 153 errorCount +=
145 test_wrap ("single threaded daemon, single client", &test_single_client, 154 test_wrap ("single threaded daemon, single client", &test_single_client,
146 NULL, 155 NULL,
@@ -148,7 +157,15 @@ main (int argc, char *const *argv)
148 aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, 157 aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY,
149 srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, 158 srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT,
150 srv_self_signed_cert_pem, MHD_OPTION_END); 159 srv_self_signed_cert_pem, MHD_OPTION_END);
151 160#if LINUX
161 errorCount +=
162 test_wrap ("single threaded daemon, parallel clients, epoll",
163 &test_parallel_clients, NULL,
164 MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG | MHD_USE_EPOLL_LINUX_ONLY,
165 aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY,
166 srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT,
167 srv_self_signed_cert_pem, MHD_OPTION_END);
168#endif
152 errorCount += 169 errorCount +=
153 test_wrap ("single threaded daemon, parallel clients", 170 test_wrap ("single threaded daemon, parallel clients",
154 &test_parallel_clients, NULL, 171 &test_parallel_clients, NULL,
diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c
index 20f8eca4..0dd4e11d 100644
--- a/src/testcurl/https/test_https_get_select.c
+++ b/src/testcurl/https/test_https_get_select.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file mhds_get_test.c 22 * @file test_https_get_select.c
23 * @brief Testcase for libmicrohttpd HTTPS GET operations 23 * @brief Testcase for libmicrohttpd HTTPS GET operations
24 * @author Sagie Amir 24 * @author Sagie Amir
25 */ 25 */
@@ -71,8 +71,9 @@ ahc_echo (void *cls,
71 return ret; 71 return ret;
72} 72}
73 73
74
74static int 75static int
75testExternalGet () 76testExternalGet (int flags)
76{ 77{
77 struct MHD_Daemon *d; 78 struct MHD_Daemon *d;
78 CURL *c; 79 CURL *c;
@@ -88,12 +89,13 @@ testExternalGet ()
88 struct CURLMsg *msg; 89 struct CURLMsg *msg;
89 time_t start; 90 time_t start;
90 struct timeval tv; 91 struct timeval tv;
92 const char *aes256_sha = "AES256-SHA";
91 93
92 multi = NULL; 94 multi = NULL;
93 cbc.buf = buf; 95 cbc.buf = buf;
94 cbc.size = 2048; 96 cbc.size = 2048;
95 cbc.pos = 0; 97 cbc.pos = 0;
96 d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL, 98 d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL | flags,
97 1082, NULL, NULL, &ahc_echo, "GET", 99 1082, NULL, NULL, &ahc_echo, "GET",
98 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 100 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
99 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 101 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
@@ -101,11 +103,8 @@ testExternalGet ()
101 if (d == NULL) 103 if (d == NULL)
102 return 256; 104 return 256;
103 105
104 char *aes256_sha = "AES256-SHA";
105 if (curl_uses_nss_ssl() == 0) 106 if (curl_uses_nss_ssl() == 0)
106 { 107 aes256_sha = "rsa_aes_256_sha";
107 aes256_sha = "rsa_aes_256_sha";
108 }
109 108
110 c = curl_easy_init (); 109 c = curl_easy_init ();
111 curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1:1082/hello_world"); 110 curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1:1082/hello_world");
@@ -222,7 +221,11 @@ main (int argc, char *const *argv)
222 fprintf (stderr, "Error: %s\n", strerror (errno)); 221 fprintf (stderr, "Error: %s\n", strerror (errno));
223 return -1; 222 return -1;
224 } 223 }
225 if (0 != (errorCount = testExternalGet ())) 224#if LINUX
225 if (0 != (errorCount = testExternalGet (MHD_USE_EPOLL_LINUX_ONLY)))
226 fprintf (stderr, "Fail: %d\n", errorCount);
227#endif
228 if (0 != (errorCount = testExternalGet (0)))
226 fprintf (stderr, "Fail: %d\n", errorCount); 229 fprintf (stderr, "Fail: %d\n", errorCount);
227 curl_global_cleanup (); 230 curl_global_cleanup ();
228 return errorCount != 0; 231 return errorCount != 0;