(t *testing.T)
| 4243 | } |
| 4244 | |
| 4245 | func TestCreateDeleteFlowtable(t *testing.T) { |
| 4246 | c, newNS := nftest.OpenSystemConn(t, *enableSysTests) |
| 4247 | defer nftest.CleanupSystemConn(t, newNS) |
| 4248 | c.FlushRuleset() |
| 4249 | defer c.FlushRuleset() |
| 4250 | |
| 4251 | filter := &nftables.Table{ |
| 4252 | Family: nftables.TableFamilyIPv4, |
| 4253 | Name: "filter", |
| 4254 | } |
| 4255 | |
| 4256 | flowtable := &nftables.Flowtable{ |
| 4257 | Table: filter, |
| 4258 | Name: "flowtable_test", |
| 4259 | } |
| 4260 | |
| 4261 | c.AddTable(filter) |
| 4262 | c.AddFlowtable(flowtable) |
| 4263 | flowtable.Name = "flowtable_test_to_delete" |
| 4264 | c.AddFlowtable(flowtable) |
| 4265 | |
| 4266 | if err := c.Flush(); err != nil { |
| 4267 | t.Fatalf("c.Flush() failed: %v", err) |
| 4268 | } |
| 4269 | |
| 4270 | flowtables, err := c.ListFlowtables(filter) |
| 4271 | if err != nil { |
| 4272 | t.Fatalf("c.ListFlowtables() failed: %v", err) |
| 4273 | } |
| 4274 | |
| 4275 | if got, want := len(flowtables), 2; got != want { |
| 4276 | t.Fatalf("flowtable entry length mismatch: got %d, want %d", got, want) |
| 4277 | } |
| 4278 | |
| 4279 | c.DelFlowtable(flowtable) |
| 4280 | if err := c.Flush(); err != nil { |
| 4281 | t.Fatalf("c.Flush() failed: %v", err) |
| 4282 | } |
| 4283 | |
| 4284 | flowtables, err = c.ListFlowtables(filter) |
| 4285 | if err != nil { |
| 4286 | t.Fatalf("c.ListFlowtables() after deletion failed: %v", err) |
| 4287 | } |
| 4288 | |
| 4289 | if got, want := len(flowtables), 1; got != want { |
| 4290 | t.Errorf("flowtable entry length mismatch: got %d, want %d", got, want) |
| 4291 | } |
| 4292 | |
| 4293 | if got, removed := flowtables[0].Name, flowtable.Name; got == removed { |
| 4294 | t.Errorf("wrong flowtable entry deleted") |
| 4295 | } |
| 4296 | } |
| 4297 | |
| 4298 | func TestOffload(t *testing.T) { |
| 4299 | c, newNS := nftest.OpenSystemConn(t, *enableSysTests) |
nothing calls this directly
no test coverage detected
searching dependent graphs…