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

Function TestSeqIDSocketControlMessage

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

Source from the content-addressed store, hash-verified

397
398 ts, err := socketControlMessageTimestamp(b, toob)
399 require.NoError(t, err)
400 require.Equal(t, int64(1747233657150580220), ts.UnixNano())
401}
402
403func TestSocketControlMessageTimestampFail(t *testing.T) {
404 if timestamping != unix.SO_TIMESTAMPING_NEW {
405 t.Skip("This test supports SO_TIMESTAMPING_NEW only. No sample of SO_TIMESTAMPING")
406 }
407
408 _, err := socketControlMessageTimestamp(make([]byte, 16), 16)
409 require.ErrorIs(t, ErrNoTimestamp, err)
410}
411
412func TestReadPacketWithRXTimestamp(t *testing.T) {
413 request := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 42}
414 // listen to incoming udp packets
415 conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("localhost"), Port: 0})
416 require.NoError(t, err)
417 defer conn.Close()
418
419 // get connection file descriptor
420 connFd, err := ConnFd(conn)
421 require.NoError(t, err)
422
423 // Allow reading of kernel timestamps via socket
424 err = EnableSWTimestampsRx(connFd)
425 require.NoError(t, err)
426
427 err = unix.SetNonblock(connFd, false)
428 require.NoError(t, err)

Callers

nothing calls this directly

Calls 2

SkipMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…