Skip to content

Commit 137a905

Browse files
committed
add preproccesor conditional to turn off http only data transfer tests
1 parent d2718a0 commit 137a905

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

minimal-examples-lowlevel/secure-streams/minimal-secure-streams-testsfail/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ require_lws_config(USE_WOLFSSL 0 requirements)
1818
require_lws_config(LWS_WITH_TLS 1 requirements)
1919

2020
if (requirements)
21+
option(LWS_WITH_SS_TESTS_HTTP_ONLY "Enable HTTP-only tests that require a local go-httpbin in secure streams test suite" ON)
22+
2123
add_executable(${SAMP} minimal-secure-streams-testsfail.c)
2224

25+
if(LWS_WITH_SS_TESTS_HTTP_ONLY)
26+
target_compile_definitions(${SAMP} PRIVATE LWS_WITH_SS_TESTS_HTTP_ONLY)
27+
endif()
28+
2329
find_program(VALGRIND "valgrind")
2430

2531
if (LWS_CTEST_INTERNET_AVAILABLE AND NOT WIN32)

minimal-examples-lowlevel/secure-streams/minimal-secure-streams-testsfail/minimal-secure-streams-testsfail.c

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ static lws_state_notify_link_t nl;
2424
struct lws_context *context;
2525
size_t amount = 12345;
2626

27+
#if defined(LWS_WITH_SS_TESTS_HTTP_ONLY)
28+
#define TESTS_COUNT 18 /* Original number of tests */
29+
#else
30+
#define TESTS_COUNT 16 /* Number of tests with HTTP ones removed */
31+
#endif
32+
2733
static void
2834
tests_start_next(lws_sorted_usec_list_t *sul);
2935

@@ -187,7 +193,9 @@ static const char * const default_ss_policy =
187193
"\"http_no_content_length\": true,"
188194
"\"retry\": \"default\","
189195
"\"tls_trust_store\": \"api_amazon_com\""
190-
"}},{"
196+
"}},"
197+
#if defined(LWS_WITH_SS_TESTS_HTTP_ONLY)
198+
"{"
191199

192200
/*
193201
* Just get a 200 from httpbin
@@ -204,7 +212,9 @@ static const char * const default_ss_policy =
204212
"\"http_url\": \"/status/200\","
205213
"\"timeout_ms\": 10000,"
206214
"\"retry\": \"default\""
207-
"}},{"
215+
"}},"
216+
#endif
217+
"{"
208218
"\"t_h1_tls\": {"
209219
"\"endpoint\": \"libwebsockets.org\","
210220
"\"port\": 443,"
@@ -310,7 +320,9 @@ static const char * const default_ss_policy =
310320
"\"timeout_ms\": 10000,"
311321
"\"retry\": \"default\","
312322
"\"tls_trust_store\": \"arca1\""
313-
"}},{"
323+
"}},"
324+
#if defined(LWS_WITH_SS_TESTS_HTTP_ONLY)
325+
"{"
314326

315327
/*
316328
* bulk payload transfer from httpbin.org
@@ -330,7 +342,9 @@ static const char * const default_ss_policy =
330342
"}],"
331343
"\"timeout_ms\": 10000,"
332344
"\"retry\": \"default\""
333-
"}},{"
345+
"}},"
346+
#endif
347+
"{"
334348
"\"bulk_h1_tls\": {"
335349
"\"endpoint\": \"libwebsockets.org\","
336350
"\"port\": 443,"
@@ -438,14 +452,15 @@ struct tests_seq {
438452
/*
439453
* We just get a 200 from httpbin.org as a sanity check first
440454
*/
441-
455+
#if defined(LWS_WITH_SS_TESTS_HTTP_ONLY)
442456
{
443457
"h1:80 just get 200",
444458
"t_h1", 15 * LWS_US_PER_SEC, LWSSSCS_QOS_ACK_REMOTE,
445459
(1 << LWSSSCS_TIMEOUT) | (1 << LWSSSCS_QOS_NACK_REMOTE) |
446460
(1 << LWSSSCS_ALL_RETRIES_FAILED),
447461
0
448462
},
463+
#endif
449464
{
450465
"h1:443 just get 200",
451466
"t_h1_tls", 15 * LWS_US_PER_SEC, LWSSSCS_QOS_ACK_REMOTE,
@@ -544,14 +559,15 @@ struct tests_seq {
544559
/*
545560
* Let's request some bulk data from httpbin.org
546561
*/
547-
562+
#if defined(LWS_WITH_SS_TESTS_HTTP_ONLY)
548563
{
549564
"h1:80 read bulk",
550565
"bulk_h1", 15 * LWS_US_PER_SEC, LWSSSCS_QOS_ACK_REMOTE,
551566
(1 << LWSSSCS_TIMEOUT) | (1 << LWSSSCS_QOS_NACK_REMOTE) |
552567
(1 << LWSSSCS_ALL_RETRIES_FAILED),
553568
12345
554569
},
570+
#endif
555571
{
556572
"h1:443 read bulk",
557573
"bulk_h1_tls", 15 * LWS_US_PER_SEC, LWSSSCS_QOS_ACK_REMOTE,
@@ -724,7 +740,7 @@ tests_start_next(lws_sorted_usec_list_t *sul)
724740

725741
doing_a_retry = 0;
726742

727-
if ((unsigned int)tests >= LWS_ARRAY_SIZE(tests_seq)) {
743+
if ((unsigned int)tests >= TESTS_COUNT) {
728744
lwsl_notice("Completed all tests\n");
729745
interrupted = 1;
730746
return;
@@ -803,6 +819,16 @@ sigint_handler(int sig)
803819
interrupted = 1;
804820
}
805821

822+
static void
823+
set_bulk_test_payloads(size_t payload_size)
824+
{
825+
for (size_t i = 0; i < TESTS_COUNT; i++) {
826+
if (strstr(tests_seq[i].name, "read bulk")) {
827+
tests_seq[i].eom_pass = payload_size;
828+
}
829+
}
830+
}
831+
806832
int
807833
main(int argc, const char **argv)
808834
{
@@ -818,9 +844,8 @@ main(int argc, const char **argv)
818844
amount = (size_t)atoi(pp);
819845

820846
/* set the expected payload for the bulk-related tests to amount */
847+
set_bulk_test_payloads(amount);
821848

822-
tests_seq[12].eom_pass = tests_seq[13].eom_pass =
823-
tests_seq[14].eom_pass = amount;
824849
#if !defined(LWS_SS_USE_SSPC)
825850
// puts(default_ss_policy);
826851
#endif

0 commit comments

Comments
 (0)