(t *testing.T)
| 2625 | } |
| 2626 | |
| 2627 | func TestObjAPI(t *testing.T) { |
| 2628 | if os.Getenv("TRAVIS") == "true" { |
| 2629 | t.SkipNow() |
| 2630 | } |
| 2631 | |
| 2632 | // Create a new network namespace to test these operations, |
| 2633 | // and tear down the namespace at test completion. |
| 2634 | c, newNS := nftest.OpenSystemConn(t, *enableSysTests) |
| 2635 | defer nftest.CleanupSystemConn(t, newNS) |
| 2636 | |
| 2637 | // Clear all rules at the beginning + end of the test. |
| 2638 | c.FlushRuleset() |
| 2639 | defer c.FlushRuleset() |
| 2640 | |
| 2641 | table := c.AddTable(&nftables.Table{ |
| 2642 | Family: nftables.TableFamilyIPv4, |
| 2643 | Name: "filter", |
| 2644 | }) |
| 2645 | |
| 2646 | tableOther := c.AddTable(&nftables.Table{ |
| 2647 | Family: nftables.TableFamilyIPv4, |
| 2648 | Name: "foo", |
| 2649 | }) |
| 2650 | |
| 2651 | chain := c.AddChain(&nftables.Chain{ |
| 2652 | Name: "chain", |
| 2653 | Table: table, |
| 2654 | Type: nftables.ChainTypeFilter, |
| 2655 | Hooknum: nftables.ChainHookPostrouting, |
| 2656 | Priority: nftables.ChainPriorityFilter, |
| 2657 | }) |
| 2658 | |
| 2659 | counter1 := c.AddObj(&nftables.NamedObj{ |
| 2660 | Table: table, |
| 2661 | Name: "fwded1", |
| 2662 | Type: nftables.ObjTypeCounter, |
| 2663 | Obj: &expr.Counter{ |
| 2664 | Bytes: 1, |
| 2665 | Packets: 1, |
| 2666 | }, |
| 2667 | }) |
| 2668 | |
| 2669 | counter2 := c.AddObj(&nftables.NamedObj{ |
| 2670 | Table: table, |
| 2671 | Name: "fwded2", |
| 2672 | Type: nftables.ObjTypeCounter, |
| 2673 | Obj: &expr.Counter{ |
| 2674 | Bytes: 1, |
| 2675 | Packets: 1, |
| 2676 | }, |
| 2677 | }) |
| 2678 | |
| 2679 | c.AddObj(&nftables.NamedObj{ |
| 2680 | Table: tableOther, |
| 2681 | Name: "fwdedOther", |
| 2682 | Type: nftables.ObjTypeCounter, |
| 2683 | Obj: &expr.Counter{ |
| 2684 | Bytes: 0, |
nothing calls this directly
no test coverage detected
searching dependent graphs…