Merge pull request #2253 from amscanne:nogo
PiperOrigin-RevId: 305807868
This commit is contained in:
commit
78126611e6
|
@ -78,7 +78,7 @@ func TestMultiEmitter(t *testing.T) {
|
|||
for _, name := range names {
|
||||
m := testMessage{name: name}
|
||||
if _, err := me.Emit(m); err != nil {
|
||||
t.Fatal("me.Emit(%v) failed: %v", m, err)
|
||||
t.Fatalf("me.Emit(%v) failed: %v", m, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ func TestMultiEmitter(t *testing.T) {
|
|||
|
||||
// Close multiEmitter.
|
||||
if err := me.Close(); err != nil {
|
||||
t.Fatal("me.Close() failed: %v", err)
|
||||
t.Fatalf("me.Close() failed: %v", err)
|
||||
}
|
||||
|
||||
// All testEmitters should be closed.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
// GoogleEmitter is a wrapper that emits logs in a format compatible with
|
||||
// package github.com/golang/glog.
|
||||
type GoogleEmitter struct {
|
||||
Writer
|
||||
*Writer
|
||||
}
|
||||
|
||||
// pid is used for the threadid component of the header.
|
||||
|
@ -46,7 +46,7 @@ var pid = os.Getpid()
|
|||
// line The line number
|
||||
// msg The user-supplied message
|
||||
//
|
||||
func (g *GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format string, args ...interface{}) {
|
||||
func (g GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format string, args ...interface{}) {
|
||||
// Log level.
|
||||
prefix := byte('?')
|
||||
switch level {
|
||||
|
@ -81,5 +81,5 @@ func (g *GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format
|
|||
message := fmt.Sprintf(format, args...)
|
||||
|
||||
// Emit the formatted result.
|
||||
fmt.Fprintf(&g.Writer, "%c%02d%02d %02d:%02d:%02d.%06d % 7d %s:%d] %s\n", prefix, int(month), day, hour, minute, second, microsecond, pid, file, line, message)
|
||||
fmt.Fprintf(g.Writer, "%c%02d%02d %02d:%02d:%02d.%06d % 7d %s:%d] %s\n", prefix, int(month), day, hour, minute, second, microsecond, pid, file, line, message)
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func (lv *Level) UnmarshalJSON(b []byte) error {
|
|||
|
||||
// JSONEmitter logs messages in json format.
|
||||
type JSONEmitter struct {
|
||||
Writer
|
||||
*Writer
|
||||
}
|
||||
|
||||
// Emit implements Emitter.Emit.
|
||||
|
|
|
@ -29,11 +29,11 @@ type k8sJSONLog struct {
|
|||
// K8sJSONEmitter logs messages in json format that is compatible with
|
||||
// Kubernetes fluent configuration.
|
||||
type K8sJSONEmitter struct {
|
||||
Writer
|
||||
*Writer
|
||||
}
|
||||
|
||||
// Emit implements Emitter.Emit.
|
||||
func (e *K8sJSONEmitter) Emit(_ int, level Level, timestamp time.Time, format string, v ...interface{}) {
|
||||
func (e K8sJSONEmitter) Emit(_ int, level Level, timestamp time.Time, format string, v ...interface{}) {
|
||||
j := k8sJSONLog{
|
||||
Log: fmt.Sprintf(format, v...),
|
||||
Level: level,
|
||||
|
|
|
@ -374,5 +374,5 @@ func CopyStandardLogTo(l Level) error {
|
|||
|
||||
func init() {
|
||||
// Store the initial value for the log.
|
||||
log.Store(&BasicLogger{Level: Info, Emitter: &GoogleEmitter{Writer{Next: os.Stderr}}})
|
||||
log.Store(&BasicLogger{Level: Info, Emitter: GoogleEmitter{&Writer{Next: os.Stderr}}})
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestDropMessages(t *testing.T) {
|
|||
t.Fatalf("Write should have failed")
|
||||
}
|
||||
|
||||
fmt.Printf("writer: %+v\n", w)
|
||||
fmt.Printf("writer: %#v\n", &w)
|
||||
|
||||
tw.fail = false
|
||||
if _, err := w.Write([]byte("line 2\n")); err != nil {
|
||||
|
@ -76,7 +76,7 @@ func TestDropMessages(t *testing.T) {
|
|||
|
||||
func TestCaller(t *testing.T) {
|
||||
tw := &testWriter{}
|
||||
e := &GoogleEmitter{Writer: Writer{Next: tw}}
|
||||
e := GoogleEmitter{Writer: &Writer{Next: tw}}
|
||||
bl := &BasicLogger{
|
||||
Emitter: e,
|
||||
Level: Debug,
|
||||
|
@ -94,7 +94,7 @@ func BenchmarkGoogleLogging(b *testing.B) {
|
|||
tw := &testWriter{
|
||||
limit: 1, // Only record one message.
|
||||
}
|
||||
e := &GoogleEmitter{Writer: Writer{Next: tw}}
|
||||
e := GoogleEmitter{Writer: &Writer{Next: tw}}
|
||||
bl := &BasicLogger{
|
||||
Emitter: e,
|
||||
Level: Debug,
|
||||
|
|
|
@ -63,7 +63,7 @@ func checkSet(s *Set, expectedSegments int) error {
|
|||
return fmt.Errorf("incorrect order: key %d (segment %d) >= key %d (segment %d)", prev, nrSegments-1, next, nrSegments)
|
||||
}
|
||||
if got, want := seg.Value(), seg.Start()+valueOffset; got != want {
|
||||
return fmt.Errorf("segment %d has key %d, value %d (expected %d)", nrSegments, seg.Start, got, want)
|
||||
return fmt.Errorf("segment %d has key %d, value %d (expected %d)", nrSegments, seg.Start(), got, want)
|
||||
}
|
||||
prev = next
|
||||
havePrev = true
|
||||
|
|
|
@ -97,7 +97,7 @@ type hostClock struct {
|
|||
}
|
||||
|
||||
// Now implements ktime.Clock.Now.
|
||||
func (hostClock) Now() ktime.Time {
|
||||
func (*hostClock) Now() ktime.Time {
|
||||
return ktime.FromNanoseconds(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ func (t *TestContext) Value(key interface{}) interface{} {
|
|||
case uniqueid.CtxInotifyCookie:
|
||||
return atomic.AddUint32(&lastInotifyCookie, 1)
|
||||
case ktime.CtxRealtimeClock:
|
||||
return hostClock{}
|
||||
return &hostClock{}
|
||||
default:
|
||||
if val, ok := t.otherValues[key]; ok {
|
||||
return val
|
||||
|
|
|
@ -119,7 +119,7 @@ func TestNewPipe(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
if flags := p.flags; test.flags != flags {
|
||||
t.Errorf("%s: got file flags %s, want %s", test.desc, flags, test.flags)
|
||||
t.Errorf("%s: got file flags %v, want %v", test.desc, flags, test.flags)
|
||||
continue
|
||||
}
|
||||
if len(test.readAheadBuffer) != len(p.readAheadBuffer) {
|
||||
|
@ -136,7 +136,7 @@ func TestNewPipe(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
if !fdnotifier.HasFD(int32(f.FD())) {
|
||||
t.Errorf("%s: pipe fd %d is not registered for events", test.desc, f.FD)
|
||||
t.Errorf("%s: pipe fd %d is not registered for events", test.desc, f.FD())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,14 +199,14 @@ func TestListen(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPasscred(t *testing.T) {
|
||||
e := ConnectedEndpoint{}
|
||||
e := &ConnectedEndpoint{}
|
||||
if got, want := e.Passcred(), false; got != want {
|
||||
t.Errorf("Got %#v.Passcred() = %t, want = %t", e, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetLocalAddress(t *testing.T) {
|
||||
e := ConnectedEndpoint{path: "foo"}
|
||||
e := &ConnectedEndpoint{path: "foo"}
|
||||
want := tcpip.FullAddress{Addr: tcpip.Address("foo")}
|
||||
if got, err := e.GetLocalAddress(); err != nil || got != want {
|
||||
t.Errorf("Got %#v.GetLocalAddress() = %#v, %v, want = %#v, %v", e, got, err, want, nil)
|
||||
|
@ -214,7 +214,7 @@ func TestGetLocalAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestQueuedSize(t *testing.T) {
|
||||
e := ConnectedEndpoint{}
|
||||
e := &ConnectedEndpoint{}
|
||||
tests := []struct {
|
||||
name string
|
||||
f func() int64
|
||||
|
|
|
@ -80,7 +80,7 @@ func newTCPMemInode(ctx context.Context, msrc *fs.MountSource, s inet.Stack, dir
|
|||
}
|
||||
|
||||
// Truncate implements fs.InodeOperations.Truncate.
|
||||
func (tcpMemInode) Truncate(context.Context, *fs.Inode, int64) error {
|
||||
func (*tcpMemInode) Truncate(context.Context, *fs.Inode, int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ func newTCPSackInode(ctx context.Context, msrc *fs.MountSource, s inet.Stack) *f
|
|||
}
|
||||
|
||||
// Truncate implements fs.InodeOperations.Truncate.
|
||||
func (tcpSack) Truncate(context.Context, *fs.Inode, int64) error {
|
||||
func (*tcpSack) Truncate(context.Context, *fs.Inode, int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -688,9 +688,9 @@ func (d *netSnmpData) Generate(ctx context.Context, buf *bytes.Buffer) error {
|
|||
if line.prefix == "Tcp" {
|
||||
tcp := stat.(*inet.StatSNMPTCP)
|
||||
// "Tcp" needs special processing because MaxConn is signed. RFC 2012.
|
||||
fmt.Sprintf("%s: %s %d %s\n", line.prefix, sprintSlice(tcp[:3]), int64(tcp[3]), sprintSlice(tcp[4:]))
|
||||
fmt.Fprintf(buf, "%s: %s %d %s\n", line.prefix, sprintSlice(tcp[:3]), int64(tcp[3]), sprintSlice(tcp[4:]))
|
||||
} else {
|
||||
fmt.Sprintf("%s: %s\n", line.prefix, sprintSlice(toSlice(stat)))
|
||||
fmt.Fprintf(buf, "%s: %s\n", line.prefix, sprintSlice(toSlice(stat)))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -140,7 +140,7 @@ func TestSetStatAtime(t *testing.T) {
|
|||
Mask: 0,
|
||||
Atime: linux.NsecToStatxTimestamp(100),
|
||||
}}); err != nil {
|
||||
t.Errorf("SetStat atime without mask failed: %v")
|
||||
t.Errorf("SetStat atime without mask failed: %v", err)
|
||||
}
|
||||
// Atime should be unchanged.
|
||||
if gotStat, err := fd.Stat(ctx, allStatOptions); err != nil {
|
||||
|
@ -155,7 +155,7 @@ func TestSetStatAtime(t *testing.T) {
|
|||
Atime: linux.NsecToStatxTimestamp(100),
|
||||
}
|
||||
if err := fd.SetStat(ctx, vfs.SetStatOptions{Stat: setStat}); err != nil {
|
||||
t.Errorf("SetStat atime with mask failed: %v")
|
||||
t.Errorf("SetStat atime with mask failed: %v", err)
|
||||
}
|
||||
if gotStat, err := fd.Stat(ctx, allStatOptions); err != nil {
|
||||
t.Errorf("Stat got error: %v", err)
|
||||
|
@ -205,7 +205,7 @@ func TestSetStat(t *testing.T) {
|
|||
Mask: 0,
|
||||
Atime: linux.NsecToStatxTimestamp(100),
|
||||
}}); err != nil {
|
||||
t.Errorf("SetStat atime without mask failed: %v")
|
||||
t.Errorf("SetStat atime without mask failed: %v", err)
|
||||
}
|
||||
// Atime should be unchanged.
|
||||
if gotStat, err := fd.Stat(ctx, allStatOptions); err != nil {
|
||||
|
@ -220,7 +220,7 @@ func TestSetStat(t *testing.T) {
|
|||
Atime: linux.NsecToStatxTimestamp(100),
|
||||
}
|
||||
if err := fd.SetStat(ctx, vfs.SetStatOptions{Stat: setStat}); err != nil {
|
||||
t.Errorf("SetStat atime with mask failed: %v")
|
||||
t.Errorf("SetStat atime with mask failed: %v", err)
|
||||
}
|
||||
if gotStat, err := fd.Stat(ctx, allStatOptions); err != nil {
|
||||
t.Errorf("Stat got error: %v", err)
|
||||
|
|
|
@ -218,56 +218,55 @@ type Stracer interface {
|
|||
SyscallExit(context interface{}, t *Task, sysno, rval uintptr, err error)
|
||||
}
|
||||
|
||||
// SyscallTable is a lookup table of system calls. Critically, a SyscallTable
|
||||
// is *immutable*. In order to make supporting suspend and resume sane, they
|
||||
// must be uniquely registered and may not change during operation.
|
||||
// SyscallTable is a lookup table of system calls.
|
||||
//
|
||||
// +stateify savable
|
||||
// Note that a SyscallTable is not savable directly. Instead, they are saved as
|
||||
// an OS/Arch pair and lookup happens again on restore.
|
||||
type SyscallTable struct {
|
||||
// OS is the operating system that this syscall table implements.
|
||||
OS abi.OS `state:"wait"`
|
||||
OS abi.OS
|
||||
|
||||
// Arch is the architecture that this syscall table targets.
|
||||
Arch arch.Arch `state:"wait"`
|
||||
Arch arch.Arch
|
||||
|
||||
// The OS version that this syscall table implements.
|
||||
Version Version `state:"manual"`
|
||||
Version Version
|
||||
|
||||
// AuditNumber is a numeric constant that represents the syscall table. If
|
||||
// non-zero, auditNumber must be one of the AUDIT_ARCH_* values defined by
|
||||
// linux/audit.h.
|
||||
AuditNumber uint32 `state:"manual"`
|
||||
AuditNumber uint32
|
||||
|
||||
// Table is the collection of functions.
|
||||
Table map[uintptr]Syscall `state:"manual"`
|
||||
Table map[uintptr]Syscall
|
||||
|
||||
// lookup is a fixed-size array that holds the syscalls (indexed by
|
||||
// their numbers). It is used for fast look ups.
|
||||
lookup []SyscallFn `state:"manual"`
|
||||
lookup []SyscallFn
|
||||
|
||||
// Emulate is a collection of instruction addresses to emulate. The
|
||||
// keys are addresses, and the values are system call numbers.
|
||||
Emulate map[usermem.Addr]uintptr `state:"manual"`
|
||||
Emulate map[usermem.Addr]uintptr
|
||||
|
||||
// The function to call in case of a missing system call.
|
||||
Missing MissingFn `state:"manual"`
|
||||
Missing MissingFn
|
||||
|
||||
// Stracer traces this syscall table.
|
||||
Stracer Stracer `state:"manual"`
|
||||
Stracer Stracer
|
||||
|
||||
// External is used to handle an external callback.
|
||||
External func(*Kernel) `state:"manual"`
|
||||
External func(*Kernel)
|
||||
|
||||
// ExternalFilterBefore is called before External is called before the syscall is executed.
|
||||
// External is not called if it returns false.
|
||||
ExternalFilterBefore func(*Task, uintptr, arch.SyscallArguments) bool `state:"manual"`
|
||||
ExternalFilterBefore func(*Task, uintptr, arch.SyscallArguments) bool
|
||||
|
||||
// ExternalFilterAfter is called before External is called after the syscall is executed.
|
||||
// External is not called if it returns false.
|
||||
ExternalFilterAfter func(*Task, uintptr, arch.SyscallArguments) bool `state:"manual"`
|
||||
ExternalFilterAfter func(*Task, uintptr, arch.SyscallArguments) bool
|
||||
|
||||
// FeatureEnable stores the strace and one-shot enable bits.
|
||||
FeatureEnable SyscallFlagsTable `state:"manual"`
|
||||
FeatureEnable SyscallFlagsTable
|
||||
}
|
||||
|
||||
// allSyscallTables contains all known tables.
|
||||
|
|
|
@ -14,16 +14,34 @@
|
|||
|
||||
package kernel
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
// afterLoad is invoked by stateify.
|
||||
func (s *SyscallTable) afterLoad() {
|
||||
otherTable, ok := LookupSyscallTable(s.OS, s.Arch)
|
||||
if !ok {
|
||||
// Couldn't find a reference?
|
||||
panic(fmt.Sprintf("syscall table not found for OS %v Arch %v", s.OS, s.Arch))
|
||||
}
|
||||
"gvisor.dev/gvisor/pkg/abi"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
)
|
||||
|
||||
// Copy the table.
|
||||
*s = *otherTable
|
||||
// syscallTableInfo is used to reload the SyscallTable.
|
||||
//
|
||||
// +stateify savable
|
||||
type syscallTableInfo struct {
|
||||
OS abi.OS
|
||||
Arch arch.Arch
|
||||
}
|
||||
|
||||
// saveSt saves the SyscallTable.
|
||||
func (tc *TaskContext) saveSt() syscallTableInfo {
|
||||
return syscallTableInfo{
|
||||
OS: tc.st.OS,
|
||||
Arch: tc.st.Arch,
|
||||
}
|
||||
}
|
||||
|
||||
// loadSt loads the SyscallTable.
|
||||
func (tc *TaskContext) loadSt(sti syscallTableInfo) {
|
||||
st, ok := LookupSyscallTable(sti.OS, sti.Arch)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("syscall table not found for OS %v, Arch %v", sti.OS, sti.Arch))
|
||||
}
|
||||
tc.st = st // Save the table reference.
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ type TaskContext struct {
|
|||
fu *futex.Manager
|
||||
|
||||
// st is the task's syscall table.
|
||||
st *SyscallTable
|
||||
st *SyscallTable `state:".(syscallTableInfo)"`
|
||||
}
|
||||
|
||||
// release releases all resources held by the TaskContext. release is called by
|
||||
|
|
|
@ -245,7 +245,7 @@ type Clock interface {
|
|||
type WallRateClock struct{}
|
||||
|
||||
// WallTimeUntil implements Clock.WallTimeUntil.
|
||||
func (WallRateClock) WallTimeUntil(t, now Time) time.Duration {
|
||||
func (*WallRateClock) WallTimeUntil(t, now Time) time.Duration {
|
||||
return t.Sub(now)
|
||||
}
|
||||
|
||||
|
@ -254,16 +254,16 @@ func (WallRateClock) WallTimeUntil(t, now Time) time.Duration {
|
|||
type NoClockEvents struct{}
|
||||
|
||||
// Readiness implements waiter.Waitable.Readiness.
|
||||
func (NoClockEvents) Readiness(mask waiter.EventMask) waiter.EventMask {
|
||||
func (*NoClockEvents) Readiness(mask waiter.EventMask) waiter.EventMask {
|
||||
return 0
|
||||
}
|
||||
|
||||
// EventRegister implements waiter.Waitable.EventRegister.
|
||||
func (NoClockEvents) EventRegister(e *waiter.Entry, mask waiter.EventMask) {
|
||||
func (*NoClockEvents) EventRegister(e *waiter.Entry, mask waiter.EventMask) {
|
||||
}
|
||||
|
||||
// EventUnregister implements waiter.Waitable.EventUnregister.
|
||||
func (NoClockEvents) EventUnregister(e *waiter.Entry) {
|
||||
func (*NoClockEvents) EventUnregister(e *waiter.Entry) {
|
||||
}
|
||||
|
||||
// ClockEventsQueue implements waiter.Waitable by wrapping waiter.Queue and
|
||||
|
@ -273,7 +273,7 @@ type ClockEventsQueue struct {
|
|||
}
|
||||
|
||||
// Readiness implements waiter.Waitable.Readiness.
|
||||
func (ClockEventsQueue) Readiness(mask waiter.EventMask) waiter.EventMask {
|
||||
func (*ClockEventsQueue) Readiness(mask waiter.EventMask) waiter.EventMask {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -241,10 +241,7 @@ func Register(name string, instance interface{}, fns Fns) {
|
|||
//
|
||||
// This function is used by the stateify tool.
|
||||
func IsZeroValue(val interface{}) bool {
|
||||
if val == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
|
||||
return val == nil || reflect.ValueOf(val).Elem().IsZero()
|
||||
}
|
||||
|
||||
// step captures one encoding / decoding step. On each step, there is up to one
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestEthernetAddressFromMulticastIPv4Address(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got := EthernetAddressFromMulticastIPv4Address(test.addr); got != test.expectedLinkAddr {
|
||||
t.Fatalf("got EthernetAddressFromMulticastIPv4Address(%s) = %s, want = %s", got, test.expectedLinkAddr)
|
||||
t.Fatalf("got EthernetAddressFromMulticastIPv4Address(%s) = %s, want = %s", test.addr, got, test.expectedLinkAddr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ func TestNDPNeighborAdvert(t *testing.T) {
|
|||
|
||||
// Make sure flags got updated in the backing buffer.
|
||||
if got := b[ndpNAFlagsOffset]; got != 64 {
|
||||
t.Errorf("got flags byte = %d, want = 64")
|
||||
t.Errorf("got flags byte = %d, want = 64", got)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ func (p PacketDispatchMode) String() string {
|
|||
case PacketMMap:
|
||||
return "PacketMMap"
|
||||
default:
|
||||
return fmt.Sprintf("unknown packet dispatch mode %v", p)
|
||||
return fmt.Sprintf("unknown packet dispatch mode '%d'", p)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ func TestDirectRequest(t *testing.T) {
|
|||
// Sleep tests are gross, but this will only potentially flake
|
||||
// if there's a bug. If there is no bug this will reliably
|
||||
// succeed.
|
||||
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel()
|
||||
if pkt, ok := c.linkEP.ReadContext(ctx); ok {
|
||||
t.Errorf("stackAddrBad: unexpected packet sent, Proto=%v", pkt.Proto)
|
||||
}
|
||||
|
|
|
@ -1959,7 +1959,7 @@ func TestAutoGenAddrDeprecateFromPI(t *testing.T) {
|
|||
// addr2 is deprecated but if explicitly requested, it should be used.
|
||||
fullAddr2 := tcpip.FullAddress{Addr: addr2.Address, NIC: nicID}
|
||||
if got := addrForNewConnectionWithAddr(t, s, fullAddr2); got != addr2.Address {
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", got, addr2.Address)
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", fullAddr2, got, addr2.Address)
|
||||
}
|
||||
|
||||
// Another PI w/ 0 preferred lifetime should not result in a deprecation
|
||||
|
@ -1972,7 +1972,7 @@ func TestAutoGenAddrDeprecateFromPI(t *testing.T) {
|
|||
}
|
||||
expectPrimaryAddr(addr1)
|
||||
if got := addrForNewConnectionWithAddr(t, s, fullAddr2); got != addr2.Address {
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", got, addr2.Address)
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", fullAddr2, got, addr2.Address)
|
||||
}
|
||||
|
||||
// Refresh lifetimes of addr generated from prefix2.
|
||||
|
@ -2084,7 +2084,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
|
|||
// addr1 is deprecated but if explicitly requested, it should be used.
|
||||
fullAddr1 := tcpip.FullAddress{Addr: addr1.Address, NIC: nicID}
|
||||
if got := addrForNewConnectionWithAddr(t, s, fullAddr1); got != addr1.Address {
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", got, addr1.Address)
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", fullAddr1, got, addr1.Address)
|
||||
}
|
||||
|
||||
// Refresh valid lifetime for addr of prefix1, w/ 0 preferred lifetime to make
|
||||
|
@ -2097,7 +2097,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
|
|||
}
|
||||
expectPrimaryAddr(addr2)
|
||||
if got := addrForNewConnectionWithAddr(t, s, fullAddr1); got != addr1.Address {
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", got, addr1.Address)
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", fullAddr1, got, addr1.Address)
|
||||
}
|
||||
|
||||
// Refresh lifetimes for addr of prefix1.
|
||||
|
@ -2121,7 +2121,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
|
|||
// addr2 should be the primary endpoint now since it is not deprecated.
|
||||
expectPrimaryAddr(addr2)
|
||||
if got := addrForNewConnectionWithAddr(t, s, fullAddr1); got != addr1.Address {
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", got, addr1.Address)
|
||||
t.Errorf("got addrForNewConnectionWithAddr(_, _, %+v) = %s, want = %s", fullAddr1, got, addr1.Address)
|
||||
}
|
||||
|
||||
// Wait for addr of prefix1 to be invalidated.
|
||||
|
@ -2564,7 +2564,7 @@ func TestAutoGenAddrAfterRemoval(t *testing.T) {
|
|||
AddressWithPrefix: addr2,
|
||||
}
|
||||
if err := s.AddProtocolAddressWithOptions(nicID, protoAddr2, stack.FirstPrimaryEndpoint); err != nil {
|
||||
t.Fatalf("AddProtocolAddressWithOptions(%d, %+v, %d, %s) = %s", nicID, protoAddr2, stack.FirstPrimaryEndpoint, err)
|
||||
t.Fatalf("AddProtocolAddressWithOptions(%d, %+v, %d) = %s", nicID, protoAddr2, stack.FirstPrimaryEndpoint, err)
|
||||
}
|
||||
// addr2 should be more preferred now since it is at the front of the primary
|
||||
// list.
|
||||
|
@ -3483,7 +3483,8 @@ func TestRouterSolicitation(t *testing.T) {
|
|||
e.Endpoint.LinkEPCapabilities |= stack.CapabilityResolutionRequired
|
||||
waitForPkt := func(timeout time.Duration) {
|
||||
t.Helper()
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
p, ok := e.ReadContext(ctx)
|
||||
if !ok {
|
||||
t.Fatal("timed out waiting for packet")
|
||||
|
@ -3513,7 +3514,8 @@ func TestRouterSolicitation(t *testing.T) {
|
|||
}
|
||||
waitForNothing := func(timeout time.Duration) {
|
||||
t.Helper()
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
if _, ok := e.ReadContext(ctx); ok {
|
||||
t.Fatal("unexpectedly got a packet")
|
||||
}
|
||||
|
|
|
@ -1445,19 +1445,19 @@ func TestOutgoingBroadcastWithEmptyRouteTable(t *testing.T) {
|
|||
|
||||
protoAddr := tcpip.ProtocolAddress{Protocol: fakeNetNumber, AddressWithPrefix: tcpip.AddressWithPrefix{header.IPv4Any, 0}}
|
||||
if err := s.AddProtocolAddress(1, protoAddr); err != nil {
|
||||
t.Fatalf("AddProtocolAddress(1, %s) failed: %s", protoAddr, err)
|
||||
t.Fatalf("AddProtocolAddress(1, %v) failed: %v", protoAddr, err)
|
||||
}
|
||||
r, err := s.FindRoute(1, header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, false /* multicastLoop */)
|
||||
if err != nil {
|
||||
t.Fatalf("FindRoute(1, %s, %s, %d) failed: %s", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
t.Fatalf("FindRoute(1, %v, %v, %d) failed: %v", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
}
|
||||
if err := verifyRoute(r, stack.Route{LocalAddress: header.IPv4Any, RemoteAddress: header.IPv4Broadcast}); err != nil {
|
||||
t.Errorf("FindRoute(1, %s, %s, %d) returned unexpected Route: %s)", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
t.Errorf("FindRoute(1, %v, %v, %d) returned unexpected Route: %v", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
}
|
||||
|
||||
// If the NIC doesn't exist, it won't work.
|
||||
if _, err := s.FindRoute(2, header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, false /* multicastLoop */); err != tcpip.ErrNetworkUnreachable {
|
||||
t.Fatalf("got FindRoute(2, %s, %s, %d) = %s want = %s", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err, tcpip.ErrNetworkUnreachable)
|
||||
t.Fatalf("got FindRoute(2, %v, %v, %d) = %v want = %v", header.IPv4Any, header.IPv4Broadcast, fakeNetNumber, err, tcpip.ErrNetworkUnreachable)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1483,12 +1483,12 @@ func TestOutgoingBroadcastWithRouteTable(t *testing.T) {
|
|||
}
|
||||
nic1ProtoAddr := tcpip.ProtocolAddress{fakeNetNumber, nic1Addr}
|
||||
if err := s.AddProtocolAddress(1, nic1ProtoAddr); err != nil {
|
||||
t.Fatalf("AddProtocolAddress(1, %s) failed: %s", nic1ProtoAddr, err)
|
||||
t.Fatalf("AddProtocolAddress(1, %v) failed: %v", nic1ProtoAddr, err)
|
||||
}
|
||||
|
||||
nic2ProtoAddr := tcpip.ProtocolAddress{fakeNetNumber, nic2Addr}
|
||||
if err := s.AddProtocolAddress(2, nic2ProtoAddr); err != nil {
|
||||
t.Fatalf("AddAddress(2, %s) failed: %s", nic2ProtoAddr, err)
|
||||
t.Fatalf("AddAddress(2, %v) failed: %v", nic2ProtoAddr, err)
|
||||
}
|
||||
|
||||
// Set the initial route table.
|
||||
|
@ -1503,10 +1503,10 @@ func TestOutgoingBroadcastWithRouteTable(t *testing.T) {
|
|||
// When an interface is given, the route for a broadcast goes through it.
|
||||
r, err := s.FindRoute(1, nic1Addr.Address, header.IPv4Broadcast, fakeNetNumber, false /* multicastLoop */)
|
||||
if err != nil {
|
||||
t.Fatalf("FindRoute(1, %s, %s, %d) failed: %s", nic1Addr.Address, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
t.Fatalf("FindRoute(1, %v, %v, %d) failed: %v", nic1Addr.Address, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
}
|
||||
if err := verifyRoute(r, stack.Route{LocalAddress: nic1Addr.Address, RemoteAddress: header.IPv4Broadcast}); err != nil {
|
||||
t.Errorf("FindRoute(1, %s, %s, %d) returned unexpected Route: %s)", nic1Addr.Address, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
t.Errorf("FindRoute(1, %v, %v, %d) returned unexpected Route: %v", nic1Addr.Address, header.IPv4Broadcast, fakeNetNumber, err)
|
||||
}
|
||||
|
||||
// When an interface is not given, it consults the route table.
|
||||
|
@ -2399,7 +2399,7 @@ func TestNICContextPreservation(t *testing.T) {
|
|||
t.Fatalf("got nicinfos[%d] = _, %t, want _, true; nicinfos = %+v", id, ok, nicinfos)
|
||||
}
|
||||
if got, want := nicinfo.Context == test.want, true; got != want {
|
||||
t.Fatal("got nicinfo.Context == ctx = %t, want %t; nicinfo.Context = %p, ctx = %p", got, want, nicinfo.Context, test.want)
|
||||
t.Fatalf("got nicinfo.Context == ctx = %t, want %t; nicinfo.Context = %p, ctx = %p", got, want, nicinfo.Context, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -2768,7 +2768,7 @@ func TestNewPEBOnPromotionToPermanent(t *testing.T) {
|
|||
{
|
||||
subnet, err := tcpip.NewSubnet("\x00", "\x00")
|
||||
if err != nil {
|
||||
t.Fatalf("NewSubnet failed:", err)
|
||||
t.Fatalf("NewSubnet failed: %v", err)
|
||||
}
|
||||
s.SetRouteTable([]tcpip.Route{{Destination: subnet, Gateway: "\x00", NIC: 1}})
|
||||
}
|
||||
|
@ -2782,11 +2782,11 @@ func TestNewPEBOnPromotionToPermanent(t *testing.T) {
|
|||
// permanentExpired kind.
|
||||
r, err := s.FindRoute(1, "\x01", "\x02", fakeNetNumber, false)
|
||||
if err != nil {
|
||||
t.Fatal("FindRoute failed:", err)
|
||||
t.Fatalf("FindRoute failed: %v", err)
|
||||
}
|
||||
defer r.Release()
|
||||
if err := s.RemoveAddress(1, "\x01"); err != nil {
|
||||
t.Fatalf("RemoveAddress failed:", err)
|
||||
t.Fatalf("RemoveAddress failed: %v", err)
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2798,7 +2798,7 @@ func TestNewPEBOnPromotionToPermanent(t *testing.T) {
|
|||
// Add some other address with peb set to
|
||||
// FirstPrimaryEndpoint.
|
||||
if err := s.AddAddressWithOptions(1, fakeNetNumber, "\x03", stack.FirstPrimaryEndpoint); err != nil {
|
||||
t.Fatal("AddAddressWithOptions failed:", err)
|
||||
t.Fatalf("AddAddressWithOptions failed: %v", err)
|
||||
|
||||
}
|
||||
|
||||
|
@ -2806,7 +2806,7 @@ func TestNewPEBOnPromotionToPermanent(t *testing.T) {
|
|||
// make sure the new peb was respected.
|
||||
// (The address should just be promoted now).
|
||||
if err := s.AddAddressWithOptions(1, fakeNetNumber, "\x01", ps); err != nil {
|
||||
t.Fatal("AddAddressWithOptions failed:", err)
|
||||
t.Fatalf("AddAddressWithOptions failed: %v", err)
|
||||
}
|
||||
var primaryAddrs []tcpip.Address
|
||||
for _, pa := range s.NICInfo()[1].ProtocolAddresses {
|
||||
|
@ -2839,11 +2839,11 @@ func TestNewPEBOnPromotionToPermanent(t *testing.T) {
|
|||
// GetMainNICAddress; else, our original address
|
||||
// should be returned.
|
||||
if err := s.RemoveAddress(1, "\x03"); err != nil {
|
||||
t.Fatalf("RemoveAddress failed:", err)
|
||||
t.Fatalf("RemoveAddress failed: %v", err)
|
||||
}
|
||||
addr, err = s.GetMainNICAddress(1, fakeNetNumber)
|
||||
if err != nil {
|
||||
t.Fatal("s.GetMainNICAddress failed:", err)
|
||||
t.Fatalf("s.GetMainNICAddress failed: %v", err)
|
||||
}
|
||||
if ps == stack.NeverPrimaryEndpoint {
|
||||
if want := (tcpip.AddressWithPrefix{}); addr != want {
|
||||
|
|
|
@ -218,7 +218,7 @@ func TestAddressWithPrefixSubnet(t *testing.T) {
|
|||
gotSubnet := ap.Subnet()
|
||||
wantSubnet, err := NewSubnet(tt.subnetAddr, tt.subnetMask)
|
||||
if err != nil {
|
||||
t.Error("NewSubnet(%q, %q) failed: %s", tt.subnetAddr, tt.subnetMask, err)
|
||||
t.Errorf("NewSubnet(%q, %q) failed: %s", tt.subnetAddr, tt.subnetMask, err)
|
||||
continue
|
||||
}
|
||||
if gotSubnet != wantSubnet {
|
||||
|
|
|
@ -284,7 +284,7 @@ func TestTCPResetSentForACKWhenNotUsingSynCookies(t *testing.T) {
|
|||
// are released instantly on Close.
|
||||
tcpTW := tcpip.TCPTimeWaitTimeoutOption(1 * time.Millisecond)
|
||||
if err := c.Stack().SetTransportProtocolOption(tcp.ProtocolNumber, tcpTW); err != nil {
|
||||
t.Fatalf("e.stack.SetTransportProtocolOption(%d, %s) = %s", tcp.ProtocolNumber, tcpTW, err)
|
||||
t.Fatalf("e.stack.SetTransportProtocolOption(%d, %v) = %v", tcp.ProtocolNumber, tcpTW, err)
|
||||
}
|
||||
|
||||
c.EP.Close()
|
||||
|
@ -5607,7 +5607,7 @@ func TestReceiveBufferAutoTuningApplicationLimited(t *testing.T) {
|
|||
return
|
||||
}
|
||||
if w := tcp.WindowSize(); w == 0 || w > uint16(wantRcvWnd) {
|
||||
t.Errorf("expected a non-zero window: got %d, want <= wantRcvWnd", w, wantRcvWnd)
|
||||
t.Errorf("expected a non-zero window: got %d, want <= wantRcvWnd", w)
|
||||
}
|
||||
},
|
||||
))
|
||||
|
|
|
@ -217,7 +217,8 @@ func (c *Context) Stack() *stack.Stack {
|
|||
func (c *Context) CheckNoPacketTimeout(errMsg string, wait time.Duration) {
|
||||
c.t.Helper()
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), wait)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), wait)
|
||||
defer cancel()
|
||||
if _, ok := c.linkEP.ReadContext(ctx); ok {
|
||||
c.t.Fatal(errMsg)
|
||||
}
|
||||
|
@ -235,7 +236,8 @@ func (c *Context) CheckNoPacket(errMsg string) {
|
|||
func (c *Context) GetPacket() []byte {
|
||||
c.t.Helper()
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
p, ok := c.linkEP.ReadContext(ctx)
|
||||
if !ok {
|
||||
c.t.Fatalf("Packet wasn't written out")
|
||||
|
@ -486,7 +488,8 @@ func (c *Context) CreateV6Endpoint(v6only bool) {
|
|||
func (c *Context) GetV6Packet() []byte {
|
||||
c.t.Helper()
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
p, ok := c.linkEP.ReadContext(ctx)
|
||||
if !ok {
|
||||
c.t.Fatalf("Packet wasn't written out")
|
||||
|
|
|
@ -358,7 +358,8 @@ func (c *testContext) createEndpointForFlow(flow testFlow) {
|
|||
func (c *testContext) getPacketAndVerify(flow testFlow, checkers ...checker.NetworkChecker) []byte {
|
||||
c.t.Helper()
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
p, ok := c.linkEP.ReadContext(ctx)
|
||||
if !ok {
|
||||
c.t.Fatalf("Packet wasn't written out")
|
||||
|
@ -607,7 +608,7 @@ func testReadInternal(c *testContext, flow testFlow, packetShouldBeDropped, expe
|
|||
// Check the peer address.
|
||||
h := flow.header4Tuple(incoming)
|
||||
if addr.Addr != h.srcAddr.Addr {
|
||||
c.t.Fatalf("unexpected remote address: got %s, want %s", addr.Addr, h.srcAddr)
|
||||
c.t.Fatalf("unexpected remote address: got %s, want %v", addr.Addr, h.srcAddr)
|
||||
}
|
||||
|
||||
// Check the payload.
|
||||
|
@ -1565,7 +1566,8 @@ func TestV4UnknownDestination(t *testing.T) {
|
|||
}
|
||||
c.injectPacket(tc.flow, payload)
|
||||
if !tc.icmpRequired {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
if p, ok := c.linkEP.ReadContext(ctx); ok {
|
||||
t.Fatalf("unexpected packet received: %+v", p)
|
||||
}
|
||||
|
@ -1573,7 +1575,8 @@ func TestV4UnknownDestination(t *testing.T) {
|
|||
}
|
||||
|
||||
// ICMP required.
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
p, ok := c.linkEP.ReadContext(ctx)
|
||||
if !ok {
|
||||
t.Fatalf("packet wasn't written out")
|
||||
|
@ -1641,7 +1644,8 @@ func TestV6UnknownDestination(t *testing.T) {
|
|||
}
|
||||
c.injectPacket(tc.flow, payload)
|
||||
if !tc.icmpRequired {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
if p, ok := c.linkEP.ReadContext(ctx); ok {
|
||||
t.Fatalf("unexpected packet received: %+v", p)
|
||||
}
|
||||
|
@ -1649,7 +1653,8 @@ func TestV6UnknownDestination(t *testing.T) {
|
|||
}
|
||||
|
||||
// ICMP required.
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
p, ok := c.linkEP.ReadContext(ctx)
|
||||
if !ok {
|
||||
t.Fatalf("packet wasn't written out")
|
||||
|
|
|
@ -65,7 +65,7 @@ func newCompatEmitter(logFD int) (*compatEmitter, error) {
|
|||
|
||||
if logFD > 0 {
|
||||
f := os.NewFile(uintptr(logFD), "user log file")
|
||||
target := &log.MultiEmitter{c.sink, &log.K8sJSONEmitter{log.Writer{Next: f}}}
|
||||
target := &log.MultiEmitter{c.sink, log.K8sJSONEmitter{&log.Writer{Next: f}}}
|
||||
c.sink = &log.BasicLogger{Level: log.Info, Emitter: target}
|
||||
}
|
||||
return c, nil
|
||||
|
|
|
@ -96,7 +96,7 @@ func (c *uds) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{})
|
|||
|
||||
listener, err := net.Listen("unix", c.socketPath)
|
||||
if err != nil {
|
||||
log.Fatal("error listening on socket %q:", c.socketPath, err)
|
||||
log.Fatalf("error listening on socket %q: %v", c.socketPath, err)
|
||||
}
|
||||
|
||||
go server(listener, outputFile)
|
||||
|
|
|
@ -342,11 +342,11 @@ func main() {
|
|||
func newEmitter(format string, logFile io.Writer) log.Emitter {
|
||||
switch format {
|
||||
case "text":
|
||||
return &log.GoogleEmitter{log.Writer{Next: logFile}}
|
||||
return log.GoogleEmitter{&log.Writer{Next: logFile}}
|
||||
case "json":
|
||||
return &log.JSONEmitter{log.Writer{Next: logFile}}
|
||||
return log.JSONEmitter{&log.Writer{Next: logFile}}
|
||||
case "json-k8s":
|
||||
return &log.K8sJSONEmitter{log.Writer{Next: logFile}}
|
||||
return log.K8sJSONEmitter{&log.Writer{Next: logFile}}
|
||||
}
|
||||
cmd.Fatalf("invalid log format %q, must be 'text', 'json', or 'json-k8s'", format)
|
||||
panic("unreachable")
|
||||
|
|
|
@ -53,7 +53,7 @@ func verifyPid(pid int, path string) error {
|
|||
if scanner.Err() != nil {
|
||||
return scanner.Err()
|
||||
}
|
||||
return fmt.Errorf("got: %s, want: %d", gots, pid)
|
||||
return fmt.Errorf("got: %v, want: %d", gots, pid)
|
||||
}
|
||||
|
||||
// TestCgroup sets cgroup options and checks that cgroup was properly configured.
|
||||
|
@ -106,7 +106,7 @@ func TestMemCGroup(t *testing.T) {
|
|||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
t.Fatalf("%vMB is less than %vMB: %v", memUsage>>20, allocMemSize>>20)
|
||||
t.Fatalf("%vMB is less than %vMB", memUsage>>20, allocMemSize>>20)
|
||||
}
|
||||
|
||||
// TestCgroup sets cgroup options and checks that cgroup was properly configured.
|
||||
|
|
|
@ -32,6 +32,6 @@ func TestBlacklists(t *testing.T) {
|
|||
t.Fatalf("error parsing blacklist: %v", err)
|
||||
}
|
||||
if *blacklistFile != "" && len(bl) == 0 {
|
||||
t.Errorf("got empty blacklist for file %q", blacklistFile)
|
||||
t.Errorf("got empty blacklist for file %q", *blacklistFile)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ func getTests(d dockerutil.Docker, blacklist map[string]struct{}) ([]testing.Int
|
|||
F: func(t *testing.T) {
|
||||
// Is the test blacklisted?
|
||||
if _, ok := blacklist[tc]; ok {
|
||||
t.Skip("SKIP: blacklisted test %q", tc)
|
||||
t.Skipf("SKIP: blacklisted test %q", tc)
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -206,7 +206,7 @@ func main() {
|
|||
initCalls = append(initCalls, fmt.Sprintf("%sRegister(\"%s.%s\", (*%s)(nil), state.Fns{Save: (*%s).save, Load: (*%s).load})", statePrefix, *fullPkg, name, name, name, name))
|
||||
}
|
||||
emitZeroCheck := func(name string) {
|
||||
fmt.Fprintf(outputFile, " if !%sIsZeroValue(x.%s) { m.Failf(\"%s is %%v, expected zero\", x.%s) }\n", statePrefix, name, name, name)
|
||||
fmt.Fprintf(outputFile, " if !%sIsZeroValue(&x.%s) { m.Failf(\"%s is %%#v, expected zero\", &x.%s) }\n", statePrefix, name, name, name)
|
||||
}
|
||||
emitLoadValue := func(name, typName string) {
|
||||
fmt.Fprintf(outputFile, " m.LoadValue(\"%s\", new(%s), func(y interface{}) { x.load%s(y.(%s)) })\n", name, typName, camelCased(name), typName)
|
||||
|
|
|
@ -9,27 +9,6 @@
|
|||
"/external/": "allowed: not subject to unsafe naming rules"
|
||||
}
|
||||
},
|
||||
"copylocks": {
|
||||
"exclude_files": {
|
||||
".*_state_autogen.go": "fix: m.Failf copies by value",
|
||||
"/pkg/log/json.go": "fix: Emit passes lock by value: gvisor.dev/gvisor/pkg/log.JSONEmitter contains gvisor.dev/gvisor/pkg/log.Writer contains gvisor.dev/gvisor/pkg/sync.Mutex",
|
||||
"/pkg/log/log_test.go": "fix: call of fmt.Printf copies lock value: gvisor.dev/gvisor/pkg/log.Writer contains gvisor.dev/gvisor/pkg/sync.Mutex",
|
||||
"/pkg/sentry/fs/host/socket_test.go": "fix: call of t.Errorf copies lock value: gvisor.dev/gvisor/pkg/sentry/fs/host.ConnectedEndpoint contains gvisor.dev/gvisor/pkg/refs.AtomicRefCount contains gvisor.dev/gvisor/pkg/sync.Mutex",
|
||||
"/pkg/sentry/fs/proc/sys_net.go": "fix: Truncate passes lock by value: gvisor.dev/gvisor/pkg/sentry/fs/proc.tcpMemInode contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.SimpleFileInode contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.InodeSimpleAttributes contains gvisor.dev/gvisor/pkg/sync.RWMutex",
|
||||
"/pkg/sentry/fs/proc/sys_net.go": "fix: Truncate passes lock by value: gvisor.dev/gvisor/pkg/sentry/fs/proc.tcpSack contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.SimpleFileInode contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.InodeSimpleAttributes contains gvisor.dev/gvisor/pkg/sync.RWMutex",
|
||||
"/pkg/sentry/fs/tty/slave.go": "fix: Truncate passes lock by value: gvisor.dev/gvisor/pkg/sentry/fs/tty.slaveInodeOperations contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.SimpleFileInode contains gvisor.dev/gvisor/pkg/sentry/fs/fsutil.InodeSimpleAttributes contains gvisor.dev/gvisor/pkg/sync.RWMutex",
|
||||
"/pkg/sentry/kernel/time/time.go": "fix: Readiness passes lock by value: gvisor.dev/gvisor/pkg/sentry/kernel/time.ClockEventsQueue contains gvisor.dev/gvisor/pkg/waiter.Queue contains gvisor.dev/gvisor/pkg/sync.RWMutex",
|
||||
"/pkg/sentry/kernel/syscalls_state.go": "fix: assignment copies lock value to *s: gvisor.dev/gvisor/pkg/sentry/kernel.SyscallTable contains gvisor.dev/gvisor/pkg/sentry/kernel.SyscallFlagsTable contains gvisor.dev/gvisor/pkg/sync.Mutex"
|
||||
}
|
||||
},
|
||||
"lostcancel": {
|
||||
"exclude_files": {
|
||||
"/pkg/tcpip/network/arp/arp_test.go": "fix: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak",
|
||||
"/pkg/tcpip/stack/ndp_test.go": "fix: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak",
|
||||
"/pkg/tcpip/transport/udp/udp_test.go": "fix: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak",
|
||||
"/pkg/tcpip/transport/tcp/testing/context/context.go": "fix: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak"
|
||||
}
|
||||
},
|
||||
"nilness": {
|
||||
"exclude_files": {
|
||||
"/com_github_vishvananda_netlink/route_linux.go": "allowed: false positive",
|
||||
|
@ -40,37 +19,6 @@
|
|||
"/external/io_opencensus_go/tag/map_codec.go": "allowed: false positive"
|
||||
}
|
||||
},
|
||||
"printf": {
|
||||
"exclude_files": {
|
||||
".*_abi_autogen_test.go": "fix: Sprintf format has insufficient args",
|
||||
"/pkg/segment/test/segment_test.go": "fix: Errorf format %d arg seg.Start is a func value, not called",
|
||||
"/pkg/tcpip/tcpip_test.go": "fix: Error call has possible formatting directive %q",
|
||||
"/pkg/tcpip/header/eth_test.go": "fix: Fatalf format %s reads arg #3, but call has 2 args",
|
||||
"/pkg/tcpip/header/ndp_test.go": "fix: Errorf format %d reads arg #1, but call has 0 args",
|
||||
"/pkg/eventchannel/event_test.go": "fix: Fatal call has possible formatting directive %v",
|
||||
"/pkg/tcpip/stack/ndp.go": "fix: Fatalf format %s has arg protocolAddr of wrong type gvisor.dev/gvisor/pkg/tcpip.ProtocolAddress",
|
||||
"/pkg/sentry/fs/fdpipe/pipe_test.go": "fix: Errorf format %s has arg flags of wrong type gvisor.dev/gvisor/pkg/sentry/fs.FileFlags",
|
||||
"/pkg/sentry/fs/fdpipe/pipe_test.go": "fix: Errorf format %d arg f.FD is a func value, not called",
|
||||
"/pkg/tcpip/link/fdbased/endpoint.go": "fix: Sprintf format %v with arg p causes recursive String method call",
|
||||
"/pkg/tcpip/transport/udp/udp_test.go": "fix: Fatalf format %s has arg h.srcAddr of wrong type gvisor.dev/gvisor/pkg/tcpip.FullAddress",
|
||||
"/pkg/tcpip/transport/tcp/tcp_test.go": "fix: Fatalf format %s has arg tcpTW of wrong type gvisor.dev/gvisor/pkg/tcpip.TCPTimeWaitTimeoutOption",
|
||||
"/pkg/tcpip/transport/tcp/tcp_test.go": "fix: Errorf call needs 1 arg but has 2 args",
|
||||
"/pkg/tcpip/stack/ndp_test.go": "fix: Errorf format %s reads arg #3, but call has 2 args",
|
||||
"/pkg/tcpip/stack/ndp_test.go": "fix: Fatalf format %s reads arg #5, but call has 4 args",
|
||||
"/pkg/tcpip/stack/stack_test.go": "fix: Fatalf format %s has arg protoAddr of wrong type gvisor.dev/gvisor/pkg/tcpip.ProtocolAddress",
|
||||
"/pkg/tcpip/stack/stack_test.go": "fix: Fatalf format %s has arg nic1ProtoAddr of wrong type gvisor.dev/gvisor/pkg/tcpip.ProtocolAddress",
|
||||
"/pkg/tcpip/stack/stack_test.go": "fix: Fatalf format %s has arg nic2ProtoAddr of wrong type gvisor.dev/gvisor/pkg/tcpip.ProtocolAddress",
|
||||
"/pkg/tcpip/stack/stack_test.go": "fix: Fatal call has possible formatting directive %t",
|
||||
"/pkg/tcpip/stack/stack_test.go": "fix: Fatalf call has arguments but no formatting directives",
|
||||
"/pkg/tcpip/link/fdbased/endpoint.go": "fix: Sprintf format %v with arg p causes recursive String method call",
|
||||
"/pkg/sentry/fsimpl/tmpfs/stat_test.go": "fix: Errorf format %v reads arg #1, but call has 0 args",
|
||||
"/runsc/container/test_app/test_app.go": "fix: Fatal call has possible formatting directive %q",
|
||||
"/test/root/cgroup_test.go": "fix: Errorf format %s has arg gots of wrong type []int",
|
||||
"/test/root/cgroup_test.go": "fix: Fatalf format %v reads arg #3, but call has 2 args",
|
||||
"/test/runtimes/runner.go": "fix: Skip call has possible formatting directive %q",
|
||||
"/test/runtimes/blacklist_test.go": "fix: Errorf format %q has arg blacklistFile of wrong type *string"
|
||||
}
|
||||
},
|
||||
"structtag": {
|
||||
"exclude_files": {
|
||||
"/external/": "allowed: may use arbitrary tags"
|
||||
|
@ -88,11 +36,5 @@
|
|||
"/pkg/sentry/platform/safecopy/safecopy_unsafe.go": "allowed: special case",
|
||||
"/pkg/sentry/vfs/mount_unsafe.go": "allowed: special case"
|
||||
}
|
||||
},
|
||||
"unusedresult": {
|
||||
"exclude_files": {
|
||||
"/pkg/sentry/fsimpl/proc/task_net.go": "fix: result of fmt.Sprintf call not used",
|
||||
"/pkg/sentry/fsimpl/proc/tasks_net.go": "fix: result of fmt.Sprintf call not used"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue