Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing ctest在实际失败时不报告失败的测试_Unit Testing_Cmake_Googletest_Ctest - Fatal编程技术网

Unit testing ctest在实际失败时不报告失败的测试

Unit testing ctest在实际失败时不报告失败的测试,unit-testing,cmake,googletest,ctest,Unit Testing,Cmake,Googletest,Ctest,我有一个单元测试代码,我使用googletest,并使用cmake添加ctest。编译代码后,我可以运行ctest或maketest来检查所有测试是否通过 Test project /sciclone/home00/hshi/AFQMCLIB/build Start 1: mpiTest 1/10 Test #1: mpiTest .......................... Passed 0.05 sec Start 2: timeTest 2/

我有一个单元测试代码,我使用googletest,并使用cmake添加ctest。编译代码后,我可以运行
ctest
maketest
来检查所有测试是否通过

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和google test编写我的单元测试,所有测试都在运行:

add_test( NAME MyTest COMMAND mpirun -np 4 $<TARGET_FILE:MyTest>)
add\u测试(名为MyTest命令mpirun-np4$)

你以前见过类似的问题吗?为什么
ctest
不显示失败错误?

ctest
检查测试的退出状态,以确定测试是通过还是失败。退出状态
0
对应“已通过”。确保测试失败时返回非零值。在这种情况下,您需要让
ctest
对照正则表达式检查测试输出(参见示例)。@Tsyvarev谢谢。我正在使用google测试,我确实在google测试中看到任何退出状态。
ctest
检查测试的退出状态,以确定测试是否通过。退出状态
0
对应“已通过”。确保测试失败时返回非零值。在这种情况下,您需要让
ctest
对照正则表达式检查测试输出(参见示例)。@Tsyvarev谢谢。我正在使用谷歌测试,我确实在谷歌测试中看到了任何退出状态。