]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: virt-time: add virt_time_init_at
authorDaiki Ueno <ueno@gnu.org>
Thu, 29 Apr 2021 15:56:37 +0000 (17:56 +0200)
committerDaiki Ueno <ueno@gnu.org>
Thu, 13 May 2021 09:19:17 +0000 (11:19 +0200)
This allows the tests to set the current time to arbitrary point,
instead of the current time; useful for the tests checking the traces
such as tls13/prf-early.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
tests/virt-time.h

index 0e7e213c5371b1f409e6bd30e3444cce1ca20041..7f7c37471c8edf361e046683427df6c8d75f8f29 100644 (file)
@@ -45,14 +45,16 @@ static struct timespec _now_ts;
                _now_ts.tv_sec += s; \
        }
 
-#define virt_time_init() { \
-               _now = time(0); \
+#define virt_time_init_at(d) { \
+               _now = (d); \
                gnutls_global_set_time_function(mytime); \
                _now_ts.tv_sec = _now; \
                _now_ts.tv_nsec = 0; \
                _gnutls_global_set_gettime_function(mygettime); \
        }
 
+#define virt_time_init() virt_time_init_at(time(0))
+
 
 static time_t mytime(time_t * t)
 {