当前位置:网站首页>GTEST death test

GTEST death test

2022-06-23 08:03:00 heihei36

auto func = []() {
    exit(1);
};

::testing::FLAGS_gtest_death_test_style = "threadsafe";

EXPECT_EXIT(func(), testing::ExitedWithCode(1), "");

If you don't add ::testing::FLAGS_gtest_death_test_style = "threadsafe";

UT Meeting BLOCK, And there will be the following warning messages :

[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.

原网站

版权声明
本文为[heihei36]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230734399265.html