Skip to content

Commit 3f41030

Browse files
committed
test/crimson/test_errorator: ignore assert_all
This came up during: https://tracker.ceph.com/issues/69406#note-25 Where an "assert_all" was called but didn't cause an abort. Added "ignore_assert_all" to showcase this scenario along with any other case where we are expected to abort. The tests could be used to verify errorator's aborting behavior. Signed-off-by: Matan Breizman <[email protected]>
1 parent 78f1306 commit 3f41030

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

src/test/crimson/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ target_link_libraries(
111111
add_ceph_unittest(unittest-seastar-errorator
112112
--memory 256M --smp 1)
113113

114+
add_executable(unittest-seastar-errorator-abort
115+
test_errorator_abort.cc)
116+
target_link_libraries(
117+
unittest-seastar-errorator-abort
118+
crimson::gtest)
119+
114120
add_executable(unittest-crimson-coroutine
115121
test_crimson_coroutine.cc)
116122
target_link_libraries(
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2+
// vim: ts=8 sw=2 smarttab
3+
4+
#include <boost/iterator/counting_iterator.hpp>
5+
#include <numeric>
6+
7+
#include "test/crimson/gtest_seastar.h"
8+
9+
#include "crimson/common/errorator.h"
10+
#include "crimson/common/errorator-loop.h"
11+
#include "crimson/common/log.h"
12+
#include "seastar/core/sleep.hh"
13+
14+
struct errorator_abort_test_t : public seastar_test_suite_t {
15+
using ertr = crimson::errorator<crimson::ct_error::invarg>;
16+
17+
ertr::future<> invarg_foo() {
18+
return crimson::ct_error::invarg::make();
19+
};
20+
21+
ertr::future<> clean_foo() {
22+
return ertr::now();
23+
};
24+
25+
struct noncopyable_t {
26+
constexpr noncopyable_t() = default;
27+
~noncopyable_t() = default;
28+
noncopyable_t(noncopyable_t&&) = default;
29+
private:
30+
noncopyable_t(const noncopyable_t&) = delete;
31+
noncopyable_t& operator=(const noncopyable_t&) = delete;
32+
};
33+
};
34+
35+
// --- The following tests must abort ---
36+
37+
/*
38+
TEST_F(errorator_abort_test_t, abort_vanilla)
39+
{
40+
run_async([this] {
41+
abort();
42+
return seastar::now().get();
43+
});
44+
}
45+
*/
46+
47+
/*
48+
TEST_F(errorator_abort_test_t, abort_ignored)
49+
{
50+
run_async([this] {
51+
auto foo = []() -> seastar::future<> {
52+
abort();
53+
return seastar::now();
54+
};
55+
56+
std::ignore = foo();
57+
return seastar::now().get();
58+
});
59+
}
60+
*/
61+
62+
/*
63+
TEST_F(errorator_abort_test_t, assert_all)
64+
{
65+
run_async([this] {
66+
return invarg_foo().handle_error(
67+
crimson::ct_error::assert_all("unexpected error")
68+
).get();
69+
});
70+
}
71+
*/
72+
73+
/*
74+
TEST_F(errorator_abort_test_t, ignore_assert_all)
75+
{
76+
run_async([this] {
77+
std::ignore = invarg_foo().handle_error(
78+
crimson::ct_error::assert_all("unexpected error")
79+
);
80+
return seastar::now().get();
81+
});
82+
}
83+
84+
TEST_F(errorator_abort_test_t, ignore_assert_failure)
85+
{
86+
run_async([this] {
87+
std::ignore = invarg_foo().handle_error(
88+
crimson::ct_error::invarg::assert_failure{"unexpected invarg"}
89+
);
90+
return seastar::now().get();
91+
});
92+
}
93+
*/

0 commit comments

Comments
 (0)