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

Function TestReadPacketWithRXTXTimestamp

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

Source from the content-addressed store, hash-verified

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,
321 0x0, 0xfc, 0xab, 0xf9, 0x8, 0x0, 0x0,
322 0x0, 0x0, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0,
323 0x0, 0x0, 0x29, 0x0, 0x0, 0x0, 0x19, 0x0,
324 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x4, 0x0,
325 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
326 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
327 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
328 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
329 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
330 0x0, 0x0,
331 }
332 toob = len(b)
333 default:
334 t.Skip("This test checks amd64 platform only")
335 }
336
337 ts, err := socketControlMessageTimestamp(b, toob)
338 require.NoError(t, err)
339 require.Equal(t, int64(1747233657150580220), ts.UnixNano())
340}
341
342func TestSocketControlMessageTimestampFail(t *testing.T) {
343 if timestamping != unix.SO_TIMESTAMPING_NEW {
344 t.Skip("This test supports SO_TIMESTAMPING_NEW only. No sample of SO_TIMESTAMPING")
345 }
346
347 _, err := socketControlMessageTimestamp(make([]byte, 16), 16)
348 require.ErrorIs(t, ErrNoTimestamp, err)
349}
350
351func TestReadPacketWithRXTimestamp(t *testing.T) {
352 request := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 42}
353 // listen to incoming udp packets
354 conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("localhost"), Port: 0})
355 require.NoError(t, err)
356 defer conn.Close()
357
358 // get connection file descriptor
359 connFd, err := ConnFd(conn)
360 require.NoError(t, err)
361
362 // Allow reading of kernel timestamps via socket

Callers

nothing calls this directly

Calls 10

ConnFdFunction · 0.85
EnableSWTimestampsFunction · 0.85
UnixMethod · 0.80
ReadTXtimestampFunction · 0.70
CloseMethod · 0.65
WriteToMethod · 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…