]> git.feebdaed.xyz Git - 0xmirror/cilium.git/commitdiff
pkg/bpf: replace reflect.DeepEqual in tests
authorAshwin Pillai <pillaiashwin96@gmail.com>
Tue, 16 Dec 2025 21:21:02 +0000 (13:21 -0800)
committerJulian Wiedmann <julianwiedmann@users.noreply.github.com>
Fri, 19 Dec 2025 17:14:30 +0000 (17:14 +0000)
Replace reflect.DeepEqual with assert.Equal from testify in BPF map test
file for better error messages when assertions fail.

Signed-off-by: Ashwin Pillai <pillai.ashwin@gmail.com>
Signed-off-by: Ashwin Pillai <pillaiashwin96@gmail.com>
pkg/bpf/map_linux_test.go

index 724019b170438f67c49a4467bc92046325c7910e..37e8ead86fd010e782343233763258a225a1e2ad 100644 (file)
@@ -7,7 +7,6 @@ import (
        "context"
        "fmt"
        "os"
-       "reflect"
        "strconv"
        "strings"
        "sync"
@@ -110,9 +109,10 @@ var (
        maxEntries = 16
 )
 
-func mapsEqual(a, b *Map) bool {
-       return a.name == b.name &&
-               reflect.DeepEqual(a.spec, b.spec)
+func mapsEqual(t *testing.T, expected, actual *Map) {
+       t.Helper()
+       require.Equal(t, expected.name, actual.name, "map names should match")
+       require.Equal(t, expected.spec, actual.spec, "map specs should match")
 }
 
 func TestPrivilegedOpen(t *testing.T) {
@@ -152,7 +152,7 @@ func TestPrivilegedOpenMap(t *testing.T) {
 
        openedMap, err = OpenMap(MapPath(logger, "cilium_test"), &TestKey{}, &TestValue{})
        require.NoError(t, err)
-       require.True(t, mapsEqual(openedMap, testMap))
+       mapsEqual(t, testMap, openedMap)
 }
 
 func TestPrivilegedOpenOrCreate(t *testing.T) {
@@ -203,7 +203,7 @@ func TestPrivilegedRecreateMap(t *testing.T) {
        require.Error(t, err)
 
        // Check OpenMap warning section
-       require.True(t, mapsEqual(parallelMap, testMap))
+       mapsEqual(t, testMap, parallelMap)
 
        key1 := &TestKey{Key: 101}
        value1 := &TestValue{Value: 201}