]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: do not consider warning from Sanitizer as fatal
authorKefu Chai <tchaikov@gmail.com>
Tue, 2 Apr 2024 10:15:14 +0000 (18:15 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 3 Apr 2024 05:29:35 +0000 (13:29 +0800)
with sanitizer enabled, unittest_ceph_crypto fails like

```
[ RUN      ] ForkDeathTest.MD5

[WARNING] /home/jenkins-build/build/workspace/ceph-pull-requests/src/googletest/googletest/src/gtest-death-test.cc:1121:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 3 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.
/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/ceph_crypto.cc:273: Failure
Death test: do_simple_crypto()
    Result: died but not with expected error.
  Expected: contains regular expression "^$"
Actual msg:
[  DEATH   ] ==3798016==Running thread 3797882 was not suspended. False leaks are possible.
[  DEATH   ] ==3798016==Running thread 3797885 was not suspended. False leaks are possible.
[  DEATH   ]
[  FAILED  ] ForkDeathTest.MD5 (119 ms)
```

but this error message should not considered as an indication of
fatal error. so, in this change, instead of matching the output with
a regex of "^$", we use a matcher to match with the error message if
sanitizer is enabled.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/test/ceph_crypto.cc

index 477d0c0db75d06acae6a46d22b805e83f0167e31..2755e0486a07111eb42c91710b46fe7e12a1f3c5 100644 (file)
@@ -270,7 +270,15 @@ void do_simple_crypto() {
 
 #if GTEST_HAS_DEATH_TEST && !defined(_WIN32)
 TEST_F(ForkDeathTest, MD5) {
-  ASSERT_EXIT(do_simple_crypto(), ::testing::ExitedWithCode(0), "^$");
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+  // sanitizer warns like:
+  // ==3798016==Running thread 3797882 was not suspended. False leaks are possible.
+  // but we should not take it as a fatal error.
+  const std::string matcher = ".*False leaks are possible.*");
+#else
+  const std::string matcher = "^$";
+#endif
+  ASSERT_EXIT(do_simple_crypto(), ::testing::ExitedWithCode(0), matcher);
 }
 #endif // GTEST_HAS_DEATH_TEST && !defined(_WIN32)