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

Function TestEnableSWTimestamps

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

Source from the content-addressed store, hash-verified

175 require.Greater(t, timestampsEnabled+newTimestampsEnabled, 0, "None of the socket options is set")
176}
177
178func TestEnableSWTimestamps(t *testing.T) {
179 // listen to incoming udp packets
180 conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 0})
181 require.NoError(t, err)
182 defer conn.Close()
183
184 connFd, err := ConnFd(conn)
185 require.NoError(t, err)
186
187 // Allow reading of kernel timestamps via socket
188 err = EnableSWTimestamps(connFd)
189 require.NoError(t, err)
190
191 // Check that socket option is set
192 timestampsEnabled, _ := unix.GetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_TIMESTAMPING)
193 newTimestampsEnabled, _ := unix.GetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_TIMESTAMPING_NEW)
194
195 // At least one of them should be set, which it > 0
196 require.Greater(t, timestampsEnabled+newTimestampsEnabled, 0, "None of the socket options is set")
197}
198
199func TestEnableTimestamps(t *testing.T) {

Callers

nothing calls this directly

Calls 3

ConnFdFunction · 0.85
EnableSWTimestampsFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…