(t *testing.T)
| 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 | |
| 342 | func 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 | |
| 351 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…