TestRawSocketAvailable verifies we can acquire a raw socket + IP_HDRINCL. If this fails, Inject() cannot work on this host (missing CAP_NET_RAW).
(t *testing.T)
| 94 | // TestRawSocketAvailable verifies we can acquire a raw socket + IP_HDRINCL. |
| 95 | // If this fails, Inject() cannot work on this host (missing CAP_NET_RAW). |
| 96 | func TestRawSocketAvailable(t *testing.T) { |
| 97 | mustBeRoot(t) |
| 98 | b := New(Config{QueueNum: 4244}) |
| 99 | if err := b.Open(context.Background(), safeScope()); err != nil { |
| 100 | t.Fatalf("Open: %v", err) |
| 101 | } |
| 102 | if b.rawSock < 0 { |
| 103 | t.Fatal("raw socket not opened") |
| 104 | } |
| 105 | if err := b.Close(); err != nil { |
| 106 | t.Fatalf("Close: %v", err) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | var _ = net.Listen // keep net imported for future use |
| 111 | var _ = time.Second |
nothing calls this directly
no test coverage detected