Skip to content

Commit

Permalink
fix: 修复sys_exec_test.go函数中TestReadv测试函数使用错误 (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryOracle authored Jan 23, 2024
1 parent 654cef1 commit a6a5330
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions sys_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ func readv(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
}

// TODO: read from sysconf(_SC_IOV_MAX)? The Linux default is
// 1024 and this seems conservative enough for now. Darwin's
// UIO_MAXIOV also seems to be 1024.
//
// 1024 and this seems conservative enough for now. Darwin's
// UIO_MAXIOV also seems to be 1024.
//
// iovecs limit length to 2GB(2^31)
func iovecs(bs [][]byte, ivs []syscall.Iovec) (iovLen int) {
totalLen := 0
Expand Down
11 changes: 8 additions & 3 deletions sys_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,23 @@ func TestReadv(t *testing.T) {
w3, _ := syscall.Write(w, vs[2])
Equal(t, w1+w2+w3, 31)

var barrier = barrier{}
barrier.bs = [][]byte{
var barrier = barrier{
bs: make([][]byte, 4),
}
res := [][]byte{
make([]byte, 0),
make([]byte, 10),
make([]byte, 11),
make([]byte, 10),
}
for i := range res {
barrier.bs[i] = res[i]
}
barrier.ivs = make([]syscall.Iovec, len(barrier.bs))
rn, err := readv(r, barrier.bs, barrier.ivs)
MustNil(t, err)
Equal(t, rn, 31)
for i, v := range barrier.bs {
for i, v := range res {
t.Logf("READ [%d] %s", i, v)
}
}
Expand Down

0 comments on commit a6a5330

Please sign in to comment.