Skip to content

Commit 08e96d0

Browse files
authored
Merge pull request ceph#62765 from bobham-bloomberg/unittest-ceph-assert
test/ceph_assert.cc: Disable core files
2 parents d1eb244 + 430a9aa commit 08e96d0

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/test/ceph_assert.cc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
22
// vim: ts=8 sw=2 sts=2 expandtab
33

4+
#include <sys/time.h>
5+
#include <sys/resource.h>
46
#include <fmt/format.h>
57

68
#include "common/ceph_argparse.h"
@@ -12,27 +14,30 @@
1214

1315
#include "gtest/gtest.h"
1416

15-
static void non_supressed_assert_line16() {
16-
ceph_assert(42 == 41); // LINE16
17+
static void non_supressed_assert_line18() {
18+
ceph_assert(42 == 41); // LINE18
1719
}
18-
static void supressed_assert_line19() {
19-
ceph_assert(42 == 40); // LINE19
20+
static void supressed_assert_line21() {
21+
ceph_assert(42 == 40); // LINE21
2022
}
21-
static void supressed_assertf_line22() {
22-
ceph_assertf(42 == 39, "FAILED ceph_assertf"); // LINE22
23+
static void supressed_assertf_line24() {
24+
ceph_assertf(42 == 39, "FAILED ceph_assertf"); // LINE24
2325
}
24-
static void non_supressed_assertf_line25() {
25-
ceph_assertf(42 == 38, "FAILED ceph_assertf"); // LINE25
26+
static void non_supressed_assertf_line27() {
27+
ceph_assertf(42 == 38, "FAILED ceph_assertf"); // LINE27
2628
}
2729

2830
TEST(CephAssertDeathTest, ceph_assert_supresssions) {
29-
ASSERT_DEATH(non_supressed_assert_line16(), "FAILED ceph_assert");
30-
supressed_assert_line19();
31-
supressed_assertf_line22();
32-
ASSERT_DEATH(non_supressed_assertf_line25(), "FAILED ceph_assertf");
31+
ASSERT_DEATH(non_supressed_assert_line18(), "FAILED ceph_assert");
32+
supressed_assert_line21();
33+
supressed_assertf_line24();
34+
ASSERT_DEATH(non_supressed_assertf_line27(), "FAILED ceph_assertf");
3335
}
3436

3537
int main(int argc, char **argv) {
38+
// Disable core files
39+
const struct rlimit rlim = { 0, 0 };
40+
setrlimit(RLIMIT_CORE, &rlim);
3641

3742
auto args = argv_to_vec(argc, argv);
3843
auto cct = global_init(
@@ -44,7 +49,7 @@ int main(int argc, char **argv) {
4449
g_ceph_context->_conf.set_val(
4550
"ceph_assert_supresssions",
4651
fmt::format(
47-
"{}:{}, {}:{}", __FILE__, /* LINE19 */19, __FILE__, /* LINE22 */22));
52+
"{}:{}, {}:{}", __FILE__, /* LINE21 */21, __FILE__, /* LINE24 */24));
4853
common_init_finish(g_ceph_context);
4954
testing::InitGoogleTest(&argc, argv);
5055
return RUN_ALL_TESTS();

0 commit comments

Comments
 (0)