我如何使ctest使用valgrind运行没有飞镖的程序? [英] How do I make ctest run a program with valgrind without dart?

查看:110
本文介绍了我如何使ctest使用valgrind运行没有飞镖的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个CMakeLists.txt,以便可以正常运行测试或使用valgrind运行测试。在将ctest与valgrind集成中,我已经看到了很多东西,但是所有这些假设都是要设置服务器以将测试结果提交到dart仪表板的。我只想在计算机上运行测试,然后在命令行上查看结果。

I want to write a CMakeLists.txt so that I can run my tests normally or with valgrind. I have seen much on integrating ctest with valgrind but all with the assumption that you want to set up a server to submit test results to a dart dashboard. I just want to run the tests on my machine and see the results on the command line.

如果我必须做一个cmake -D VALGRIND = ON可以,但是如果可能的话,我宁愿生成名为 foo和 valgrind_foo的测试。

If I have to do a cmake -D VALGRIND=ON thats fine, but I'd rather generate tests named "foo" and "valgrind_foo" if possible.

推荐答案

我使用valgrind进行内存检查。要配置valgrind,我在构建系统中定义以下变量:

I use valgrind for my memory check. To configure valgrind, I define the following variables in my build system:

find_program( MEMORYCHECK_COMMAND valgrind )
set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )

也在那里是我的valgrind抑制文件:

Also, in there is my valgrind suppression file:

set( MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/valgrind_suppress.txt" )

写完CMakeLists.txt文件并正确配置valgrind之后,可以运行以下命令:

After you write your CMakeLists.txt files and configure valgrind correctly in them, you can run the following command:

cmake -G ... (to configure your build)
ctest -D ExperimentalBuild (this will build your code)
ctest -R testName -D ExperimentalTest (just runs the test)
ctest -R testName -D ExperimentalMemCheck (to run the test under valgrind)

这将欺骗您的构建系统以在本地运行测试自动化。它希望您运行:

This will trick your build system to run the test automation locally. It expects you to run:

ctest -R testName -D ExperimentalSubmit

next,提交到(默认或您的)仪表板,但您无需执行此步骤即可运行所需的东西。结果将存储在Testing / Temporary /目录中。

next, to submit to the (default or your) Dashboard, but you don't need to go through this step to run what you want. The results will be stored in the Testing/Temporary/ directory.

这篇关于我如何使ctest使用valgrind运行没有飞镖的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆