我有一个bash脚本,需要检测Helgrind是否给出了任何错误。我尝试使用以下内容:
thread_race=$(valgrind --error-exitcode=10 --tool=helgrind ./$2.out $3; echo $?)
$ 2是一个.cpp文件,$ 3是一个参数。但是,这不起作用,因为它实际上不会更改退出代码。
如果检测到任何错误,我期望thread race
为10,否则为其他错误。
是否有办法知道helgrind是否已检测到任何错误,然后保存答案?我正在使用带有lang ++的Ubuntu Linux。
编辑:
在这两种情况下,当helgrind检测到错误并且没有检测到错误时,thread_race
都会返回134。
我有一个类似的测试,但没有helgrind,效果很好。
leak=$(valgrind --leak-check=full --error-exitcode=55 ./$2.out $3 >/dev/null; echo $?)
在给出错误时,这会将退出代码更改为55。我收到通知,正确的退出代码需要--leak-check = full,使用helgrind会导致更多错误:
thread_race=$(valgrind --leak-check=full --error-exitcode=10 --tool=helgrind ./$2.out $3; echo $?)
输出
valgrind: Unknown option: --leak-check=full
and thread_race = 1