]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/ceph_assert: fix death test timeout with threadsafe style 67085/head
authorKefu Chai <k.chai@proxmox.com>
Tue, 27 Jan 2026 08:34:09 +0000 (16:34 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 27 Jan 2026 08:37:19 +0000 (16:37 +0800)
The unittest_ceph_assert test was timing out intermittently with warning:
```
"Death tests use fork(), which is unsafe particularly in a threaded
context. For this test, Google Test detected 3 threads."
```
The issue occurs because global_init() creates threads before the death
tests run. Use the "threadsafe" death test style to handle this safely,
matching the pattern already used in ceph_breakpad.cc and
test_perf_counters_cache.cc.

see also https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/test/ceph_assert.cc

index ffda501230860d885ac9945b5845bc2d8e5bd228..4fc606d7b119da7a1a9380b6f9801c3bb852e422 100644 (file)
@@ -52,5 +52,6 @@ int main(int argc, char **argv) {
       "{}:{}, {}:{}", __FILE__, /* LINE21 */21, __FILE__, /* LINE24 */24));
   common_init_finish(g_ceph_context);
   testing::InitGoogleTest(&argc, argv);
+  GTEST_FLAG_SET(death_test_style, "threadsafe");
   return RUN_ALL_TESTS();
 }