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

Function TestReadPacketWithRXTimestamp

timestamp/timestamp_linux_test.go:285–317  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283 require.True(t, dst.Equal(addr))
284 require.True(t, dst.IsMulticast())
285 })
286
287 t.Run("IPv4 unicast", func(t *testing.T) {
288 addr := net.ParseIP("10.0.0.1")
289 b := pktInfo4Cmsg(addr)
290 dst, err := socketControlMessageDstAddr(b, len(b))
291 require.NoError(t, err)
292 require.True(t, dst.Equal(addr))
293 require.False(t, dst.IsMulticast())
294 })
295
296 t.Run("no pktinfo", func(t *testing.T) {
297 _, err := socketControlMessageDstAddr(make([]byte, 16), 16)
298 require.Error(t, err)
299 })
300}
301
302func TestSocketControlMessageTimestamp(t *testing.T) {
303 if timestamping != unix.SO_TIMESTAMPING_NEW {
304 t.Skip("This test supports SO_TIMESTAMPING_NEW only. No sample of SO_TIMESTAMPING")
305 }
306
307 var b []byte
308 var toob int
309
310 // unix.Cmsghdr used in socketControlMessageTimestamp differs depending on platform
311 switch runtime.GOARCH {
312 case "amd64":
313 b = []byte{
314 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
315 0x1, 0x0, 0x0, 0x0, 0x41, 0x0, 0x0, 0x0,
316 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
317 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
318 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
319 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
320 0x79, 0xab, 0x24, 0x68, 0x0, 0x0, 0x0,

Callers

nothing calls this directly

Calls 8

ConnFdFunction · 0.85
UnixMethod · 0.80
EnableSWTimestampsRxFunction · 0.70
CloseMethod · 0.65
StringMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…