diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-03-28 18:11:09 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-02 09:54:48 +0000 |
| commit | f861ecca8b4dbdc9f71c3271d1eb6dbc0f71b5c6 (patch) | |
| tree | 859cab799bcd1fa814af51fb807ce950ad7b0d2f /pkg/osutil/osutil_test.go | |
| parent | 6baf506947ba27ed9ce775cf9351cb0886166083 (diff) | |
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.
Diffstat (limited to 'pkg/osutil/osutil_test.go')
| -rw-r--r-- | pkg/osutil/osutil_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
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) + } +} |
