diff options
Diffstat (limited to 'src/testcurl/https/test_https_get_parallel.c')
-rw-r--r-- | src/testcurl/https/test_https_get_parallel.c | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c index 27c23173..e4040874 100644 --- a/src/testcurl/https/test_https_get_parallel.c +++ b/src/testcurl/https/test_https_get_parallel.c | |||
@@ -36,10 +36,10 @@ | |||
36 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 36 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
37 | #include "tls_test_common.h" | 37 | #include "tls_test_common.h" |
38 | 38 | ||
39 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 4 | 39 | #if defined(CPU_COUNT) && (CPU_COUNT + 0) < 4 |
40 | #undef CPU_COUNT | 40 | #undef CPU_COUNT |
41 | #endif | 41 | #endif |
42 | #if !defined(CPU_COUNT) | 42 | #if ! defined(CPU_COUNT) |
43 | #define CPU_COUNT 4 | 43 | #define CPU_COUNT 4 |
44 | #endif | 44 | #endif |
45 | 45 | ||
@@ -83,8 +83,8 @@ test_single_client (void *cls, int port, const char *cipher_suite, | |||
83 | { | 83 | { |
84 | void *client_thread_ret; | 84 | void *client_thread_ret; |
85 | struct https_test_data client_args = | 85 | struct https_test_data client_args = |
86 | { NULL, port, cipher_suite, curl_proto_version }; | 86 | { NULL, port, cipher_suite, curl_proto_version }; |
87 | (void)cls; /* Unused. Silent compiler warning. */ | 87 | (void) cls; /* Unused. Silent compiler warning. */ |
88 | 88 | ||
89 | client_thread_ret = https_transfer_thread_adapter (&client_args); | 89 | client_thread_ret = https_transfer_thread_adapter (&client_args); |
90 | if (client_thread_ret != NULL) | 90 | if (client_thread_ret != NULL) |
@@ -101,7 +101,7 @@ test_single_client (void *cls, int port, const char *cipher_suite, | |||
101 | * TODO : make client_count a parameter - numver of curl client threads to spawn | 101 | * TODO : make client_count a parameter - numver of curl client threads to spawn |
102 | */ | 102 | */ |
103 | static int | 103 | static int |
104 | test_parallel_clients (void * cls, int port, const char *cipher_suite, | 104 | test_parallel_clients (void *cls, int port, const char *cipher_suite, |
105 | int curl_proto_version) | 105 | int curl_proto_version) |
106 | { | 106 | { |
107 | int i; | 107 | int i; |
@@ -109,26 +109,26 @@ test_parallel_clients (void * cls, int port, const char *cipher_suite, | |||
109 | void *client_thread_ret; | 109 | void *client_thread_ret; |
110 | pthread_t client_arr[client_count]; | 110 | pthread_t client_arr[client_count]; |
111 | struct https_test_data client_args = | 111 | struct https_test_data client_args = |
112 | { NULL, port, cipher_suite, curl_proto_version }; | 112 | { NULL, port, cipher_suite, curl_proto_version }; |
113 | (void)cls; /* Unused. Silent compiler warning. */ | 113 | (void) cls; /* Unused. Silent compiler warning. */ |
114 | 114 | ||
115 | for (i = 0; i < client_count; ++i) | 115 | for (i = 0; i < client_count; ++i) |
116 | { | ||
117 | if (pthread_create (&client_arr[i], NULL, | ||
118 | &https_transfer_thread_adapter, &client_args) != 0) | ||
116 | { | 119 | { |
117 | if (pthread_create (&client_arr[i], NULL, | 120 | fprintf (stderr, "Error: failed to spawn test client threads.\n"); |
118 | &https_transfer_thread_adapter, &client_args) != 0) | 121 | return -1; |
119 | { | ||
120 | fprintf (stderr, "Error: failed to spawn test client threads.\n"); | ||
121 | return -1; | ||
122 | } | ||
123 | } | 122 | } |
123 | } | ||
124 | 124 | ||
125 | /* check all client requests fulfilled correctly */ | 125 | /* check all client requests fulfilled correctly */ |
126 | for (i = 0; i < client_count; ++i) | 126 | for (i = 0; i < client_count; ++i) |
127 | { | 127 | { |
128 | if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || | 128 | if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || |
129 | (client_thread_ret != NULL)) | 129 | (client_thread_ret != NULL)) |
130 | return -1; | 130 | return -1; |
131 | } | 131 | } |
132 | 132 | ||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
@@ -136,11 +136,11 @@ test_parallel_clients (void * cls, int port, const char *cipher_suite, | |||
136 | 136 | ||
137 | int | 137 | int |
138 | main (int argc, char *const *argv) | 138 | main (int argc, char *const *argv) |
139 | { | 139 | { |
140 | unsigned int errorCount = 0; | 140 | unsigned int errorCount = 0; |
141 | const char *aes256_sha = "AES256-SHA"; | 141 | const char *aes256_sha = "AES256-SHA"; |
142 | int port; | 142 | int port; |
143 | (void)argc; /* Unused. Silent compiler warning. */ | 143 | (void) argc; /* Unused. Silent compiler warning. */ |
144 | 144 | ||
145 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 145 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
146 | port = 0; | 146 | port = 0; |
@@ -150,21 +150,23 @@ main (int argc, char *const *argv) | |||
150 | /* initialize random seed used by curl clients */ | 150 | /* initialize random seed used by curl clients */ |
151 | unsigned int iseed = (unsigned int) time (NULL); | 151 | unsigned int iseed = (unsigned int) time (NULL); |
152 | srand (iseed); | 152 | srand (iseed); |
153 | if (!testsuite_curl_global_init ()) | 153 | if (! testsuite_curl_global_init ()) |
154 | return 99; | 154 | return 99; |
155 | 155 | ||
156 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) | 156 | if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) |
157 | { | 157 | { |
158 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); | 158 | fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); |
159 | return 77; | 159 | return 77; |
160 | } | 160 | } |
161 | if (curl_uses_nss_ssl() == 0) | 161 | if (curl_uses_nss_ssl () == 0) |
162 | aes256_sha = "rsa_aes_256_sha"; | 162 | aes256_sha = "rsa_aes_256_sha"; |
163 | #ifdef EPOLL_SUPPORT | 163 | #ifdef EPOLL_SUPPORT |
164 | errorCount += | 164 | errorCount += |
165 | test_wrap ("single threaded daemon, single client, epoll", &test_single_client, | 165 | test_wrap ("single threaded daemon, single client, epoll", |
166 | &test_single_client, | ||
166 | NULL, port, | 167 | NULL, port, |
167 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, | 168 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
169 | | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, | ||
168 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, | 170 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
169 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, | 171 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
170 | srv_self_signed_cert_pem, MHD_OPTION_END); | 172 | srv_self_signed_cert_pem, MHD_OPTION_END); |
@@ -172,7 +174,8 @@ main (int argc, char *const *argv) | |||
172 | errorCount += | 174 | errorCount += |
173 | test_wrap ("single threaded daemon, single client", &test_single_client, | 175 | test_wrap ("single threaded daemon, single client", &test_single_client, |
174 | NULL, port, | 176 | NULL, port, |
175 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, | 177 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
178 | | MHD_USE_ERROR_LOG, | ||
176 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, | 179 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
177 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, | 180 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
178 | srv_self_signed_cert_pem, MHD_OPTION_END); | 181 | srv_self_signed_cert_pem, MHD_OPTION_END); |
@@ -180,7 +183,8 @@ main (int argc, char *const *argv) | |||
180 | errorCount += | 183 | errorCount += |
181 | test_wrap ("single threaded daemon, parallel clients, epoll", | 184 | test_wrap ("single threaded daemon, parallel clients, epoll", |
182 | &test_parallel_clients, NULL, port, | 185 | &test_parallel_clients, NULL, port, |
183 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, | 186 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
187 | | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, | ||
184 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, | 188 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
185 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, | 189 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
186 | srv_self_signed_cert_pem, MHD_OPTION_END); | 190 | srv_self_signed_cert_pem, MHD_OPTION_END); |
@@ -188,7 +192,8 @@ main (int argc, char *const *argv) | |||
188 | errorCount += | 192 | errorCount += |
189 | test_wrap ("single threaded daemon, parallel clients", | 193 | test_wrap ("single threaded daemon, parallel clients", |
190 | &test_parallel_clients, NULL, port, | 194 | &test_parallel_clients, NULL, port, |
191 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, | 195 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
196 | | MHD_USE_ERROR_LOG, | ||
192 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, | 197 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
193 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, | 198 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
194 | srv_self_signed_cert_pem, MHD_OPTION_END); | 199 | srv_self_signed_cert_pem, MHD_OPTION_END); |