我有一个单元测试代码,我使用谷歌测试,并使用cmake添加ctest。编译完代码后,我可以运行ctest
或make test
来检查所有测试。
Test project /sciclone/home00/hshi/AFQMCLIB/build
Start 1: mpiTest
1/10 Test #1: mpiTest .......................... Passed 0.05 sec
Start 2: timeTest
2/10 Test #2: timeTest ......................... Passed 0.07 sec
Start 3: errorAnalysisTest
3/10 Test #3: errorAnalysisTest ................ Passed 0.06 sec
Start 4: randomNumberTest
4/10 Test #4: randomNumberTest ................. Passed 0.23 sec
Start 5: tensorTest
5/10 Test #5: tensorTest ....................... Passed 0.07 sec
Start 6: fftwTest
6/10 Test #6: fftwTest ......................... Passed 0.07 sec
Start 7: mathTest
7/10 Test #7: mathTest ......................... Passed 0.04 sec
Start 8: clusterTest
8/10 Test #8: clusterTest ...................... Passed 0.05 sec
Start 9: realMaterialHamiltonianTest
9/10 Test #9: realMaterialHamiltonianTest ...... Passed 0.11 sec
Start 10: lanczosTest
10/10 Test #10: lanczosTest ...................... Passed 0.05 sec
100% tests passed, 0 tests failed out of 10
Total Test time (real) = 0.80 sec
然而,如果我单独进行第5次测试,我会得到:
...
[----------] 6 tests from Tensor_1d_bl_cpu
[ RUN ] Tensor_1d_bl_cpu.copyBlas
[ OK ] Tensor_1d_bl_cpu.copyBlas (0 ms)
[ RUN ] Tensor_1d_bl_cpu.normBlas
[ OK ] Tensor_1d_bl_cpu.normBlas (0 ms)
[ RUN ] Tensor_1d_bl_cpu.scaleBlas
[ OK ] Tensor_1d_bl_cpu.scaleBlas (0 ms)
[ RUN ] Tensor_1d_bl_cpu.dotcBlas
/sciclone/home00/hshi/AFQMCLIB/AFQMCLIB/libhao/test_hao/gtest_custom.cpp:19: Failure
Expected: expected.real()
Which is: 146.65745800000002
To be equal to: actual.real()
Which is: 0
/sciclone/home00/hshi/AFQMCLIB/AFQMCLIB/libhao/test_hao/gtest_custom.cpp:20: Failure
Expected: expected.imag()
Which is: -36.1877
To be equal to: actual.imag()
Which is: 0
[ FAILED ] Tensor_1d_bl_cpu.dotcBlas (0 ms)
[ RUN ] Tensor_1d_bl_cpu.axpy_cpu
[ OK ] Tensor_1d_bl_cpu.axpy_cpu (0 ms)
[ RUN ] Tensor_1d_bl_cpu.gemv_cpu
[ OK ] Tensor_1d_bl_cpu.gemv_cpu (0 ms)
[----------] 6 tests from Tensor_1d_bl_cpu (0 ms total)
[----------] Global test environment tear-down
[==========] 100 tests from 9 test cases ran. (280 ms total)
[ PASSED ] 99 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] Tensor_1d_bl_cpu.dotcBlas
如果我运行ctest --verbose
,我可以看到失败的信息。但是,如果我运行ctest
,则没有错误。
我正在使用cmake / 3.2.3和谷歌测试来编写单元测试,所有测试都是mpirun:
add_test( NAME MyTest COMMAND mpirun -np 4 $<TARGET_FILE:MyTest>)
你之前见过类似的问题吗?为什么ctest
没有显示失败的错误?