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

Function TestEnableTimestamps

timestamp/timestamp_notlinux_test.go:61–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestEnableTimestamps(t *testing.T) {
62 // listen to incoming udp packets
63 conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 0})
64 require.NoError(t, err)
65 defer conn.Close()
66
67 connFd, err := ConnFd(conn)
68 require.NoError(t, err)
69
70 // SOFTWARE
71 // Allow reading of kernel timestamps via socket
72 err = EnableTimestamps(SW, connFd, &net.Interface{Name: "lo", Index: 1})
73 require.NoError(t, err)
74
75 // Check that socket option is set
76 kernelTimestampsEnabled, err := unix.GetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_TIMESTAMP)
77 require.NoError(t, err)
78
79 // To be enabled must be > 0
80 require.Greater(t, kernelTimestampsEnabled, 0, "Kernel timestamps are not enabled")
81
82 // HARDWARE
83 err = EnableTimestamps(HW, connFd, &net.Interface{Name: "lo", Index: 1})
84 require.Equal(t, fmt.Errorf("unrecognized timestamp type: %s", HW), err)
85}
86
87func TestReadPacketWithRXTimestamp(t *testing.T) {
88 request := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 42}

Callers

nothing calls this directly

Calls 3

ConnFdFunction · 0.85
EnableTimestampsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…