(t *testing.T)
| 175 | require.Greater(t, timestampsEnabled+newTimestampsEnabled, 0, "None of the socket options is set") |
| 176 | } |
| 177 | |
| 178 | func 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 | |
| 199 | func TestEnableTimestamps(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…