-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 修复sys_exec_test.go函数中TestReadv测试函数使用错误 #297
Conversation
@BinaryOracle 这个其实是这段测试有点问题。原本的代码没问题。之所以要reset,是因为 barrier 不能持有原始 []byte 的引用,否则这段 []byte 永远不能被 GC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以修改 TestReadv ,独立创建每一个 []byte 的变量,然后直接读取变量中的内容。而不是读取 [][]byte 里的内容
我改了一下pr,把TestReadv测试函数修正了一下: func TestReadv(t *testing.T) {
r, w := GetSysFdPairs()
vs := [][]byte{
[]byte("first line"), // len=10
[]byte("second line"), // len=11
[]byte("third line"), // len=10
}
w1, _ := syscall.Write(w, vs[0])
w2, _ := syscall.Write(w, vs[1])
w3, _ := syscall.Write(w, vs[2])
Equal(t, w1+w2+w3, 31)
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 res {
t.Logf("READ [%d] %s", i, v)
}
} |
@BinaryOracle Hi,能再辛苦你能签署下这个吗? |
好 |
我看签署了CLA之后,但是显示处于pending状态: 然后我这边协议签署文件发送到对应的邮箱了,这边还需要做什么吗? |
@BinaryOracle 你提交commit用的邮箱应该不是你github的邮箱 |
提交代码的邮箱没认证,目前已经认证通过了 |
问题描述
项目路径下提供了一个测试用例文件: sys_exec_test.go , 其中提供了一个测试函数TestReadv,用于测试Readv系统调用:
在没有修改前,readv的源码如下:
最终输出的结果为 , 缓冲区中的数据为空,都被清空了,不符合预期:
解决办法
将readv中清空缓冲区的方法调用移除:
再次运行测试用例,输出如下: