mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add leak checking to fdbased_test.
PiperOrigin-RevId: 423901655
This commit is contained in:
committed by
gVisor bot
parent
2b2f9ea914
commit
e7091facd2
@@ -30,6 +30,8 @@ go_test(
|
||||
srcs = ["endpoint_test.go"],
|
||||
library = ":fdbased",
|
||||
deps = [
|
||||
"//pkg/refs",
|
||||
"//pkg/refsvfs2",
|
||||
"//pkg/tcpip",
|
||||
"//pkg/tcpip/buffer",
|
||||
"//pkg/tcpip/header",
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -28,6 +29,8 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/refs"
|
||||
"gvisor.dev/gvisor/pkg/refsvfs2"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/buffer"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -203,6 +206,7 @@ func testWritePacket(t *testing.T, plen int, eth bool, gsoMaxSize uint32, hash u
|
||||
// See nic.writePacket.
|
||||
pkt.EgressRoute = r
|
||||
pkt.NetworkProtocolNumber = proto
|
||||
defer pkt.DecRef()
|
||||
|
||||
// Build header.
|
||||
b := pkt.NetworkHeader().Push(netHdrLen)
|
||||
@@ -339,6 +343,7 @@ func TestPreserveSrcAddress(t *testing.T) {
|
||||
ReserveHeaderBytes: header.EthernetMinimumSize,
|
||||
Data: buffer.VectorisedView{},
|
||||
})
|
||||
defer pkt.DecRef()
|
||||
// Every PacketBuffer must have these set:
|
||||
// See nic.writePacket.
|
||||
pkt.NetworkProtocolNumber = proto
|
||||
@@ -385,6 +390,7 @@ func TestDeliverPacket(t *testing.T) {
|
||||
ReserveHeaderBytes: header.EthernetMinimumSize,
|
||||
Data: buffer.NewViewFromBytes(all).ToVectorisedView(),
|
||||
})
|
||||
defer wantPkt.DecRef()
|
||||
if eth {
|
||||
hdr := header.Ethernet(wantPkt.LinkHeader().Push(header.EthernetMinimumSize))
|
||||
hdr.Encode(&header.EthernetFields{
|
||||
@@ -634,3 +640,10 @@ func TestDispatchPacketFormat(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
refs.SetLeakMode(refs.LeaksPanic)
|
||||
code := m.Run()
|
||||
refsvfs2.DoLeakCheck()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user