MCPcopy Create free account
hub / github.com/google/nftables / TestSocket

Function TestSocket

expr/socket_test.go:26–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestSocket(t *testing.T) {
27 t.Parallel()
28 tests := []struct {
29 name string
30 socket Socket
31 }{
32 {
33 name: "Unmarshal `socket transparent`",
34 socket: Socket{
35 Key: SocketKeyTransparent,
36 Level: 0,
37 Register: 1,
38 },
39 },
40 {
41 name: "Unmarshal `socket cgroup level 5`",
42 socket: Socket{
43 Key: SocketKeyCgroupv2,
44 Level: 5,
45 Register: 1,
46 },
47 },
48 {
49 name: "Unmarshal `socket cgroup level 1`",
50 socket: Socket{
51 Key: SocketKeyCgroupv2,
52 Level: 1,
53 Register: 1,
54 },
55 },
56 {
57 name: "Unmarshal `socket wildcard`",
58 socket: Socket{
59 Key: SocketKeyWildcard,
60 Level: 0,
61 Register: 1,
62 },
63 },
64 {
65 name: "Unmarshal `socket mark`",
66 socket: Socket{
67 Key: SocketKeyMark,
68 Level: 0,
69 Register: 1,
70 },
71 },
72 }
73
74 for _, tt := range tests {
75 t.Run(tt.name, func(t *testing.T) {
76 nSocket := Socket{}
77 data, err := tt.socket.marshal(0 /* don't care in this test */)
78 if err != nil {
79 t.Fatalf("marshal error: %+v", err)
80
81 }
82 ad, err := netlink.NewAttributeDecoder(data)
83 if err != nil {

Callers

nothing calls this directly

Calls 2

unmarshalMethod · 0.95
marshalMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…