Skip to content

Commit

Permalink
Timeout in the tserver test using real time
Browse files Browse the repository at this point in the history
When running the tserver test we bail out if a timeout expires. We
shouldn't use fake time for that timeout, because fake time might never
actually get incremented.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#22284)
  • Loading branch information
mattcaswell committed Oct 6, 2023
1 parent 2e62b07 commit 79997a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/quic_tserver_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static int do_test(int use_thread_assist, int use_fake_time, int use_inject)
int s_begin_write = 0;
OSSL_TIME start_time;
unsigned char alpn[] = { 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' };
OSSL_TIME (*now_cb)(void *arg) = use_fake_time ? fake_now : real_now;
size_t limit_ms = 1000;

#if defined(OPENSSL_NO_QUIC_THREAD_ASSIST)
Expand Down Expand Up @@ -194,10 +193,14 @@ static int do_test(int use_thread_assist, int use_fake_time, int use_inject)
if (!TEST_true(SSL_set_blocking_mode(c_ssl, 0)))
goto err;

start_time = now_cb(NULL);
/*
* We use real time for the timeout not fake time. Otherwise with fake time
* we could hit a hang if we never increment the fake time
*/
start_time = real_now(NULL);

for (;;) {
if (ossl_time_compare(ossl_time_subtract(now_cb(NULL), start_time),
if (ossl_time_compare(ossl_time_subtract(real_now(NULL), start_time),
ossl_ms2time(limit_ms)) >= 0) {
TEST_error("timeout while attempting QUIC server test");
goto err;
Expand Down

0 comments on commit 79997a9

Please sign in to comment.