我想在 valgrind 下使用不同的选项测试 C 代码。我希望能够捕获所有输出并根据这些运行的结果报告测试成功/失败。最初我想到了 perl 模块 Test::Valgrind 但无法使用它。还有其他选择可以做到这一点吗?
最佳答案
几乎所有可用的语言都提供了捕获外部程序运行的输出的方法。
- C:
popen
、pclose
- 通过管道将流传入或传出进程 - Perl:反引号 (``) 运算符或
open
函数 - executing external commands - Python:参见Pipe subprocess standard output to a variable
关于将 valgrind 的输出捕获到编程中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20367192/