Skip to content

Commit

Permalink
map: use t.Cleanup in createArray
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
  • Loading branch information
lmb committed Oct 20, 2023
1 parent c13934f commit 73d68a3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
8 changes: 1 addition & 7 deletions map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func newHash(t *testing.T) *Map {

func TestMap(t *testing.T) {
m := createArray(t)
defer m.Close()

t.Log(m)

Expand Down Expand Up @@ -430,7 +429,6 @@ func TestMapCloneNil(t *testing.T) {
func TestMapPin(t *testing.T) {
m := createArray(t)
c := qt.New(t)
defer m.Close()

if err := m.Put(uint32(0), uint32(42)); err != nil {
t.Fatal("Can't put:", err)
Expand Down Expand Up @@ -557,7 +555,6 @@ func TestMapPinMultiple(t *testing.T) {
func TestMapPinWithEmptyPath(t *testing.T) {
m := createArray(t)
c := qt.New(t)
defer m.Close()

err := m.Pin("")

Expand Down Expand Up @@ -694,7 +691,6 @@ func TestMapLoadPinnedWithOptions(t *testing.T) {
testutils.SkipOnOldKernel(t, "4.15", "file_flags in BPF_OBJ_GET")

array := createArray(t)
defer array.Close()

tmp := testutils.TempBPFFS(t)

Expand Down Expand Up @@ -780,6 +776,7 @@ func createArray(t *testing.T) *Map {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { m.Close() })
return m
}

Expand Down Expand Up @@ -1276,7 +1273,6 @@ func TestIterateMapInMap(t *testing.T) {
defer parent.Close()

a := createArray(t)
defer a.Close()

if err := parent.Put(idx, a); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1529,7 +1525,6 @@ func TestMapName(t *testing.T) {

func TestMapFromFD(t *testing.T) {
m := createArray(t)
defer m.Close()

if err := m.Put(uint32(0), uint32(123)); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1597,7 +1592,6 @@ func TestMapContents(t *testing.T) {

func TestMapFreeze(t *testing.T) {
arr := createArray(t)
defer arr.Close()

err := arr.Freeze()
testutils.SkipIfNotSupported(t, err)
Expand Down
1 change: 0 additions & 1 deletion prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,6 @@ func TestProgramRejectIncorrectByteOrder(t *testing.T) {

func TestProgramSpecTag(t *testing.T) {
arr := createArray(t)
defer arr.Close()

spec := &ProgramSpec{
Type: SocketFilter,
Expand Down

0 comments on commit 73d68a3

Please sign in to comment.