aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-01-15 17:45:48 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-01-15 17:45:48 +0300
commit0ea5d514477a8b109a922afe5cdd1343d94c63bd (patch)
treed584175ecb1d30bbf6c80e8aea452fbede515006
parent0a478564f7ca32e7e5e6e20559149067515082a6 (diff)
downloadlibmicrohttpd-0ea5d514477a8b109a922afe5cdd1343d94c63bd.tar.gz
libmicrohttpd-0ea5d514477a8b109a922afe5cdd1343d94c63bd.zip
test_upgrade{,_large}: used the same port for all checks.
Fixed port conflict for platforms with broken detection of autobind port
-rw-r--r--src/microhttpd/test_upgrade.c14
-rw-r--r--src/microhttpd/test_upgrade_large.c14
2 files changed, 16 insertions, 12 deletions
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 68598723..fa91f7dc 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -174,6 +174,8 @@ fflush_allstd (void)
174 174
175static int verbose = 0; 175static int verbose = 0;
176 176
177static uint16_t global_port;
178
177enum tls_tool 179enum tls_tool
178{ 180{
179 TLS_CLI_NO_TOOL = 0, 181 TLS_CLI_NO_TOOL = 0,
@@ -1265,9 +1267,7 @@ test_upgrade (int flags,
1265 1267
1266 if (! test_tls) 1268 if (! test_tls)
1267 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, 1269 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,
1268 MHD_is_feature_supported ( 1270 global_port,
1269 MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1270 0 : 1090,
1271 NULL, NULL, 1271 NULL, NULL,
1272 &ahc_upgrade, NULL, 1272 &ahc_upgrade, NULL,
1273 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 1273 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -1281,9 +1281,7 @@ test_upgrade (int flags,
1281 else 1281 else
1282 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE 1282 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE
1283 | MHD_USE_TLS, 1283 | MHD_USE_TLS,
1284 MHD_is_feature_supported ( 1284 global_port,
1285 MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1286 0 : 1090,
1287 NULL, NULL, 1285 NULL, NULL,
1288 &ahc_upgrade, NULL, 1286 &ahc_upgrade, NULL,
1289 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, 1287 MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
@@ -1307,6 +1305,7 @@ test_upgrade (int flags,
1307 if ( (NULL == dinfo) || 1305 if ( (NULL == dinfo) ||
1308 (0 == dinfo->port) ) 1306 (0 == dinfo->port) )
1309 mhdErrorExitDesc ("MHD_get_daemon_info() failed"); 1307 mhdErrorExitDesc ("MHD_get_daemon_info() failed");
1308 global_port = dinfo->port; /* Re-use the same port for the next checks */
1310 if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) 1309 if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool))
1311 { 1310 {
1312 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); 1311 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt ();
@@ -1434,6 +1433,9 @@ main (int argc,
1434#endif /* ! HTTPS_SUPPORT */ 1433#endif /* ! HTTPS_SUPPORT */
1435 } 1434 }
1436 1435
1436 global_port = MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1437 0 : (test_tls ? 1091 : 1090);
1438
1437 /* run tests */ 1439 /* run tests */
1438 if (verbose) 1440 if (verbose)
1439 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", 1441 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n",
diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c
index 7c1032cf..3ccb1985 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -338,6 +338,8 @@ fflush_allstd (void)
338 338
339static int verbose = 0; 339static int verbose = 0;
340 340
341static uint16_t global_port;
342
341static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID; 343static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID;
342 344
343enum tls_tool 345enum tls_tool
@@ -1453,9 +1455,7 @@ test_upgrade (int flags,
1453 1455
1454 if (! test_tls) 1456 if (! test_tls)
1455 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, 1457 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,
1456 MHD_is_feature_supported ( 1458 global_port,
1457 MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1458 0 : 1090,
1459 NULL, NULL, 1459 NULL, NULL,
1460 &ahc_upgrade, NULL, 1460 &ahc_upgrade, NULL,
1461 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512, 1461 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512,
@@ -1470,9 +1470,7 @@ test_upgrade (int flags,
1470 else 1470 else
1471 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE 1471 d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE
1472 | MHD_USE_TLS, 1472 | MHD_USE_TLS,
1473 MHD_is_feature_supported ( 1473 global_port,
1474 MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1475 0 : 1090,
1476 NULL, NULL, 1474 NULL, NULL,
1477 &ahc_upgrade, NULL, 1475 &ahc_upgrade, NULL,
1478 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512, 1476 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512,
@@ -1497,6 +1495,7 @@ test_upgrade (int flags,
1497 if ( (NULL == dinfo) || 1495 if ( (NULL == dinfo) ||
1498 (0 == dinfo->port) ) 1496 (0 == dinfo->port) )
1499 mhdErrorExitDesc ("MHD_get_daemon_info() failed"); 1497 mhdErrorExitDesc ("MHD_get_daemon_info() failed");
1498 global_port = dinfo->port; /* Re-use the same port for the next checks */
1500 if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) 1499 if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool))
1501 { 1500 {
1502 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); 1501 sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt ();
@@ -1634,6 +1633,9 @@ main (int argc,
1634#endif /* ! HTTPS_SUPPORT */ 1633#endif /* ! HTTPS_SUPPORT */
1635 } 1634 }
1636 1635
1636 global_port = MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT) ?
1637 0 : (test_tls ? 1093 : 1092);
1638
1637 /* run tests */ 1639 /* run tests */
1638 if (verbose) 1640 if (verbose)
1639 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", 1641 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n",