CTEST和MPI并行测试
我正在尝试使用 googletest 应该测试某些MPI并行代码。理想情况下,我希望我们的CI服务器通过ctest
执行它们。
我的天真方法是简单地使用mpi
调用CTEST:
mpirun -n 3 ctest
但是,只要执行至少两个,这甚至导致琐碎的测试失败。
琐碎测试的示例:
TEST(TestSuite, DummyTest1) {
EXPECT_TRUE(true);
}
TEST(TestSuite, DummyTest2) {
EXPECT_TRUE(true);
}
我应该以其他方式启动ctest
吗?还是我必须完全不同?
其他信息:
- 测试是通过
gtest_discover_tests()
添加的。 - 直接使用MPI(
Mpirun -n 3 Testexe
)启动测试可执行的测试成功测试,但我更喜欢使用ctest
。 - 版本信息:
- googletest:1.11.0
- mpi:OpenMPI 4.0.3和mpich 3.3.2
I'm trying to build some tests with googleTest which should test some MPI parallel code. Ideally I want our CI server to execute them through ctest
.
My naive approach was to simply call ctest with MPI
:
mpirun -n 3 ctest
However, this results in even trivial tests failing as long as at least two are executed.
Example of a trivial tests:
TEST(TestSuite, DummyTest1) {
EXPECT_TRUE(true);
}
TEST(TestSuite, DummyTest2) {
EXPECT_TRUE(true);
}
Am I supposed to launch ctest
in some other way? Or do I have to approach this completely differently?
Additional info:
- The tests are added via
gtest_discover_tests()
. - Launching the test executable directly with MPI (
mpirun -n 3 testExe
) yields successful tests but I would prefer usingctest
. - Version info:
- googletest: 1.11.0
- MPI: OpenMPI 4.0.3 AND MPICH 3.3.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 this cmake post,链接到CMAKE GITLAB存储库中的合并请求和问题,
gtest_discover_tests()
当前根本不支持MPI。可能的解决方法是滥用
crossCompiling_emulator
属性,以将包装器注入测试命令。但是,这不仅改变了整个目标,而不仅会改变测试,因此您的里程可能会有所不同。有关完整的示例,请参见论坛帖子。
According to this CMake Forum post, which links to a Merge Requests and an issue in the CMake GitLab repository,
gtest_discover_tests()
currently simply doesn't support MPI.A possible workaround is to abuse the
CROSSCOMPILING_EMULATOR
property to inject the wrapper into the test command. However, this changes the whole target and not only the tests so your mileage may vary.See the forum post for a full minimal example.