Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108113 from cockroachdb/blathers/backport-release…
…-23.1-108094
- Loading branch information
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
//go:build linux | ||
// +build linux | ||
|
||
package ptp | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/timeutil" | ||
) | ||
|
||
// TestClockNow sanity checks that Clock.Now() sourced from the CLOCK_REALTIME | ||
// device returns time close to timeutil.Now(). This ensures that the conversion | ||
// from the time returned by a clock device to Go's time.Time is correct. | ||
func TestClockNow(t *testing.T) { | ||
if got, want := realtime().Now(), timeutil.Now(); want.Sub(got).Abs() > 10*time.Second { | ||
t.Errorf("clock mismatch: got %v; timeutil says %v", got, want) | ||
} | ||
} |