Skip to content

Commit 6032dbc

Browse files
committed
Format NTPv5 test results differently
1 parent 0651dac commit 6032dbc

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

ntp5_test.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ func logResponseV5(t *testing.T, r *Response) {
3838
t.Logf("[%s] MonoEpoch: %s", host, fmtEpoch(r.MonotonicEpochID))
3939
t.Logf("[%s] Supported: %v", host, r.SupportedVersions)
4040
t.Logf("[%s] Poll: %s", host, r.Poll)
41-
t.Logf("[%s] CorrDelay0: %s", host, r.Correction.OriginDelay)
42-
t.Logf("[%s] CorrPath0: 0x%08x", host, r.Correction.OriginPathID)
43-
t.Logf("[%s] CorrDelay1: %s", host, r.Correction.ReturnDelay)
44-
t.Logf("[%s] CorrPath1: 0x%08x", host, r.Correction.ReturnPathID)
41+
t.Logf("[%s] Correction: %s", host, fmtCorrection(r.Correction))
4542
t.Logf("[%s] Precision: %s", host, r.Precision)
4643
t.Logf("[%s] RootDelay: %s", host, r.RootDelay)
4744
t.Logf("[%s] RootDisp: %s", host, r.RootDispersion)
@@ -102,6 +99,18 @@ func fmtTimescaleOffsets(offsets []TimescaleOffset) string {
10299
return s.String()
103100
}
104101

102+
func fmtCorrection(c Correction) string {
103+
if c.OriginDelay < 0 || c.ReturnDelay < 0 {
104+
return "<invalid>"
105+
}
106+
if c.OriginPathID == 0 && c.ReturnPathID == 0 {
107+
return "<none>"
108+
}
109+
return fmt.Sprintf("%s (0x%04x) / %s (0x%04x)",
110+
c.OriginDelay, c.OriginPathID,
111+
c.ReturnDelay, c.ReturnPathID)
112+
}
113+
105114
func fmtCookie(c uint64) string {
106115
if c == 0 {
107116
return "<zero>"
@@ -116,18 +125,18 @@ func TestOnlineV5Query(t *testing.T) {
116125
}
117126

118127
opt := QueryOptions{
119-
Version: 5,
120-
ReferenceIDRequest: ReferenceIDRequest{
121-
ChunkOffset: 0,
122-
ChunkSize: uint16(512),
123-
},
128+
Version: 5,
124129
Timescale: TimescaleUTC,
125130
AdditionalTimescales: []Timescale{TimescaleTAI, TimescaleUT1, TimescaleUTCSmeared},
126131
RequestSupportedVersions: true,
127132
RequestCorrection: true,
128133
RequestReferenceTime: true,
129134
RequestMonotonic: true,
130135
RequestInterleavedMode: true,
136+
ReferenceIDRequest: ReferenceIDRequest{
137+
ChunkOffset: 0,
138+
ChunkSize: uint16(512),
139+
},
131140
}
132141

133142
// Force an immediate timeout.

0 commit comments

Comments
 (0)