summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--nogo.yaml233
-rw-r--r--pkg/bpf/decoder.go2
-rw-r--r--pkg/sentry/fs/proc/sys_net.go4
-rw-r--r--pkg/sentry/fs/tmpfs/inode_file.go6
-rw-r--r--pkg/sentry/fsimpl/fuse/dev_test.go2
-rw-r--r--pkg/sentry/kernel/pipe/pipe_test.go3
-rw-r--r--pkg/sentry/kernel/sessions.go32
-rw-r--r--pkg/sentry/kernel/vdso.go2
-rw-r--r--pkg/sentry/vfs/mount_test.go35
-rw-r--r--pkg/unet/unet_test.go157
-rw-r--r--runsc/cmd/checkpoint.go3
-rw-r--r--runsc/config/flags.go2
-rw-r--r--runsc/specutils/specutils.go3
-rw-r--r--tools/go_generics/imports.go4
-rw-r--r--tools/go_marshal/test/escape/escape.go1
-rw-r--r--tools/go_marshal/test/test.go2
16 files changed, 135 insertions, 356 deletions
diff --git a/nogo.yaml b/nogo.yaml
index c856830cb..5c1737f59 100644
--- a/nogo.yaml
+++ b/nogo.yaml
@@ -64,21 +64,10 @@ global:
- pkg/abi/linux/fuse.go:25
- pkg/abi/linux/socket.go:113
- pkg/abi/linux/tty.go:73
- - pkg/bpf/decoder.go:112
- pkg/cpuid/cpuid_x86.go:675
- - pkg/eventchannel/event.go:193
- - pkg/eventchannel/event.go:27
- - pkg/eventchannel/event_test.go:22
- - pkg/eventchannel/rate.go:19
- pkg/gohacks/gohacks_unsafe.go:33
- pkg/log/json.go:30
- pkg/log/log.go:359
- - pkg/merkletree/merkletree.go:230
- - pkg/merkletree/merkletree.go:243
- - pkg/merkletree/merkletree.go:249
- - pkg/merkletree/merkletree.go:266
- - pkg/merkletree/merkletree.go:355
- - pkg/merkletree/merkletree.go:369
- pkg/metric/metric_test.go:20
- pkg/p9/p9test/client_test.go:687
- pkg/p9/transport_test.go:196
@@ -121,14 +110,6 @@ global:
- pkg/sentry/fs/gofer/attr.go:120
- pkg/sentry/fs/gofer/fifo.go:33
- pkg/sentry/fs/gofer/inode.go:410
- - pkg/sentry/fsimpl/devpts/devpts.go:110
- - pkg/sentry/fsimpl/devpts/devpts.go:246
- - pkg/sentry/fsimpl/devpts/devpts.go:50
- - pkg/sentry/fsimpl/devpts/master.go:110
- - pkg/sentry/fsimpl/devpts/master.go:55
- - pkg/sentry/fsimpl/devpts/replica.go:113
- - pkg/sentry/fsimpl/devpts/replica.go:57
- - pkg/sentry/fsimpl/devtmpfs/devtmpfs.go:54
- pkg/sentry/fsimpl/ext/disklayout/superblock_64.go:97
- pkg/sentry/fsimpl/ext/disklayout/superblock_old.go:92
- pkg/sentry/fsimpl/ext/disklayout/block_group_32.go:44
@@ -136,203 +117,13 @@ global:
- pkg/sentry/fsimpl/ext/disklayout/inode_old.go:93
- pkg/sentry/fsimpl/ext/disklayout/superblock_32.go:66
- pkg/sentry/fsimpl/ext/disklayout/block_group_64.go:53
- - pkg/sentry/fsimpl/eventfd/eventfd.go:268
- - pkg/sentry/fsimpl/ext/directory.go:163
- - pkg/sentry/fsimpl/ext/directory.go:164
- - pkg/sentry/fsimpl/ext/extent_file.go:142
- - pkg/sentry/fsimpl/ext/extent_file.go:143
- - pkg/sentry/fsimpl/ext/ext.go:105
- - pkg/sentry/fsimpl/ext/filesystem.go:287
- - pkg/sentry/fsimpl/ext/regular_file.go:153
- - pkg/sentry/fsimpl/ext/symlink.go:113
- - pkg/sentry/fsimpl/fuse/connection_control.go:194
- - pkg/sentry/fsimpl/fuse/dev.go:387
- - pkg/sentry/fsimpl/fuse/dev_test.go:318
- - pkg/sentry/fsimpl/fuse/fusefs.go:102
- - pkg/sentry/fsimpl/fuse/read_write.go:129
- pkg/sentry/fsimpl/fuse/request_response.go:71
- - pkg/sentry/fsimpl/gofer/directory.go:135
- - pkg/sentry/fsimpl/gofer/filesystem.go:679
- - pkg/sentry/fsimpl/gofer/gofer.go:1694
- - pkg/sentry/fsimpl/gofer/gofer.go:276
- - pkg/sentry/fsimpl/gofer/regular_file.go:81
- - pkg/sentry/fsimpl/gofer/special_file.go:141
- - pkg/sentry/fsimpl/host/host.go:184
- - pkg/sentry/fsimpl/kernfs/dynamic_bytes_file.go:50
- - pkg/sentry/fsimpl/kernfs/dynamic_bytes_file.go:90
- - pkg/sentry/fsimpl/kernfs/fd_impl_util.go:273
- - pkg/sentry/fsimpl/kernfs/filesystem.go:247
- - pkg/sentry/fsimpl/kernfs/inode_impl_util.go:320
- - pkg/sentry/fsimpl/kernfs/inode_impl_util.go:497
- - pkg/sentry/fsimpl/kernfs/synthetic_directory.go:52
- - pkg/sentry/fsimpl/overlay/directory.go:119
- - pkg/sentry/fsimpl/overlay/filesystem.go:527
- - pkg/sentry/fsimpl/overlay/non_directory.go:152
- - pkg/sentry/fsimpl/overlay/overlay.go:115
- - pkg/sentry/fsimpl/overlay/overlay.go:719
- - pkg/sentry/fsimpl/pipefs/pipefs.go:74
- - pkg/sentry/fsimpl/proc/filesystem.go:52
- - pkg/sentry/fsimpl/proc/filesystem.go:81
- - pkg/sentry/fsimpl/proc/subtasks.go:126
- - pkg/sentry/fsimpl/proc/subtasks.go:189
- - pkg/sentry/fsimpl/proc/task_fds.go:168
- - pkg/sentry/fsimpl/proc/task_fds.go:228
- - pkg/sentry/fsimpl/proc/task_fds.go:301
- - pkg/sentry/fsimpl/proc/task_fds.go:318
- - pkg/sentry/fsimpl/proc/task_fds.go:67
- - pkg/sentry/fsimpl/proc/task_files.go:112
- - pkg/sentry/fsimpl/proc/task_files.go:158
- - pkg/sentry/fsimpl/proc/task_files.go:259
- - pkg/sentry/fsimpl/proc/task_files.go:285
- - pkg/sentry/fsimpl/proc/task_files.go:305
- - pkg/sentry/fsimpl/proc/task_files.go:384
- - pkg/sentry/fsimpl/proc/task_files.go:403
- - pkg/sentry/fsimpl/proc/task_files.go:428
- - pkg/sentry/fsimpl/proc/task_files.go:691
- - pkg/sentry/fsimpl/proc/task_files.go:770
- - pkg/sentry/fsimpl/proc/task_files.go:797
- - pkg/sentry/fsimpl/proc/task_files.go:828
- - pkg/sentry/fsimpl/proc/task_files.go:879
- - pkg/sentry/fsimpl/proc/task_files.go:910
- - pkg/sentry/fsimpl/proc/task_files.go:961
- - pkg/sentry/fsimpl/proc/task.go:127
- - pkg/sentry/fsimpl/proc/task.go:193
- - pkg/sentry/fsimpl/proc/task_net.go:134
- - pkg/sentry/fsimpl/proc/task_net.go:475
- - pkg/sentry/fsimpl/proc/task_net.go:491
- - pkg/sentry/fsimpl/proc/task_net.go:508
- - pkg/sentry/fsimpl/proc/task_net.go:665
- - pkg/sentry/fsimpl/proc/task_net.go:715
- - pkg/sentry/fsimpl/proc/task_net.go:779
- - pkg/sentry/fsimpl/proc/tasks_files.go:113
- - pkg/sentry/fsimpl/proc/tasks_files.go:388
- - pkg/sentry/fsimpl/proc/tasks.go:232
- - pkg/sentry/fsimpl/proc/tasks_sys.go:145
- - pkg/sentry/fsimpl/proc/tasks_sys.go:181
- - pkg/sentry/fsimpl/proc/tasks_sys.go:239
- - pkg/sentry/fsimpl/proc/tasks_sys.go:291
- - pkg/sentry/fsimpl/proc/tasks_sys.go:375
- - pkg/sentry/fsimpl/signalfd/signalfd.go:124
- pkg/sentry/fsimpl/signalfd/signalfd.go:15
- - pkg/sentry/fsimpl/signalfd/signalfd.go:126
- - pkg/sentry/fsimpl/sockfs/sockfs.go:36
- - pkg/sentry/fsimpl/sockfs/sockfs.go:79
- - pkg/sentry/fsimpl/sys/kcov.go:49
- - pkg/sentry/fsimpl/sys/kcov.go:99
- - pkg/sentry/fsimpl/sys/sys.go:118
- - pkg/sentry/fsimpl/sys/sys.go:56
- - pkg/sentry/fsimpl/testutil/testutil.go:257
- - pkg/sentry/fsimpl/testutil/testutil.go:260
- - pkg/sentry/fsimpl/timerfd/timerfd.go:87
- - pkg/sentry/fsimpl/tmpfs/directory.go:112
- - pkg/sentry/fsimpl/tmpfs/filesystem.go:195
- - pkg/sentry/fsimpl/tmpfs/regular_file.go:226
- - pkg/sentry/fsimpl/tmpfs/regular_file.go:346
- - pkg/sentry/fsimpl/tmpfs/tmpfs.go:103
- - pkg/sentry/fsimpl/tmpfs/tmpfs.go:733
- - pkg/sentry/fsimpl/verity/filesystem.go:490
- - pkg/sentry/fsimpl/verity/verity.go:156
- - pkg/sentry/fsimpl/verity/verity.go:629
- - pkg/sentry/fsimpl/verity/verity.go:672
- - pkg/sentry/fs/mount.go:162
- - pkg/sentry/fs/mount.go:256
- - pkg/sentry/fs/mount_overlay.go:144
- - pkg/sentry/fs/mounts.go:432
- - pkg/sentry/fs/proc/exec_args.go:104
- - pkg/sentry/fs/proc/exec_args.go:73
- - pkg/sentry/fs/proc/fds.go:269
- - pkg/sentry/fs/proc/loadavg.go:33
- - pkg/sentry/fs/proc/meminfo.go:39
- - pkg/sentry/fs/proc/mounts.go:193
- - pkg/sentry/fs/proc/mounts.go:84
- - pkg/sentry/fs/proc/net.go:125
- - pkg/sentry/fs/proc/proc.go:146
- - pkg/sentry/fs/proc/proc.go:204
- - pkg/sentry/fs/proc/seqfile/seqfile.go:210
- - pkg/sentry/fs/proc/sys.go:146
- - pkg/sentry/fs/proc/sys.go:43
- - pkg/sentry/fs/proc/sys_net.go:113
- - pkg/sentry/fs/proc/sys_net.go:205
- - pkg/sentry/fs/proc/sys_net.go:233
- - pkg/sentry/fs/proc/sys_net.go:307
- - pkg/sentry/fs/proc/sys_net.go:335
- - pkg/sentry/fs/proc/sys_net.go:446
- - pkg/sentry/fs/proc/sys_net.go:456
- - pkg/sentry/fs/proc/sys_net.go:89
- - pkg/sentry/fs/proc/task.go:170
- - pkg/sentry/fs/proc/task.go:322
- - pkg/sentry/fs/proc/task.go:427
- - pkg/sentry/fs/proc/task.go:467
- - pkg/sentry/fs/proc/task.go:500
- - pkg/sentry/fs/proc/task.go:784
- - pkg/sentry/fs/proc/task.go:839
- - pkg/sentry/fs/proc/task.go:920
- - pkg/sentry/fs/proc/uid_gid_map.go:108
- - pkg/sentry/fs/proc/uid_gid_map.go:79
- - pkg/sentry/fs/proc/uptime.go:75
- - pkg/sentry/fs/ramfs/dir.go:447
- - pkg/sentry/fs/tmpfs/inode_file.go:436
- - pkg/sentry/fs/tmpfs/inode_file.go:537
- - pkg/sentry/fs/tty/dir.go:313
- - pkg/sentry/fs/tty/master.go:131
- - pkg/sentry/fs/tty/master.go:91
- - pkg/sentry/fs/tty/replica.go:116
- - pkg/sentry/fs/tty/replica.go:88
- - pkg/sentry/kernel/auth/id_map.go:269
- - pkg/sentry/kernel/fasync/fasync.go:67
- - pkg/sentry/kernel/kcov.go:209
- - pkg/sentry/kernel/kcov.go:223
- - pkg/sentry/kernel/kernel.go:343
- - pkg/sentry/kernel/kernel.go:368
- - pkg/sentry/kernel/pipe/pipe_test.go:93
- - pkg/sentry/kernel/pipe/reader_writer.go:65
- - pkg/sentry/kernel/posixtimer.go:157
- - pkg/sentry/kernel/ptrace.go:218
- - pkg/sentry/kernel/semaphore/semaphore.go:323
- - pkg/sentry/kernel/sessions.go:123
- - pkg/sentry/kernel/sessions.go:508
- - pkg/sentry/kernel/signal_handlers.go:57
- - pkg/sentry/kernel/task_context.go:72
- - pkg/sentry/kernel/task_exit.go:67
- - pkg/sentry/kernel/task_sched.go:255
- - pkg/sentry/kernel/task_sched.go:280
- - pkg/sentry/kernel/task_sched.go:323
- - pkg/sentry/kernel/task_stop.go:192
- - pkg/sentry/kernel/thread_group.go:530
- - pkg/sentry/kernel/timekeeper.go:316
- - pkg/sentry/kernel/vdso.go:106
- - pkg/sentry/kernel/vdso.go:118
- pkg/sentry/memmap/memmap.go:103
- pkg/sentry/memmap/memmap.go:163
- - pkg/sentry/mm/address_space.go:42
- - pkg/sentry/mm/address_space.go:42
- pkg/sentry/mm/aio_context.go:208
- - pkg/sentry/mm/aio_context.go:288
- pkg/sentry/mm/pma.go:683
- - pkg/sentry/mm/special_mappable.go:80
- - pkg/sentry/syscalls/linux/sys_sem.go:62
- - pkg/sentry/syscalls/linux/sys_time.go:189
- pkg/sentry/usage/cpu.go:42
- - pkg/sentry/vfs/anonfs.go:302
- - pkg/sentry/vfs/anonfs.go:99
- - pkg/sentry/vfs/dentry.go:214
- - pkg/sentry/vfs/epoll.go:168
- - pkg/sentry/vfs/epoll.go:314
- - pkg/sentry/vfs/file_description.go:549
- - pkg/sentry/vfs/file_description_impl_util.go:304
- - pkg/sentry/vfs/file_description_impl_util.go:412
- - pkg/sentry/vfs/filesystem.go:76
- - pkg/sentry/vfs/lock.go:15
- - pkg/sentry/vfs/lock.go:47
- - pkg/sentry/vfs/memxattr/xattr.go:37
- - pkg/sentry/vfs/mount.go:510
- - pkg/sentry/vfs/mount.go:667
- - pkg/sentry/vfs/mount_test.go:106
- - pkg/sentry/vfs/mount_test.go:160
- - pkg/sentry/vfs/mount_test.go:215
- - pkg/sentry/vfs/mount_unsafe.go:153
- - pkg/sentry/vfs/resolving_path.go:228
- - pkg/sentry/vfs/vfs.go:897
- pkg/shim/runsc/runsc.go:16
- pkg/shim/runsc/utils.go:16
- pkg/shim/v1/proc/deleted_state.go:16
@@ -364,27 +155,10 @@ global:
- pkg/state/tests/integer_test.go:28
- pkg/sync/rwmutex_test.go:105
- pkg/syserr/host_linux.go:35
- - pkg/unet/unet_test.go:634
- - pkg/unet/unet_test.go:662
- - pkg/unet/unet_test.go:703
- - pkg/unet/unet_test.go:98
- pkg/usermem/addr.go:34
- pkg/usermem/usermem.go:171
- pkg/usermem/usermem.go:170
- - runsc/boot/compat.go:22
- runsc/boot/compat.go:56
- - runsc/boot/loader.go:1115
- - runsc/boot/loader.go:1120
- - runsc/cmd/checkpoint.go:151
- - runsc/config/flags.go:32
- - runsc/container/container.go:641
- - runsc/container/container.go:988
- - runsc/specutils/specutils.go:172
- - runsc/specutils/specutils.go:428
- - runsc/specutils/specutils.go:436
- - runsc/specutils/specutils.go:442
- - runsc/specutils/specutils.go:447
- - runsc/specutils/specutils.go:454
- test/cmd/test_app/fds.go:171
- test/iptables/filter_output.go:251
- test/packetimpact/testbench/connections.go:77
@@ -400,13 +174,6 @@ global:
- tools/checkescape/test1/test1.go:64
- tools/checkescape/test1/test1.go:80
- tools/checkescape/test1/test1.go:94
- - tools/go_generics/imports.go:51
- - tools/go_generics/imports.go:75
- - tools/go_marshal/gomarshal/generator.go:177
- - tools/go_marshal/gomarshal/generator.go:81
- - tools/go_marshal/gomarshal/generator.go:85
- - tools/go_marshal/test/escape/escape.go:15
- - tools/go_marshal/test/test.go:164
analyzers:
asmdecl:
external: # Enabled.
diff --git a/pkg/bpf/decoder.go b/pkg/bpf/decoder.go
index 069d0395d..6d1e65cb1 100644
--- a/pkg/bpf/decoder.go
+++ b/pkg/bpf/decoder.go
@@ -109,7 +109,7 @@ func decodeLdSize(inst linux.BPFInstruction, w *bytes.Buffer) error {
case B:
w.WriteString("1")
default:
- return fmt.Errorf("Invalid BPF LD size: %v", inst)
+ return fmt.Errorf("invalid BPF LD size: %v", inst)
}
return nil
}
diff --git a/pkg/sentry/fs/proc/sys_net.go b/pkg/sentry/fs/proc/sys_net.go
index e555672ad..52061175f 100644
--- a/pkg/sentry/fs/proc/sys_net.go
+++ b/pkg/sentry/fs/proc/sys_net.go
@@ -86,9 +86,9 @@ func (*tcpMemInode) Truncate(context.Context, *fs.Inode, int64) error {
}
// GetFile implements fs.InodeOperations.GetFile.
-func (m *tcpMemInode) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error) {
+func (t *tcpMemInode) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error) {
flags.Pread = true
- return fs.NewFile(ctx, dirent, flags, &tcpMemFile{tcpMemInode: m}), nil
+ return fs.NewFile(ctx, dirent, flags, &tcpMemFile{tcpMemInode: t}), nil
}
// +stateify savable
diff --git a/pkg/sentry/fs/tmpfs/inode_file.go b/pkg/sentry/fs/tmpfs/inode_file.go
index fc0498f17..d6c65301c 100644
--- a/pkg/sentry/fs/tmpfs/inode_file.go
+++ b/pkg/sentry/fs/tmpfs/inode_file.go
@@ -431,9 +431,6 @@ func (rw *fileReadWriter) ReadToBlocks(dsts safemem.BlockSeq) (uint64, error) {
// Continue.
seg, gap = gap.NextSegment(), fsutil.FileRangeGapIterator{}
-
- default:
- break
}
}
return done, nil
@@ -532,9 +529,6 @@ func (rw *fileReadWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error)
// Write to that memory as usual.
seg, gap = rw.f.data.Insert(gap, gapMR, fr.Start), fsutil.FileRangeGapIterator{}
-
- default:
- break
}
}
return done, nil
diff --git a/pkg/sentry/fsimpl/fuse/dev_test.go b/pkg/sentry/fsimpl/fuse/dev_test.go
index 5986133e9..95c475a65 100644
--- a/pkg/sentry/fsimpl/fuse/dev_test.go
+++ b/pkg/sentry/fsimpl/fuse/dev_test.go
@@ -315,7 +315,7 @@ func fuseServerRun(t *testing.T, s *testutil.System, k *kernel.Kernel, fd *vfs.F
readPayload.MarshalUnsafe(outBuf[outHdrLen:])
outIOseq := usermem.BytesIOSequence(outBuf)
- n, err = fd.Write(s.Ctx, outIOseq, vfs.WriteOptions{})
+ _, err = fd.Write(s.Ctx, outIOseq, vfs.WriteOptions{})
if err != nil {
t.Fatalf("Write failed :%v", err)
}
diff --git a/pkg/sentry/kernel/pipe/pipe_test.go b/pkg/sentry/kernel/pipe/pipe_test.go
index 9cded388d..3dd739080 100644
--- a/pkg/sentry/kernel/pipe/pipe_test.go
+++ b/pkg/sentry/kernel/pipe/pipe_test.go
@@ -116,7 +116,8 @@ func TestPipeWriteUntilEnd(t *testing.T) {
}
}
if err != nil {
- t.Fatalf("Readv: got unexpected error %v", err)
+ t.Errorf("Readv: got unexpected error %v", err)
+ return
}
}
}()
diff --git a/pkg/sentry/kernel/sessions.go b/pkg/sentry/kernel/sessions.go
index df5c8421b..5bddb0a36 100644
--- a/pkg/sentry/kernel/sessions.go
+++ b/pkg/sentry/kernel/sessions.go
@@ -477,20 +477,20 @@ func (tg *ThreadGroup) Session() *Session {
//
// If this group isn't visible in this namespace, zero will be returned. It is
// the callers responsibility to check that before using this function.
-func (pidns *PIDNamespace) IDOfSession(s *Session) SessionID {
- pidns.owner.mu.RLock()
- defer pidns.owner.mu.RUnlock()
- return pidns.sids[s]
+func (ns *PIDNamespace) IDOfSession(s *Session) SessionID {
+ ns.owner.mu.RLock()
+ defer ns.owner.mu.RUnlock()
+ return ns.sids[s]
}
// SessionWithID returns the Session with the given ID in the PID namespace ns,
// or nil if that given ID is not defined in this namespace.
//
// A reference is not taken on the session.
-func (pidns *PIDNamespace) SessionWithID(id SessionID) *Session {
- pidns.owner.mu.RLock()
- defer pidns.owner.mu.RUnlock()
- return pidns.sessions[id]
+func (ns *PIDNamespace) SessionWithID(id SessionID) *Session {
+ ns.owner.mu.RLock()
+ defer ns.owner.mu.RUnlock()
+ return ns.sessions[id]
}
// ProcessGroup returns the ThreadGroup's ProcessGroup.
@@ -505,18 +505,18 @@ func (tg *ThreadGroup) ProcessGroup() *ProcessGroup {
// IDOfProcessGroup returns the process group assigned to pg in PID namespace ns.
//
// The same constraints apply as IDOfSession.
-func (pidns *PIDNamespace) IDOfProcessGroup(pg *ProcessGroup) ProcessGroupID {
- pidns.owner.mu.RLock()
- defer pidns.owner.mu.RUnlock()
- return pidns.pgids[pg]
+func (ns *PIDNamespace) IDOfProcessGroup(pg *ProcessGroup) ProcessGroupID {
+ ns.owner.mu.RLock()
+ defer ns.owner.mu.RUnlock()
+ return ns.pgids[pg]
}
// ProcessGroupWithID returns the ProcessGroup with the given ID in the PID
// namespace ns, or nil if that given ID is not defined in this namespace.
//
// A reference is not taken on the process group.
-func (pidns *PIDNamespace) ProcessGroupWithID(id ProcessGroupID) *ProcessGroup {
- pidns.owner.mu.RLock()
- defer pidns.owner.mu.RUnlock()
- return pidns.processGroups[id]
+func (ns *PIDNamespace) ProcessGroupWithID(id ProcessGroupID) *ProcessGroup {
+ ns.owner.mu.RLock()
+ defer ns.owner.mu.RUnlock()
+ return ns.processGroups[id]
}
diff --git a/pkg/sentry/kernel/vdso.go b/pkg/sentry/kernel/vdso.go
index 9bc452e67..9e5c2d26f 100644
--- a/pkg/sentry/kernel/vdso.go
+++ b/pkg/sentry/kernel/vdso.go
@@ -115,7 +115,7 @@ func (v *VDSOParamPage) incrementSeq(paramPage safemem.Block) error {
}
if old != v.seq {
- return fmt.Errorf("unexpected VDSOParamPage seq value: got %d expected %d. Application may hang or get incorrect time from the VDSO.", old, v.seq)
+ return fmt.Errorf("unexpected VDSOParamPage seq value: got %d expected %d; application may hang or get incorrect time from the VDSO", old, v.seq)
}
v.seq = next
diff --git a/pkg/sentry/vfs/mount_test.go b/pkg/sentry/vfs/mount_test.go
index cb8c56bd3..cb882a983 100644
--- a/pkg/sentry/vfs/mount_test.go
+++ b/pkg/sentry/vfs/mount_test.go
@@ -29,7 +29,7 @@ func TestMountTableLookupEmpty(t *testing.T) {
parent := &Mount{}
point := &Dentry{}
if m := mt.Lookup(parent, point); m != nil {
- t.Errorf("empty mountTable lookup: got %p, wanted nil", m)
+ t.Errorf("Empty mountTable lookup: got %p, wanted nil", m)
}
}
@@ -111,13 +111,16 @@ func BenchmarkMountTableParallelLookup(b *testing.B) {
k := keys[i&(numMounts-1)]
m := mt.Lookup(k.mount, k.dentry)
if m == nil {
- b.Fatalf("lookup failed")
+ b.Errorf("Lookup failed")
+ return
}
if parent := m.parent(); parent != k.mount {
- b.Fatalf("lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ b.Errorf("Lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ return
}
if point := m.point(); point != k.dentry {
- b.Fatalf("lookup returned mount with point %p, wanted %p", point, k.dentry)
+ b.Errorf("Lookup returned mount with point %p, wanted %p", point, k.dentry)
+ return
}
}
}()
@@ -167,13 +170,16 @@ func BenchmarkMountMapParallelLookup(b *testing.B) {
m := ms[k]
mu.RUnlock()
if m == nil {
- b.Fatalf("lookup failed")
+ b.Errorf("Lookup failed")
+ return
}
if parent := m.parent(); parent != k.mount {
- b.Fatalf("lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ b.Errorf("Lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ return
}
if point := m.point(); point != k.dentry {
- b.Fatalf("lookup returned mount with point %p, wanted %p", point, k.dentry)
+ b.Errorf("Lookup returned mount with point %p, wanted %p", point, k.dentry)
+ return
}
}
}()
@@ -220,14 +226,17 @@ func BenchmarkMountSyncMapParallelLookup(b *testing.B) {
k := keys[i&(numMounts-1)]
mi, ok := ms.Load(k)
if !ok {
- b.Fatalf("lookup failed")
+ b.Errorf("Lookup failed")
+ return
}
m := mi.(*Mount)
if parent := m.parent(); parent != k.mount {
- b.Fatalf("lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ b.Errorf("Lookup returned mount with parent %p, wanted %p", parent, k.mount)
+ return
}
if point := m.point(); point != k.dentry {
- b.Fatalf("lookup returned mount with point %p, wanted %p", point, k.dentry)
+ b.Errorf("Lookup returned mount with point %p, wanted %p", point, k.dentry)
+ return
}
}
}()
@@ -264,7 +273,7 @@ func BenchmarkMountTableNegativeLookup(b *testing.B) {
k := negkeys[i&(numMounts-1)]
m := mt.Lookup(k.mount, k.dentry)
if m != nil {
- b.Fatalf("lookup got %p, wanted nil", m)
+ b.Fatalf("Lookup got %p, wanted nil", m)
}
}
})
@@ -300,7 +309,7 @@ func BenchmarkMountMapNegativeLookup(b *testing.B) {
m := ms[k]
mu.RUnlock()
if m != nil {
- b.Fatalf("lookup got %p, wanted nil", m)
+ b.Fatalf("Lookup got %p, wanted nil", m)
}
}
})
@@ -333,7 +342,7 @@ func BenchmarkMountSyncMapNegativeLookup(b *testing.B) {
k := negkeys[i&(numMounts-1)]
m, _ := ms.Load(k)
if m != nil {
- b.Fatalf("lookup got %p, wanted nil", m)
+ b.Fatalf("Lookup got %p, wanted nil", m)
}
}
})
diff --git a/pkg/unet/unet_test.go b/pkg/unet/unet_test.go
index 5c4b9e8e9..a38ffc19d 100644
--- a/pkg/unet/unet_test.go
+++ b/pkg/unet/unet_test.go
@@ -53,40 +53,40 @@ func randomFilename() (string, error) {
func TestConnectFailure(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
if _, err := Connect(name, false); err == nil {
- t.Fatalf("connect was successful, expected err")
+ t.Fatalf("Connect was successful, expected err")
}
}
func TestBindFailure(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("first bind failed, got err %v expected nil", err)
+ t.Fatalf("First bind failed, got err %v expected nil", err)
}
defer ss.Close()
if _, err = BindAndListen(name, false); err == nil {
- t.Fatalf("second bind succeeded, expected non-nil err")
+ t.Fatalf("Second bind succeeded, expected non-nil err")
}
}
func TestMultipleAccept(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("first bind failed, got err %v expected nil", err)
+ t.Fatalf("First bind failed, got err %v expected nil", err)
}
defer ss.Close()
@@ -99,7 +99,8 @@ func TestMultipleAccept(t *testing.T) {
defer wg.Done()
s, err := Connect(name, false)
if err != nil {
- t.Fatalf("connect failed, got err %v expected nil", err)
+ t.Errorf("Connect failed, got err %v expected nil", err)
+ return
}
s.Close()
}()
@@ -109,7 +110,7 @@ func TestMultipleAccept(t *testing.T) {
for i := 0; i < backlog; i++ {
s, err := ss.Accept()
if err != nil {
- t.Errorf("accept failed, got err %v expected nil", err)
+ t.Errorf("Accept failed, got err %v expected nil", err)
continue
}
s.Close()
@@ -119,35 +120,35 @@ func TestMultipleAccept(t *testing.T) {
func TestServerClose(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("first bind failed, got err %v expected nil", err)
+ t.Fatalf("First bind failed, got err %v expected nil", err)
}
// Make sure the first close succeeds.
if err := ss.Close(); err != nil {
- t.Fatalf("first close failed, got err %v expected nil", err)
+ t.Fatalf("First close failed, got err %v expected nil", err)
}
// The second one should fail.
if err := ss.Close(); err == nil {
- t.Fatalf("second close succeeded, expected non-nil err")
+ t.Fatalf("Second close succeeded, expected non-nil err")
}
}
func socketPair(t *testing.T, packet bool) (*Socket, *Socket) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
// Bind a server.
ss, err := BindAndListen(name, packet)
if err != nil {
- t.Fatalf("error binding, got %v expected nil", err)
+ t.Fatalf("Error binding, got %v expected nil", err)
}
defer ss.Close()
@@ -165,7 +166,7 @@ func socketPair(t *testing.T, packet bool) (*Socket, *Socket) {
// Connect the client.
client, err := Connect(name, packet)
if err != nil {
- t.Fatalf("error connecting, got %v expected nil", err)
+ t.Fatalf("Error connecting, got %v expected nil", err)
}
// Grab the server handle.
@@ -173,7 +174,7 @@ func socketPair(t *testing.T, packet bool) (*Socket, *Socket) {
case server := <-acceptSocket:
return server, client
case err := <-acceptErr:
- t.Fatalf("accept error: %v", err)
+ t.Fatalf("Accept error: %v", err)
}
panic("unreachable")
}
@@ -186,17 +187,17 @@ func TestSendRecv(t *testing.T) {
// Write on the client.
w := client.Writer(true)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for client write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
// Read on the server.
b := [][]byte{{'b'}}
r := server.Reader(true)
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for server read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For server read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
}
@@ -211,17 +212,17 @@ func TestSymmetric(t *testing.T) {
// Write on the server.
w := server.Writer(true)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for server write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For server write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
// Read on the client.
b := [][]byte{{'b'}}
r := client.Reader(true)
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for client read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
}
@@ -233,13 +234,13 @@ func TestPacket(t *testing.T) {
// Write on the client.
w := client.Writer(true)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for client write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
// Write on the client again.
w = client.Writer(true)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for client write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
// Read on the server.
@@ -249,19 +250,19 @@ func TestPacket(t *testing.T) {
b := [][]byte{{'b', 'b'}}
r := server.Reader(true)
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for server read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For server read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
// Do it again.
r = server.Reader(true)
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for server read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For server read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
}
@@ -271,12 +272,12 @@ func TestClose(t *testing.T) {
// Make sure the first close succeeds.
if err := client.Close(); err != nil {
- t.Fatalf("first close failed, got err %v expected nil", err)
+ t.Fatalf("First close failed, got err %v expected nil", err)
}
// The second one should fail.
if err := client.Close(); err == nil {
- t.Fatalf("second close succeeded, expected non-nil err")
+ t.Fatalf("Second close succeeded, expected non-nil err")
}
}
@@ -294,17 +295,17 @@ func TestNonBlockingSend(t *testing.T) {
// We're good. That's what we wanted.
blockCount++
} else {
- t.Fatalf("for client write, got n=%d err=%v, expected n=1000 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=1000 err=nil", n, err)
}
}
}
if blockCount == 1000 {
// Shouldn't have _always_ blocked.
- t.Fatalf("socket always blocked!")
+ t.Fatalf("Socket always blocked!")
} else if blockCount == 0 {
// Should have started blocking eventually.
- t.Fatalf("socket never blocked!")
+ t.Fatalf("Socket never blocked!")
}
}
@@ -319,25 +320,25 @@ func TestNonBlockingRecv(t *testing.T) {
// Expected to block immediately.
_, err := r.ReadVec(b)
if err != syscall.EWOULDBLOCK && err != syscall.EAGAIN {
- t.Fatalf("read didn't block, got err %v expected blocking err", err)
+ t.Fatalf("Read didn't block, got err %v expected blocking err", err)
}
// Put some data in the pipe.
w := server.Writer(false)
if n, err := w.WriteVec(b); n != 1 || err != nil {
- t.Fatalf("write failed with n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("Write failed with n=%d err=%v, expected n=1 err=nil", n, err)
}
// Expect it not to block.
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("read failed with n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("Read failed with n=%d err=%v, expected n=1 err=nil", n, err)
}
// Expect it to return a block error again.
r = client.Reader(false)
_, err = r.ReadVec(b)
if err != syscall.EWOULDBLOCK && err != syscall.EAGAIN {
- t.Fatalf("read didn't block, got err %v expected blocking err", err)
+ t.Fatalf("Read didn't block, got err %v expected blocking err", err)
}
}
@@ -349,17 +350,17 @@ func TestRecvVectors(t *testing.T) {
// Write on the client.
w := client.Writer(true)
if n, err := w.WriteVec([][]byte{{'a', 'b'}}); n != 2 || err != nil {
- t.Fatalf("for client write, got n=%d err=%v, expected n=2 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=2 err=nil", n, err)
}
// Read on the server.
b := [][]byte{{'c'}, {'c'}}
r := server.Reader(true)
if n, err := r.ReadVec(b); n != 2 || err != nil {
- t.Fatalf("for server read, got n=%d err=%v, expected n=2 err=nil", n, err)
+ t.Fatalf("For server read, got n=%d err=%v, expected n=2 err=nil", n, err)
}
if b[0][0] != 'a' || b[1][0] != 'b' {
- t.Fatalf("got bad read data, got %c,%c, expected a,b", b[0][0], b[1][0])
+ t.Fatalf("Got bad read data, got %c,%c, expected a,b", b[0][0], b[1][0])
}
}
@@ -371,17 +372,17 @@ func TestSendVectors(t *testing.T) {
// Write on the client.
w := client.Writer(true)
if n, err := w.WriteVec([][]byte{{'a'}, {'b'}}); n != 2 || err != nil {
- t.Fatalf("for client write, got n=%d err=%v, expected n=2 err=nil", n, err)
+ t.Fatalf("For client write, got n=%d err=%v, expected n=2 err=nil", n, err)
}
// Read on the server.
b := [][]byte{{'c', 'c'}}
r := server.Reader(true)
if n, err := r.ReadVec(b); n != 2 || err != nil {
- t.Fatalf("for server read, got n=%d err=%v, expected n=2 err=nil", n, err)
+ t.Fatalf("For server read, got n=%d err=%v, expected n=2 err=nil", n, err)
}
if b[0][0] != 'a' || b[0][1] != 'b' {
- t.Fatalf("got bad read data, got %c,%c, expected a,b", b[0][0], b[0][1])
+ t.Fatalf("Got bad read data, got %c,%c, expected a,b", b[0][0], b[0][1])
}
}
@@ -394,23 +395,23 @@ func TestSendFDsNotEnabled(t *testing.T) {
w := server.Writer(true)
w.PackFDs(0, 1, 2)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for server write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For server write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
// Read on the client, without enabling FDs.
b := [][]byte{{'b'}}
r := client.Reader(true)
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for client read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
// Make sure the FDs are not received.
fds, err := r.ExtractFDs()
if len(fds) != 0 || err != nil {
- t.Fatalf("got fds=%v err=%v, expected len(fds)=0 err=nil", fds, err)
+ t.Fatalf("Got fds=%v err=%v, expected len(fds)=0 err=nil", fds, err)
}
}
@@ -418,7 +419,7 @@ func sendFDs(t *testing.T, s *Socket, fds []int) {
w := s.Writer(true)
w.PackFDs(fds...)
if n, err := w.WriteVec([][]byte{{'a'}}); n != 1 || err != nil {
- t.Fatalf("for write, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For write, got n=%d err=%v, expected n=1 err=nil", n, err)
}
}
@@ -428,7 +429,7 @@ func recvFDs(t *testing.T, s *Socket, enableSize int, origFDs []int) {
// Count the number of FDs.
preEntries, err := ioutil.ReadDir("/proc/self/fd")
if err != nil {
- t.Fatalf("can't readdir, got err %v expected nil", err)
+ t.Fatalf("Can't readdir, got err %v expected nil", err)
}
// Read on the client.
@@ -438,31 +439,31 @@ func recvFDs(t *testing.T, s *Socket, enableSize int, origFDs []int) {
r.EnableFDs(enableSize)
}
if n, err := r.ReadVec(b); n != 1 || err != nil {
- t.Fatalf("for client read, got n=%d err=%v, expected n=1 err=nil", n, err)
+ t.Fatalf("For client read, got n=%d err=%v, expected n=1 err=nil", n, err)
}
if b[0][0] != 'a' {
- t.Fatalf("got bad read data, got %c, expected a", b[0][0])
+ t.Fatalf("Got bad read data, got %c, expected a", b[0][0])
}
// Count the new number of FDs.
postEntries, err := ioutil.ReadDir("/proc/self/fd")
if err != nil {
- t.Fatalf("can't readdir, got err %v expected nil", err)
+ t.Fatalf("Can't readdir, got err %v expected nil", err)
}
if len(preEntries)+expected != len(postEntries) {
- t.Errorf("process fd count isn't right, expected %d got %d", len(preEntries)+expected, len(postEntries))
+ t.Errorf("Process fd count isn't right, expected %d got %d", len(preEntries)+expected, len(postEntries))
}
// Make sure the FDs are there.
fds, err := r.ExtractFDs()
if len(fds) != expected || err != nil {
- t.Fatalf("got fds=%v err=%v, expected len(fds)=%d err=nil", fds, err, expected)
+ t.Fatalf("Got fds=%v err=%v, expected len(fds)=%d err=nil", fds, err, expected)
}
// Make sure they are different from the originals.
for i := 0; i < len(fds); i++ {
if fds[i] == origFDs[i] {
- t.Errorf("got original fd for index %d, expected different", i)
+ t.Errorf("Got original fd for index %d, expected different", i)
}
}
@@ -480,10 +481,10 @@ func recvFDs(t *testing.T, s *Socket, enableSize int, origFDs []int) {
// Make sure the count is back to normal.
finalEntries, err := ioutil.ReadDir("/proc/self/fd")
if err != nil {
- t.Fatalf("can't readdir, got err %v expected nil", err)
+ t.Fatalf("Can't readdir, got err %v expected nil", err)
}
if len(finalEntries) != len(preEntries) {
- t.Errorf("process fd count isn't right, expected %d got %d", len(preEntries), len(finalEntries))
+ t.Errorf("Process fd count isn't right, expected %d got %d", len(preEntries), len(finalEntries))
}
}
@@ -567,7 +568,7 @@ func TestGetPeerCred(t *testing.T) {
}
if got, err := client.GetPeerCred(); err != nil || !reflect.DeepEqual(got, want) {
- t.Errorf("got GetPeerCred() = %v, %v, want = %+v, %+v", got, err, want, nil)
+ t.Errorf("GetPeerCred() = %v, %v, want = %+v, %+v", got, err, want, nil)
}
}
@@ -594,53 +595,53 @@ func TestGetPeerCredFailure(t *testing.T) {
want := "bad file descriptor"
if _, err := s.GetPeerCred(); err == nil || err.Error() != want {
- t.Errorf("got s.GetPeerCred() = %v, want = %s", err, want)
+ t.Errorf("s.GetPeerCred() = %v, want = %s", err, want)
}
}
func TestAcceptClosed(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("bind failed, got err %v expected nil", err)
+ t.Fatalf("Bind failed, got err %v expected nil", err)
}
if err := ss.Close(); err != nil {
- t.Fatalf("close failed, got err %v expected nil", err)
+ t.Fatalf("Close failed, got err %v expected nil", err)
}
if _, err := ss.Accept(); err == nil {
- t.Errorf("accept on closed SocketServer, got err %v, want != nil", err)
+ t.Errorf("Accept on closed SocketServer, got err %v, want != nil", err)
}
}
func TestCloseAfterAcceptStart(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("bind failed, got err %v expected nil", err)
+ t.Fatalf("Bind failed, got err %v expected nil", err)
}
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
+ defer wg.Done()
time.Sleep(50 * time.Millisecond)
if err := ss.Close(); err != nil {
- t.Fatalf("close failed, got err %v expected nil", err)
+ t.Errorf("Close failed, got err %v expected nil", err)
}
- wg.Done()
}()
if _, err := ss.Accept(); err == nil {
- t.Errorf("accept on closed SocketServer, got err %v, want != nil", err)
+ t.Errorf("Accept on closed SocketServer, got err %v, want != nil", err)
}
wg.Wait()
@@ -649,28 +650,28 @@ func TestCloseAfterAcceptStart(t *testing.T) {
func TestReleaseAfterAcceptStart(t *testing.T) {
name, err := randomFilename()
if err != nil {
- t.Fatalf("unable to generate file, got err %v expected nil", err)
+ t.Fatalf("Unable to generate file, got err %v expected nil", err)
}
ss, err := BindAndListen(name, false)
if err != nil {
- t.Fatalf("bind failed, got err %v expected nil", err)
+ t.Fatalf("Bind failed, got err %v expected nil", err)
}
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
+ defer wg.Done()
time.Sleep(50 * time.Millisecond)
fd, err := ss.Release()
if err != nil {
- t.Fatalf("Release failed, got err %v expected nil", err)
+ t.Errorf("Release failed, got err %v expected nil", err)
}
syscall.Close(fd)
- wg.Done()
}()
if _, err := ss.Accept(); err == nil {
- t.Errorf("accept on closed SocketServer, got err %v, want != nil", err)
+ t.Errorf("Accept on closed SocketServer, got err %v, want != nil", err)
}
wg.Wait()
@@ -688,7 +689,7 @@ func TestControlMessage(t *testing.T) {
cm.PackFDs(want...)
got, err := cm.ExtractFDs()
if err != nil || !reflect.DeepEqual(got, want) {
- t.Errorf("got cm.ExtractFDs() = %v, %v, want = %v, %v", got, err, want, nil)
+ t.Errorf("cm.ExtractFDs() = %v, %v, want = %v, %v", got, err, want, nil)
}
}
}
@@ -705,11 +706,13 @@ func benchmarkSendRecv(b *testing.B, packet bool) {
for i := 0; i < b.N; i++ {
n, err := server.Read(buf)
if n != 1 || err != nil {
- b.Fatalf("server.Read: got (%d, %v), wanted (1, nil)", n, err)
+ b.Errorf("server.Read: got (%d, %v), wanted (1, nil)", n, err)
+ return
}
n, err = server.Write(buf)
if n != 1 || err != nil {
- b.Fatalf("server.Write: got (%d, %v), wanted (1, nil)", n, err)
+ b.Errorf("server.Write: got (%d, %v), wanted (1, nil)", n, err)
+ return
}
}
}()
diff --git a/runsc/cmd/checkpoint.go b/runsc/cmd/checkpoint.go
index 8fe0c427a..d4e0da2ab 100644
--- a/runsc/cmd/checkpoint.go
+++ b/runsc/cmd/checkpoint.go
@@ -149,6 +149,9 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa
}
ws, err := cont.Wait()
+ if err != nil {
+ Fatalf("Error waiting for container: %v", err)
+ }
*waitStatus = ws
return subcommands.ExitSuccess
diff --git a/runsc/config/flags.go b/runsc/config/flags.go
index d3203b565..13d8f1b25 100644
--- a/runsc/config/flags.go
+++ b/runsc/config/flags.go
@@ -29,7 +29,7 @@ import (
var registration sync.Once
-// This is the set of flags used to populate Config.
+// RegisterFlags registers flags used to populate Config.
func RegisterFlags() {
registration.Do(func() {
// Although these flags are not part of the OCI spec, they are used by
diff --git a/runsc/specutils/specutils.go b/runsc/specutils/specutils.go
index 45abc1425..7b923ddf4 100644
--- a/runsc/specutils/specutils.go
+++ b/runsc/specutils/specutils.go
@@ -19,6 +19,7 @@ package specutils
import (
"encoding/json"
"fmt"
+ "io"
"io/ioutil"
"os"
"path"
@@ -169,7 +170,7 @@ func ReadSpec(bundleDir string, conf *config.Config) (*specs.Spec, error) {
// ReadSpecFromFile reads an OCI runtime spec from the given File, and
// normalizes all relative paths into absolute by prepending the bundle dir.
func ReadSpecFromFile(bundleDir string, specFile *os.File, conf *config.Config) (*specs.Spec, error) {
- if _, err := specFile.Seek(0, os.SEEK_SET); err != nil {
+ if _, err := specFile.Seek(0, io.SeekStart); err != nil {
return nil, fmt.Errorf("error seeking to beginning of file %q: %v", specFile.Name(), err)
}
specBytes, err := ioutil.ReadAll(specFile)
diff --git a/tools/go_generics/imports.go b/tools/go_generics/imports.go
index 90d3aa1e0..370650e46 100644
--- a/tools/go_generics/imports.go
+++ b/tools/go_generics/imports.go
@@ -48,7 +48,7 @@ func updateImportIdent(orig string, imports mapValue, id *ast.Ident, used map[st
// Create a new entry in the used map.
path := imports[importName]
if path == "" {
- return fmt.Errorf("Unknown path to package '%s', used in '%s'", importName, orig)
+ return fmt.Errorf("unknown path to package '%s', used in '%s'", importName, orig)
}
m = &importedPackage{
@@ -72,7 +72,7 @@ func convertExpression(s string, imports mapValue, used map[string]*importedPack
// Parse the expression in the input string.
expr, err := parser.ParseExpr(s)
if err != nil {
- return "", fmt.Errorf("Unable to parse \"%s\": %v", s, err)
+ return "", fmt.Errorf("unable to parse \"%s\": %v", s, err)
}
// Go through the AST and update references.
diff --git a/tools/go_marshal/test/escape/escape.go b/tools/go_marshal/test/escape/escape.go
index 7f62b0a2b..df14ae98e 100644
--- a/tools/go_marshal/test/escape/escape.go
+++ b/tools/go_marshal/test/escape/escape.go
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// Package escape contains test cases for escape analysis.
package escape
import (
diff --git a/tools/go_marshal/test/test.go b/tools/go_marshal/test/test.go
index d9e9f341b..e7e3ed74a 100644
--- a/tools/go_marshal/test/test.go
+++ b/tools/go_marshal/test/test.go
@@ -161,7 +161,7 @@ type TestArray [sizeA]int32
// +marshal
type TestArray2 [sizeA * sizeB]int32
-// TestArray2 is a newtype on an array with a simple arithmetic expression of
+// TestArray3 is a newtype on an array with a simple arithmetic expression of
// mixed constants and literals for the array length.
//
// +marshal