Skip to content

Commit a6a5330

Browse files
authored
fix: 修复sys_exec_test.go函数中TestReadv测试函数使用错误 (#297)
1 parent 654cef1 commit a6a5330

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

sys_exec.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ func readv(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
9494
}
9595

9696
// TODO: read from sysconf(_SC_IOV_MAX)? The Linux default is
97-
// 1024 and this seems conservative enough for now. Darwin's
98-
// UIO_MAXIOV also seems to be 1024.
97+
//
98+
// 1024 and this seems conservative enough for now. Darwin's
99+
// UIO_MAXIOV also seems to be 1024.
100+
//
99101
// iovecs limit length to 2GB(2^31)
100102
func iovecs(bs [][]byte, ivs []syscall.Iovec) (iovLen int) {
101103
totalLen := 0

sys_exec_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,23 @@ func TestReadv(t *testing.T) {
105105
w3, _ := syscall.Write(w, vs[2])
106106
Equal(t, w1+w2+w3, 31)
107107

108-
var barrier = barrier{}
109-
barrier.bs = [][]byte{
108+
var barrier = barrier{
109+
bs: make([][]byte, 4),
110+
}
111+
res := [][]byte{
110112
make([]byte, 0),
111113
make([]byte, 10),
112114
make([]byte, 11),
113115
make([]byte, 10),
114116
}
117+
for i := range res {
118+
barrier.bs[i] = res[i]
119+
}
115120
barrier.ivs = make([]syscall.Iovec, len(barrier.bs))
116121
rn, err := readv(r, barrier.bs, barrier.ivs)
117122
MustNil(t, err)
118123
Equal(t, rn, 31)
119-
for i, v := range barrier.bs {
124+
for i, v := range res {
120125
t.Logf("READ [%d] %s", i, v)
121126
}
122127
}

0 commit comments

Comments
 (0)