Use fake time rather than real time in the noisy dgram test
authorMatt Caswell <matt@openssl.org>
Mon, 18 Sep 2023 16:06:31 +0000 (17:06 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 22 Sep 2023 12:56:43 +0000 (13:56 +0100)
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22157)

test/quicapitest.c

index 0030c3108211e75a1d72b3fea7a30571330ac4d5..023738a22bb1b5a8b3979a4c1eb3c76e511f59fc 100644 (file)
@@ -1276,7 +1276,7 @@ static int unreliable_client_read(SSL *clientquic, SSL **stream, void *buf,
                 return 0;
         }
         ossl_quic_tserver_tick(qtserv);
-        OSSL_sleep(10);
+        qtest_add_time(1);
     }
 
     return 0;
@@ -1295,7 +1295,7 @@ static int unreliable_server_read(QUIC_TSERVER *qtserv, uint64_t sid,
             return 1;
         ossl_quic_tserver_tick(qtserv);
         SSL_handle_events(clientquic);
-        OSSL_sleep(10);
+        qtest_add_time(1);
     }
 
     return 0;
@@ -1315,7 +1315,8 @@ static int test_noisy_dgram(void)
     if (!TEST_ptr(cctx)
             || !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
                                                     privkey,
-                                                    QTEST_FLAG_NOISE,
+                                                    QTEST_FLAG_NOISE
+                                                    | QTEST_FLAG_FAKE_TIME,
                                                     &qtserv,
                                                     &clientquic, NULL)))
         goto err;
@@ -1334,6 +1335,7 @@ static int test_noisy_dgram(void)
         if (!TEST_true(ossl_quic_tserver_stream_new(qtserv, 0, &sid)))
             goto err;
         ossl_quic_tserver_tick(qtserv);
+        qtest_add_time(1);
 
         /*
         * Send data from the server to the client. Some datagrams may get lost,
@@ -1347,6 +1349,7 @@ static int test_noisy_dgram(void)
                     || !TEST_size_t_eq(msglen, written))
                 goto err;
             ossl_quic_tserver_tick(qtserv);
+            qtest_add_time(1);
 
             /*
             * Since the underlying BIO is now noisy we may get failures that
@@ -1368,6 +1371,8 @@ static int test_noisy_dgram(void)
                 goto err;
 
             ossl_quic_tserver_tick(qtserv);
+            qtest_add_time(1);
+
             /*
             * Since the underlying BIO is now noisy we may get failures that
             * need to be retried - so we use unreliable_server_read() to handle