Skip to content

Commit

Permalink
fix: 修复sys_exec_test.go函数中TestReadv测试函数使用错误
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryOracle committed Dec 7, 2023
1 parent 6a53bae commit 9562ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions sys_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func readv(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
}
// syscall
r, _, e := syscall.RawSyscall(syscall.SYS_READV, uintptr(fd), uintptr(unsafe.Pointer(&ivs[0])), uintptr(iovLen))
resetIovecs(bs, ivs[:iovLen])
if e != 0 {
return int(r), syscall.Errno(e)
}
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 9562ad1

Please sign in to comment.