GTEST死亡测试
Posted heihei36
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GTEST死亡测试相关的知识,希望对你有一定的参考价值。
auto func = []()
exit(1);
;
::testing::FLAGS_gtest_death_test_style = "threadsafe";
EXPECT_EXIT(func(), testing::ExitedWithCode(1), "");
若不加上::testing::FLAGS_gtest_death_test_style = "threadsafe";
UT会BLOCK,且会有如下警告信息:
[WARNING] googletest-release-1.10.0/googletest/src/gtest-death-test.cc:1122:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 2 threads. See https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#death-tests-and-threads for more explanation and suggested solutions, especially if this is the last message you see before your test times out.
以上是关于GTEST死亡测试的主要内容,如果未能解决你的问题,请参考以下文章