我有一个测试脚本,通过各种输入反复运行一个小应用程序:
# test_script.sh
for input1 in $some_range; do
for input2 in $some_other_range; do
if ! ./my_app $input1 $input2 2>/dev/null; then
echo "ERROR: app failed with inputs: $input1 $input2"
fi
done
done
Run Code Online (Sandbox Code Playgroud)
这一切都很好,除非它失败了,我得到两条消息,我想要的"错误"消息,然后另一条消息(显然来自bash?)提醒我我的应用程序已中止:
test_script.sh: line 10: 641 Aborted ./my_app $input1 $input2
ERROR: app failed with inputs: XXX YYY
Run Code Online (Sandbox Code Playgroud)
如何防止"中止"消息?
另请注意:应用程序可能在标准C库'assert'语句上失败.