From 3d357e4d4aacf56575c7209480d4dd1a69187983 Mon Sep 17 00:00:00 2001 From: Anastasios Papagiannis Date: Fri, 13 Dec 2024 12:14:35 +0200 Subject: [PATCH] Add tests for the reverse policy filter mapping Signed-off-by: Anastasios Papagiannis --- pkg/policyfilter/map_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/policyfilter/map_test.go b/pkg/policyfilter/map_test.go index b1d66317ac1..f247f02e01a 100644 --- a/pkg/policyfilter/map_test.go +++ b/pkg/policyfilter/map_test.go @@ -19,9 +19,20 @@ func requirePfmEqualTo(t *testing.T, m PfMap, val map[uint64][]uint64) { } } + checkReverseVals := map[CgroupID]map[PolicyID]struct{}{} + for k, ids := range val { + for _, id := range ids { + if checkReverseVals[CgroupID(id)] == nil { + checkReverseVals[CgroupID(id)] = map[PolicyID]struct{}{} + } + checkReverseVals[CgroupID(id)][PolicyID(k)] = struct{}{} + } + } + mapVals, err := m.readAll() require.NoError(t, err) require.EqualValues(t, checkVals, mapVals.Direct) + require.EqualValues(t, checkReverseVals, mapVals.Reverse) } // TestPfMapOps tests some simple map operations