MCPcopy Create free account
hub / github.com/facebook/time / TestSysoffBestSample

Function TestSysoffBestSample

phc/offset_test.go:41–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestSysoffBestSample(t *testing.T) {
42 extended := &PTPSysOffsetExtended{
43 Samples: 3,
44 Ts: [unix.PTP_MAX_SAMPLES][3]PtpClockTime{
45 {{Sec: 1667818190, Nsec: 552297411}, {Sec: 1667818153, Nsec: 552297462}, {Sec: 1667818190, Nsec: 552297522}},
46 {{Sec: 1667818190, Nsec: 552297533}, {Sec: 1667818153, Nsec: 552297582}, {Sec: 1667818190, Nsec: 552297622}},
47 {{Sec: 1667818190, Nsec: 552297644}, {Sec: 1667818153, Nsec: 552297661}, {Sec: 1667818190, Nsec: 552297722}},
48 },
49 ClockID: unix.CLOCK_MONOTONIC_RAW,
50 }
51 got := extended.BestSample()
52 want := SysoffResult{
53 SysTime: time.Unix(0, 1667818190552297683),
54 PHCTime: time.Unix(0, 1667818153552297661),
55 Delay: time.Duration(78),
56 Offset: time.Duration(37000000022),
57 SysClockID: unix.CLOCK_MONOTONIC_RAW,
58 }
59 require.Equal(t, want, got)
60}
61
62func TestSysoffFromExtendedTS(t *testing.T) {
63 extendedTS := [3]PtpClockTime{

Callers

nothing calls this directly

Calls 3

BestSampleMethod · 0.95
UnixMethod · 0.80
DurationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…