diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-25 20:33:19 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-06-25 20:33:19 +0300 |
commit | 9d1596d3108ff237dbe368942296a0f6fbba47f8 (patch) | |
tree | bb6ac83244c81ce1e4063cbe4c35b15d13e01b39 /src/testcurl/https/test_https_time_out.c | |
parent | a7b7a32ec6dd493e00573da4b2f343f02feb0aa7 (diff) | |
download | libmicrohttpd-9d1596d3108ff237dbe368942296a0f6fbba47f8.tar.gz libmicrohttpd-9d1596d3108ff237dbe368942296a0f6fbba47f8.zip |
Make testsuite parallel build compatible (part 2)
Diffstat (limited to 'src/testcurl/https/test_https_time_out.c')
-rw-r--r-- | src/testcurl/https/test_https_time_out.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c index a1908e49..4330334b 100644 --- a/src/testcurl/https/test_https_time_out.c +++ b/src/testcurl/https/test_https_time_out.c | |||
@@ -47,7 +47,7 @@ extern const char srv_self_signed_cert_pem[]; | |||
47 | static const int TIME_OUT = 3; | 47 | static const int TIME_OUT = 3; |
48 | 48 | ||
49 | static int | 49 | static int |
50 | test_tls_session_time_out (gnutls_session_t session) | 50 | test_tls_session_time_out (gnutls_session_t session, int port) |
51 | { | 51 | { |
52 | int ret; | 52 | int ret; |
53 | MHD_socket sd; | 53 | MHD_socket sd; |
@@ -62,7 +62,7 @@ test_tls_session_time_out (gnutls_session_t session) | |||
62 | 62 | ||
63 | memset (&sa, '\0', sizeof (struct sockaddr_in)); | 63 | memset (&sa, '\0', sizeof (struct sockaddr_in)); |
64 | sa.sin_family = AF_INET; | 64 | sa.sin_family = AF_INET; |
65 | sa.sin_port = htons (DEAMON_TEST_PORT); | 65 | sa.sin_port = htons (port); |
66 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 66 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
67 | 67 | ||
68 | gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (intptr_t) sd); | 68 | gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (intptr_t) sd); |
@@ -109,7 +109,12 @@ main (int argc, char *const *argv) | |||
109 | gnutls_datum_t key; | 109 | gnutls_datum_t key; |
110 | gnutls_datum_t cert; | 110 | gnutls_datum_t cert; |
111 | gnutls_certificate_credentials_t xcred; | 111 | gnutls_certificate_credentials_t xcred; |
112 | int port; | ||
112 | 113 | ||
114 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
115 | port = 0; | ||
116 | else | ||
117 | port = 3070; | ||
113 | 118 | ||
114 | #ifdef MHD_HTTPS_REQUIRE_GRYPT | 119 | #ifdef MHD_HTTPS_REQUIRE_GRYPT |
115 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); | 120 | gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); |
@@ -121,7 +126,7 @@ main (int argc, char *const *argv) | |||
121 | gnutls_global_set_log_level (11); | 126 | gnutls_global_set_log_level (11); |
122 | 127 | ||
123 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | | 128 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | |
124 | MHD_USE_ERROR_LOG, DEAMON_TEST_PORT, | 129 | MHD_USE_ERROR_LOG, port, |
125 | NULL, NULL, &http_dummy_ahc, NULL, | 130 | NULL, NULL, &http_dummy_ahc, NULL, |
126 | MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT, | 131 | MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT, |
127 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 132 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, |
@@ -133,13 +138,21 @@ main (int argc, char *const *argv) | |||
133 | fprintf (stderr, MHD_E_SERVER_INIT); | 138 | fprintf (stderr, MHD_E_SERVER_INIT); |
134 | return -1; | 139 | return -1; |
135 | } | 140 | } |
141 | if (0 == port) | ||
142 | { | ||
143 | const union MHD_DaemonInfo *dinfo; | ||
144 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
145 | if (NULL == dinfo || 0 == dinfo->port) | ||
146 | { MHD_stop_daemon (d); return -1; } | ||
147 | port = (int)dinfo->port; | ||
148 | } | ||
136 | 149 | ||
137 | if (0 != setup_session (&session, &key, &cert, &xcred)) | 150 | if (0 != setup_session (&session, &key, &cert, &xcred)) |
138 | { | 151 | { |
139 | fprintf (stderr, "failed to setup session\n"); | 152 | fprintf (stderr, "failed to setup session\n"); |
140 | return 1; | 153 | return 1; |
141 | } | 154 | } |
142 | errorCount += test_tls_session_time_out (session); | 155 | errorCount += test_tls_session_time_out (session, port); |
143 | teardown_session (session, &key, &cert, xcred); | 156 | teardown_session (session, &key, &cert, xcred); |
144 | 157 | ||
145 | print_test_result (errorCount, argv[0]); | 158 | print_test_result (errorCount, argv[0]); |