From f861ecca8b4dbdc9f71c3271d1eb6dbc0f71b5c6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 28 Mar 2024 18:11:09 +0100 Subject: syz-fuzzer: use of monotonic time for latency measurement time.Now/Since may reject to use monotonic time if the fuzzer messes with system time badly enough. Enforce use of monotonic time. --- pkg/osutil/osutil_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/osutil/osutil_test.go') diff --git a/pkg/osutil/osutil_test.go b/pkg/osutil/osutil_test.go index 713a62c14..7d5913b4a 100644 --- a/pkg/osutil/osutil_test.go +++ b/pkg/osutil/osutil_test.go @@ -9,6 +9,7 @@ import ( "path/filepath" "strings" "testing" + "time" ) func TestIsExist(t *testing.T) { @@ -119,3 +120,12 @@ func TestCopyFiles(t *testing.T) { }) } } + +func TestMonotonicNano(t *testing.T) { + start := MonotonicNano() + time.Sleep(100 * time.Millisecond) + diff := MonotonicNano() - start + if diff <= 0 || diff > 10*time.Second { + t.Fatalf("diff %v", diff) + } +} -- cgit mrf-deployment