(t *testing.T)
| 2194 | } |
| 2195 | |
| 2196 | func TestListChainByNameUsingLasting(t *testing.T) { |
| 2197 | _, newNS := nftest.OpenSystemConn(t, *enableSysTests) |
| 2198 | conn, err := nftables.New(nftables.WithNetNSFd(int(newNS)), nftables.AsLasting()) |
| 2199 | if err != nil { |
| 2200 | t.Fatalf("nftables.New() failed: %v", err) |
| 2201 | } |
| 2202 | defer nftest.CleanupSystemConn(t, newNS) |
| 2203 | conn.FlushRuleset() |
| 2204 | defer conn.FlushRuleset() |
| 2205 | |
| 2206 | table := &nftables.Table{ |
| 2207 | Name: "chain_test_lasting", |
| 2208 | Family: nftables.TableFamilyIPv4, |
| 2209 | } |
| 2210 | tr := conn.AddTable(table) |
| 2211 | |
| 2212 | c := &nftables.Chain{ |
| 2213 | Name: "filter_lasting", |
| 2214 | Table: table, |
| 2215 | } |
| 2216 | conn.AddChain(c) |
| 2217 | |
| 2218 | if err := conn.Flush(); err != nil { |
| 2219 | t.Errorf("conn.Flush() failed: %v", err) |
| 2220 | } |
| 2221 | |
| 2222 | cr, err := conn.ListChain(tr, c.Name) |
| 2223 | if err != nil { |
| 2224 | t.Fatalf("conn.ListChain() failed: %v", err) |
| 2225 | } |
| 2226 | |
| 2227 | if got, want := cr.Name, c.Name; got != want { |
| 2228 | t.Fatalf("got chain %s, want chain %s", got, want) |
| 2229 | } |
| 2230 | |
| 2231 | if got, want := cr.Table.Name, table.Name; got != want { |
| 2232 | t.Fatalf("got chain table %s, want chain table %s", got, want) |
| 2233 | } |
| 2234 | } |
| 2235 | |
| 2236 | func TestListTableByName(t *testing.T) { |
| 2237 | conn, newNS := nftest.OpenSystemConn(t, *enableSysTests) |
nothing calls this directly
no test coverage detected
searching dependent graphs…