diff --git a/picoquictest/edge_cases.c b/picoquictest/edge_cases.c index 018ff00f3..f1fd1aa1a 100644 --- a/picoquictest/edge_cases.c +++ b/picoquictest/edge_cases.c @@ -859,7 +859,7 @@ int idle_server_test() } /* -* Testing isuses caused by frame events after a stream is reset. +* Testing issues caused by frame events after a stream is reset. * * We are concerned with possible errors when copies of "old" * frames cause processing of a stream after the stream has been @@ -944,12 +944,49 @@ int reset_repeat_test_need_repeat(int test_id, picoquic_cnx_t* cnx, const uint8_ return ret; } +int reset_loop_wait_stream_opened(picoquic_test_tls_api_ctx_t* test_ctx, + uint64_t* simulated_time, uint64_t data_stream_id, uint64_t loop1_time) +{ + int ret = 0; + int was_active = 0; + int nb_inactive = 0; + uint64_t time_out = *simulated_time + loop1_time; + int is_opened = 0; + + while (*simulated_time < time_out && + TEST_CLIENT_READY && + TEST_SERVER_READY && + nb_inactive < 64 && + ret == 0) { + picoquic_stream_head_t* c_stream = picoquic_find_stream(test_ctx->cnx_client, data_stream_id); + picoquic_stream_head_t* s_stream = picoquic_find_stream(test_ctx->cnx_server, data_stream_id); + if (c_stream != NULL && c_stream->sent_offset > 10000 && s_stream != NULL) { + is_opened = 1; + break; + } + was_active = 0; + + ret = tls_api_one_sim_round(test_ctx, simulated_time, 0, &was_active); + + if (was_active) { + nb_inactive = 0; + } + else { + nb_inactive++; + } + } + if (!is_opened) { + ret = -1; + } + return ret; +} + int reset_repeat_test_one(uint8_t test_id) { picoquic_test_tls_api_ctx_t* test_ctx = NULL; uint64_t simulated_time = 0; uint64_t data_stream_id = 4; - uint64_t loop1_time = 15000; + uint64_t loop1_time = 1000000; uint64_t loop2_time = 1000000; picoquic_connection_id_t initial_cid = { { 0x8e, 0x5e, 0x48, 0xe9, 0, 0, 0, 0}, 8 }; int ret = 0; @@ -1000,6 +1037,13 @@ int reset_repeat_test_one(uint8_t test_id) /* Run for a short time, so the stream is created and the transfer started */ if (ret == 0) { +#if 1 + ret = reset_loop_wait_stream_opened(test_ctx, &simulated_time, data_stream_id, loop1_time); + if (ret != 0) { + DBG_PRINTF("Test #%d. Loop wait stream failed!"); + ret = -1; + } +#else int was_active = 0; int nb_inactive = 0; uint64_t time_out = simulated_time + loop1_time; @@ -1025,13 +1069,14 @@ int reset_repeat_test_one(uint8_t test_id) nb_inactive++; } } +#endif } /* Verify that the stream #4 is present, and the * transmission has not stopped. */ if (!(TEST_CLIENT_READY) || !(TEST_SERVER_READY)) { - DBG_PRINTF("%s", "Sevrer or client not ready!"); + DBG_PRINTF("%s", "Server or client not ready!"); ret = -1; } if (ret == 0) {