diff options
author | Ting-Yu Wang <anivia@google.com> | 2021-01-29 17:35:27 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-29 17:37:29 -0800 |
commit | 825c185dc56251bd330124ef773c6653e3887579 (patch) | |
tree | c059718acc0418795dc444184e08cbea19f7fc80 /pkg/tcpip/buffer/view_test.go | |
parent | 45fe9fe9c6fa92954a5017b98835eac5fd8d3987 (diff) |
Make fragmentation return a reassembled PacketBuffer
This allows later decoupling of the backing network buffer implementation.
PiperOrigin-RevId: 354643297
Diffstat (limited to 'pkg/tcpip/buffer/view_test.go')
-rw-r--r-- | pkg/tcpip/buffer/view_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/tcpip/buffer/view_test.go b/pkg/tcpip/buffer/view_test.go index e7f7cc9f1..78b2faa26 100644 --- a/pkg/tcpip/buffer/view_test.go +++ b/pkg/tcpip/buffer/view_test.go @@ -20,6 +20,7 @@ import ( "io" "reflect" "testing" + "unsafe" "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/buffer" @@ -578,3 +579,15 @@ func TestAppendView(t *testing.T) { } } } + +func TestMemSize(t *testing.T) { + const perViewCap = 128 + views := make([]buffer.View, 2, 32) + views[0] = make(buffer.View, 10, perViewCap) + views[1] = make(buffer.View, 20, perViewCap) + vv := buffer.NewVectorisedView(30, views) + want := int(unsafe.Sizeof(vv)) + cap(views)*int(unsafe.Sizeof(views)) + 2*perViewCap + if got := vv.MemSize(); got != want { + t.Errorf("vv.MemSize() = %d, want %d", got, want) + } +} |