mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Replace reflect.DeepEqual with [slices/maps].Equal.
They are faster on slice/map comparisons. PiperOrigin-RevId: 633080355
This commit is contained in:
@@ -16,7 +16,7 @@ package bitmap
|
||||
|
||||
import (
|
||||
"math"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestRemove(t *testing.T) {
|
||||
bitmap.Remove(firstSlice[i])
|
||||
}
|
||||
bitmapSlice := bitmap.ToSlice()
|
||||
if !reflect.DeepEqual(bitmapSlice, secondSlice) {
|
||||
if !slices.Equal(bitmapSlice, secondSlice) {
|
||||
t.Errorf("After Remove() firstSlice, remained slice: %v, wanted: %v", bitmapSlice, secondSlice)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func TestRemove(t *testing.T) {
|
||||
}
|
||||
bitmapSlice = bitmap.ToSlice()
|
||||
emptySlice := make([]uint32, 0)
|
||||
if !reflect.DeepEqual(bitmapSlice, emptySlice) {
|
||||
if !slices.Equal(bitmapSlice, emptySlice) {
|
||||
t.Errorf("After Remove secondSlice, remained slice: %v, wanted: %v", bitmapSlice, emptySlice)
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func TestFlipRange(t *testing.T) {
|
||||
|
||||
bitmap.FlipRange(uint32(tt.flipRangeMin), uint32(tt.flipRangeMax+1))
|
||||
flipBitmapSlice := bitmap.ToSlice()
|
||||
if !reflect.DeepEqual(flipFillSlice, flipBitmapSlice) {
|
||||
if !slices.Equal(flipFillSlice, flipBitmapSlice) {
|
||||
t.Errorf("%v, flipped slice: %v, wanted: %v", tt.name, flipBitmapSlice, flipFillSlice)
|
||||
}
|
||||
})
|
||||
@@ -186,7 +186,7 @@ func TestClearRange(t *testing.T) {
|
||||
clearedSlice = append(clearedSlice, uint32(i))
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(clearedSlice, clearedBitmapSlice) {
|
||||
if !slices.Equal(clearedSlice, clearedBitmapSlice) {
|
||||
t.Errorf("%v, cleared slice: %v, wanted: %v", tt.name, clearedBitmapSlice, clearedSlice)
|
||||
}
|
||||
})
|
||||
@@ -402,7 +402,7 @@ func TestGrow(t *testing.T) {
|
||||
want[i] = uint32(i)
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(bitmap.ToSlice(), want) {
|
||||
if !slices.Equal(bitmap.ToSlice(), want) {
|
||||
t.Errorf("Grow() got: %v, want: %v", bitmap.ToSlice(), want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package bits
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestForEachSetBit64(t *testing.T) {
|
||||
ForEachSetBit64(n, func(i int) {
|
||||
got = append(got, i)
|
||||
})
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("ForEachSetBit64(%#x): iterated bits %v, wanted %v", n, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package bpf
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
@@ -886,7 +887,7 @@ func TestValidInstructions(t *testing.T) {
|
||||
if retOptimized.ReturnValue != retFast {
|
||||
t.Fatalf("expected return value from optimized version: got %d, non-optimized execution returned %d", retOptimized.ReturnValue, retFast)
|
||||
}
|
||||
if !reflect.DeepEqual(retOptimized.InputAccessed, execution.InputAccessed) {
|
||||
if !slices.Equal(retOptimized.InputAccessed, execution.InputAccessed) {
|
||||
t.Fatalf("expected input read coverage from optimized version: got %s, non-optimized execution was %s", retOptimized.String(), execution.String())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package bpf
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -301,7 +301,7 @@ func TestOptimize(t *testing.T) {
|
||||
} else {
|
||||
optimizedInsns = Optimize(optimizedInsns)
|
||||
}
|
||||
if !reflect.DeepEqual(optimizedInsns, test.want) {
|
||||
if !slices.Equal(optimizedInsns, test.want) {
|
||||
t.Errorf("got optimized instructions:\n%v\nwant:\n%v\n", prettyInstructions(optimizedInsns), prettyInstructions(test.want))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -625,7 +625,7 @@ func TestBufferPullUp(t *testing.T) {
|
||||
for v := b.data.Front(); v != nil; v = v.Next() {
|
||||
gotLengths = append(gotLengths, v.Size())
|
||||
}
|
||||
if !reflect.DeepEqual(gotLengths, tc.lengths) {
|
||||
if !slices.Equal(gotLengths, tc.lengths) {
|
||||
t.Errorf("lengths = %v; want %v", gotLengths, tc.lengths)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package fspath
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -126,7 +126,7 @@ func TestParse(t *testing.T) {
|
||||
for pit := p.Begin; pit.Ok(); pit = pit.Next() {
|
||||
pcs = append(pcs, pit.String())
|
||||
}
|
||||
if !reflect.DeepEqual(pcs, test.relpath) {
|
||||
if !slices.Equal(pcs, test.relpath) {
|
||||
t.Errorf("relative path: got %v, wanted %v", pcs, test.relpath)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package gohacks
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestImmutableBytesFromString(t *testing.T) {
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := ImmutableBytesFromString(tc.input)
|
||||
if !reflect.DeepEqual(got, tc.want) {
|
||||
if !slices.Equal(got, tc.want) {
|
||||
t.Errorf("got contents %v (len %d cap %d) want %v (len %d cap %d)", got, len(got), cap(got), tc.want, len(tc.want), cap(tc.want))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"hash/adler32"
|
||||
"math"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -729,7 +729,7 @@ func TestTimerMetric(t *testing.T) {
|
||||
}
|
||||
m := emitter[0].(*pb.MetricUpdate).Metrics[0]
|
||||
wantFields := []string{"foo", "quux"}
|
||||
if !reflect.DeepEqual(m.GetFieldValues(), wantFields) {
|
||||
if !slices.Equal(m.GetFieldValues(), wantFields) {
|
||||
t.Errorf("%+v: got fields %v want %v", m, m.GetFieldValues(), wantFields)
|
||||
}
|
||||
dv, ok := m.Value.(*pb.MetricValue_DistributionValue)
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -633,7 +633,7 @@ func renameHelper(h *Harness, root p9.File, srcNames []string, dstNames []string
|
||||
// renameSrcPath here? If yes, then this is a mismatch.
|
||||
// We can't rename the src to some subpath of itself.
|
||||
if len(renameDestPath) > len(renameSrcPath) &&
|
||||
reflect.DeepEqual(renameDestPath[:len(renameSrcPath)], renameSrcPath) {
|
||||
slices.Equal(renameDestPath[:len(renameSrcPath)], renameSrcPath) {
|
||||
renameDestPath = nil
|
||||
renameSrcPath = nil
|
||||
continue
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
package pagetables
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
|
||||
type mapping struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ package usage
|
||||
import (
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bpf"
|
||||
@@ -29,7 +30,7 @@ import (
|
||||
// match byte-for-byte. If not, it prints them side-by-side.
|
||||
func comparePrograms(t *testing.T, precompiled, freshlyCompiled []bpf.Instruction) {
|
||||
t.Helper()
|
||||
if !reflect.DeepEqual(precompiled, freshlyCompiled) {
|
||||
if !slices.Equal(precompiled, freshlyCompiled) {
|
||||
t.Error("Precompiled and freshly-compiled versions of the program do not match:")
|
||||
t.Errorf(" Offset | %-32s | %-32s", "Freshly-compiled", "Compiled")
|
||||
for i := 0; i < max(len(precompiled), len(freshlyCompiled)); i++ {
|
||||
|
||||
@@ -17,7 +17,7 @@ package segment
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -343,7 +343,7 @@ func TestNextLargeEnoughGap(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(gapArr2, gapArr1) {
|
||||
if !slices.Equal(gapArr2, gapArr1) {
|
||||
t.Errorf("Search result not correct, got: %v, wanted: %v", gapArr1, gapArr2)
|
||||
}
|
||||
if t.Failed() {
|
||||
@@ -393,7 +393,7 @@ func TestPrevLargeEnoughGap(t *testing.T) {
|
||||
gapArr2 = append(gapArr2, gap.Range().Start)
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(gapArr2, gapArr1) {
|
||||
if !slices.Equal(gapArr2, gapArr1) {
|
||||
t.Errorf("Search result not correct, got: %v, wanted: %v", gapArr1, gapArr2)
|
||||
}
|
||||
if t.Failed() {
|
||||
@@ -648,7 +648,7 @@ func TestMutateRange(t *testing.T) {
|
||||
(*seg.ValuePtr())++
|
||||
return true
|
||||
})
|
||||
if got := s.ExportSlice(); !reflect.DeepEqual(got, test.final) {
|
||||
if got := s.ExportSlice(); !slices.Equal(got, test.final) {
|
||||
t.Errorf("Set mismatch after mutation: got %v, wanted %v", got, test.final)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ package cgroupfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bitmap"
|
||||
@@ -48,7 +48,7 @@ func TestFormat(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to parse formatted bitmap: %v", err)
|
||||
}
|
||||
if got, want := b1.ToSlice(), b.ToSlice(); !reflect.DeepEqual(got, want) {
|
||||
if got, want := b1.ToSlice(), b.ToSlice(); !slices.Equal(got, want) {
|
||||
t.Errorf("Parsing formatted output doesn't result in the original bitmap. Got %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
@@ -90,7 +90,7 @@ func TestParse(t *testing.T) {
|
||||
}
|
||||
|
||||
got := b.ToSlice()
|
||||
if !reflect.DeepEqual(got, tt.output) {
|
||||
if !slices.Equal(got, tt.output) {
|
||||
t.Errorf("Parsed bitmap doesn't match what we expected. Got %v, want %v", got, tt.output)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package fsutil
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
@@ -30,7 +30,7 @@ func TestDirtySet(t *testing.T) {
|
||||
want := []DirtyFlatSegment{
|
||||
{hostarch.PageSize, 2 * hostarch.PageSize, DirtyInfo{Keep: true}},
|
||||
}
|
||||
if got := set.ExportSlice(); !reflect.DeepEqual(got, want) {
|
||||
if got := set.ExportSlice(); !slices.Equal(got, want) {
|
||||
t.Errorf("set:\n\tgot %v,\n\twant %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
package memmap
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
|
||||
type testMappingSpace struct {
|
||||
@@ -40,7 +41,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
ms := &testMappingSpace{}
|
||||
|
||||
mapped := set.AddMapping(ms, hostarch.AddrRange{0x10000, 0x12000}, 0x1000, true)
|
||||
if got, want := mapped, []MappableRange{{0x1000, 0x3000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := mapped, []MappableRange{{0x1000, 0x3000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("AddMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
mapped = set.AddMapping(ms, hostarch.AddrRange{0x30000, 0x31000}, 0x4000, true)
|
||||
if got, want := mapped, []MappableRange{{0x4000, 0x5000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := mapped, []MappableRange{{0x4000, 0x5000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("AddMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
mapped = set.AddMapping(ms, hostarch.AddrRange{0x12000, 0x15000}, 0x3000, true)
|
||||
if got, want := mapped, []MappableRange{{0x3000, 0x4000}, {0x5000, 0x6000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := mapped, []MappableRange{{0x3000, 0x4000}, {0x5000, 0x6000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("AddMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
unmapped := set.RemoveMapping(ms, hostarch.AddrRange{0x10000, 0x11000}, 0x1000, true)
|
||||
if got, want := unmapped, []MappableRange{{0x1000, 0x2000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x1000, 0x2000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
unmapped = set.RemoveMapping(ms, hostarch.AddrRange{0x11000, 0x15000}, 0x2000, true)
|
||||
if got, want := unmapped, []MappableRange{{0x2000, 0x4000}, {0x5000, 0x6000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x2000, 0x4000}, {0x5000, 0x6000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ func TestAddRemoveMapping(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
unmapped = set.RemoveMapping(ms, hostarch.AddrRange{0x30000, 0x31000}, 0x4000, true)
|
||||
if got, want := unmapped, []MappableRange{{0x4000, 0x5000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x4000, 0x5000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -129,7 +130,7 @@ func TestInvalidateWholeMapping(t *testing.T) {
|
||||
// [0x10000, 0x11000) => [0, 0x1000)
|
||||
t.Log(&set)
|
||||
set.Invalidate(MappableRange{0, 0x1000}, InvalidateOpts{})
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{0x10000, 0x11000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{Start: 0x10000, End: 0x11000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("Invalidate: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -143,7 +144,7 @@ func TestInvalidatePartialMapping(t *testing.T) {
|
||||
// [0x10000, 0x13000) => [0, 0x3000)
|
||||
t.Log(&set)
|
||||
set.Invalidate(MappableRange{0x1000, 0x2000}, InvalidateOpts{})
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{0x11000, 0x12000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{Start: 0x11000, End: 0x12000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("Invalidate: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -159,7 +160,7 @@ func TestInvalidateMultipleMappings(t *testing.T) {
|
||||
// [0x12000, 0x13000) => [0x2000, 0x3000)
|
||||
t.Log(&set)
|
||||
set.Invalidate(MappableRange{0, 0x3000}, InvalidateOpts{})
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{0x10000, 0x11000}, {0x20000, 0x21000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := ms.inv, []hostarch.AddrRange{{Start: 0x10000, End: 0x11000}, {Start: 0x20000, End: 0x21000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("Invalidate: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -176,10 +177,10 @@ func TestInvalidateOverlappingMappings(t *testing.T) {
|
||||
// ms2:[0x11000, 0x13000) => [0x1000, 0x3000)
|
||||
t.Log(&set)
|
||||
set.Invalidate(MappableRange{0x1000, 0x2000}, InvalidateOpts{})
|
||||
if got, want := ms1.inv, []hostarch.AddrRange{{0x11000, 0x12000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := ms1.inv, []hostarch.AddrRange{{Start: 0x11000, End: 0x12000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("Invalidate: ms1: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
if got, want := ms2.inv, []hostarch.AddrRange{{0x20000, 0x21000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := ms2.inv, []hostarch.AddrRange{{Start: 0x20000, End: 0x21000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("Invalidate: ms1: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -189,7 +190,7 @@ func TestMixedWritableMappings(t *testing.T) {
|
||||
ms := &testMappingSpace{}
|
||||
|
||||
mapped := set.AddMapping(ms, hostarch.AddrRange{0x10000, 0x12000}, 0x1000, true)
|
||||
if got, want := mapped, []MappableRange{{0x1000, 0x3000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := mapped, []MappableRange{{0x1000, 0x3000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("AddMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -198,7 +199,7 @@ func TestMixedWritableMappings(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
mapped = set.AddMapping(ms, hostarch.AddrRange{0x20000, 0x22000}, 0x2000, false)
|
||||
if got, want := mapped, []MappableRange{{0x3000, 0x4000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := mapped, []MappableRange{{0x3000, 0x4000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("AddMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -228,7 +229,7 @@ func TestMixedWritableMappings(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
unmapped = set.RemoveMapping(ms, hostarch.AddrRange{0x11000, 0x12000}, 0x2000, true)
|
||||
if got, want := unmapped, []MappableRange{{0x2000, 0x3000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x2000, 0x3000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ func TestMixedWritableMappings(t *testing.T) {
|
||||
}
|
||||
|
||||
unmapped = set.RemoveMapping(ms, hostarch.AddrRange{0x10000, 0x12000}, 0x1000, true)
|
||||
if got, want := unmapped, []MappableRange{{0x1000, 0x2000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x1000, 0x2000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
|
||||
@@ -253,7 +254,7 @@ func TestMixedWritableMappings(t *testing.T) {
|
||||
t.Log(&set)
|
||||
|
||||
unmapped = set.RemoveMapping(ms, hostarch.AddrRange{0x21000, 0x22000}, 0x3000, false)
|
||||
if got, want := unmapped, []MappableRange{{0x3000, 0x4000}}; !reflect.DeepEqual(got, want) {
|
||||
if got, want := unmapped, []MappableRange{{0x3000, 0x4000}}; !slices.Equal(got, want) {
|
||||
t.Errorf("RemoveMapping: got %+v, wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package checker
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -463,7 +463,7 @@ func Raw(want []byte) NetworkChecker {
|
||||
return func(t *testing.T, h []header.Network) {
|
||||
t.Helper()
|
||||
|
||||
if got := h[len(h)-1].Payload(); !reflect.DeepEqual(got, want) {
|
||||
if got := h[len(h)-1].Payload(); !slices.Equal(got, want) {
|
||||
t.Errorf("Wrong payload, got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -917,7 +917,7 @@ func TCPSACKBlockChecker(sackBlocks []header.SACKBlock) TransportChecker {
|
||||
}
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(gotSACKBlocks, sackBlocks) {
|
||||
if !slices.Equal(gotSACKBlocks, sackBlocks) {
|
||||
t.Errorf("SACKBlocks are not equal, got = %v, want = %v", gotSACKBlocks, sackBlocks)
|
||||
}
|
||||
}
|
||||
@@ -928,7 +928,7 @@ func Payload(want []byte) TransportChecker {
|
||||
return func(t *testing.T, h header.Transport) {
|
||||
t.Helper()
|
||||
|
||||
if got := h.Payload(); !reflect.DeepEqual(got, want) {
|
||||
if got := h.Payload(); !slices.Equal(got, want) {
|
||||
t.Errorf("Wrong payload, got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package header_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -63,7 +64,7 @@ func TestEncodeSACKBlocks(t *testing.T) {
|
||||
t.Logf("testing: %v", tc)
|
||||
header.EncodeSACKBlocks(tc.sackBlocks, b)
|
||||
opts := header.ParseTCPOptions(b)
|
||||
if got, want := opts.SACKBlocks, tc.want; !reflect.DeepEqual(got, want) {
|
||||
if got, want := opts.SACKBlocks, tc.want; !slices.Equal(got, want) {
|
||||
t.Errorf("header.EncodeSACKBlocks(%v, %v), encoded blocks got: %v, want: %v", tc.sackBlocks, b, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
@@ -506,7 +506,7 @@ func TestIovecBuffer(t *testing.T) {
|
||||
buf.Apply(func(v *buffer.View) {
|
||||
lengths = append(lengths, v.Size())
|
||||
})
|
||||
if !reflect.DeepEqual(lengths, c.wantLengths) {
|
||||
if !slices.Equal(lengths, c.wantLengths) {
|
||||
t.Errorf("Pulled view lengths = %v, want %v", lengths, c.wantLengths)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ package queue
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/atomicbitops"
|
||||
@@ -69,7 +69,7 @@ func TestBasicTxQueue(t *testing.T) {
|
||||
40, 0, 0, 0, // size 2
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(want, d) {
|
||||
if !slices.Equal(want, d) {
|
||||
t.Fatalf("Bad posted packet: got %v, want %v", d, want)
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func TestBasicRxQueue(t *testing.T) {
|
||||
t.Fatalf("Tx pipe is empty after PostBuffers")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(want[i], d) {
|
||||
if !slices.Equal(want[i], d) {
|
||||
t.Fatalf("Bad posted packet: got %v, want %v", d, want[i])
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ func TestBasicRxQueue(t *testing.T) {
|
||||
t.Fatalf("Bad packet size: got %v, want %v", n, 100)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(bufs, b) {
|
||||
if !slices.Equal(bufs, b) {
|
||||
t.Fatalf("Bad returned buffers: got %v, want %v", bufs, b)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -320,7 +320,7 @@ func TestUpdateSACKBlocks(t *testing.T) {
|
||||
copy(sack.Blocks[:], tc.sackBlocks)
|
||||
sack.NumBlocks = len(tc.sackBlocks)
|
||||
tcp.UpdateSACKBlocks(&sack, tc.segStart, tc.segEnd, tc.rcvNxt)
|
||||
if got, want := sack.Blocks[:sack.NumBlocks], tc.updated; !reflect.DeepEqual(got, want) {
|
||||
if got, want := sack.Blocks[:sack.NumBlocks], tc.updated; !slices.Equal(got, want) {
|
||||
t.Errorf("UpdateSACKBlocks(%v, %v, %v, %v), got: %v, want: %v", tc.sackBlocks, tc.segStart, tc.segEnd, tc.rcvNxt, got, want)
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ func TestTrimSackBlockList(t *testing.T) {
|
||||
copy(sack.Blocks[:], tc.sackBlocks)
|
||||
sack.NumBlocks = len(tc.sackBlocks)
|
||||
tcp.TrimSACKBlockList(&sack, tc.rcvNxt)
|
||||
if got, want := sack.Blocks[:sack.NumBlocks], tc.trimmed; !reflect.DeepEqual(got, want) {
|
||||
if got, want := sack.Blocks[:sack.NumBlocks], tc.trimmed; !slices.Equal(got, want) {
|
||||
t.Errorf("TrimSackBlockList(%v, %v), got: %v, want: %v", tc.sackBlocks, tc.rcvNxt, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user