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

Function TestListChainByNameUsingLasting

nftables_test.go:2196–2234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2194}
2195
2196func 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
2236func TestListTableByName(t *testing.T) {
2237 conn, newNS := nftest.OpenSystemConn(t, *enableSysTests)

Callers

nothing calls this directly

Calls 10

OpenSystemConnFunction · 0.92
NewFunction · 0.92
WithNetNSFdFunction · 0.92
AsLastingFunction · 0.92
CleanupSystemConnFunction · 0.92
FlushRulesetMethod · 0.80
AddTableMethod · 0.80
AddChainMethod · 0.80
FlushMethod · 0.80
ListChainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…