Line data Source code
1 : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 : // of this source code is governed by a BSD-style license that can be found in 3 : // the LICENSE file. 4 : 5 : package testutils 6 : 7 : import ( 8 : "runtime" 9 : "testing" 10 : "time" 11 : 12 : "github.com/stretchr/testify/require" 13 : ) 14 : 15 : // DurationIsAtLeast verifies that the given duration is at least the given 16 : // value. 17 1 : func DurationIsAtLeast(t testing.TB, d, minValue time.Duration) { 18 1 : t.Helper() 19 1 : if runtime.GOOS == "windows" && minValue < 10*time.Millisecond { 20 0 : // Windows timer precision is coarse (on the order of 1 millisecond) and can 21 0 : // cause the duration for short operations to be 0. 22 0 : return 23 0 : } 24 1 : require.GreaterOrEqual(t, d, minValue) 25 : }