Skip to content

Commit 1f4a05c

Browse files
authored
Merge pull request ceph#62635 from Matan-B/wip-matanb-crimson-ignore-abort
test/crimson/test_errorator: showcase assert_all/handle/pass_furhter Reviewed-by: Yingxin Cheng <[email protected]> Reviewed-by: Samuel Just <[email protected]>
2 parents 7b9a62d + 396674f commit 1f4a05c

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/test/crimson/test_errorator.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
struct errorator_test_t : public seastar_test_suite_t {
1515
using ertr = crimson::errorator<crimson::ct_error::invarg>;
1616

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+
1725
struct noncopyable_t {
1826
constexpr noncopyable_t() = default;
1927
~noncopyable_t() = default;
@@ -85,3 +93,43 @@ TEST_F(errorator_test_t, test_futurization)
8593
}).unsafe_get();
8694
});
8795
}
96+
97+
TEST_F(errorator_test_t, no_handle_error)
98+
{
99+
run_async([this] {
100+
return clean_foo().handle_error(
101+
crimson::ct_error::assert_all("unexpected error")
102+
).get();
103+
});
104+
}
105+
106+
TEST_F(errorator_test_t, handle_specific_error)
107+
{
108+
int res = 0;
109+
run_async([&res, this] {
110+
return invarg_foo().handle_error(
111+
crimson::ct_error::invarg::handle([&res] (const auto& ec) {
112+
EXPECT_EQ(ec.value(), EINVAL);
113+
res = 1;
114+
return seastar::now();
115+
}),
116+
crimson::ct_error::assert_all("unexpected error")).get();
117+
});
118+
EXPECT_EQ(res, 1);
119+
}
120+
121+
TEST_F(errorator_test_t, pass_further_error)
122+
{
123+
int res = 0;
124+
run_async([&res, this] {
125+
return invarg_foo().handle_error(
126+
ertr::pass_further{}
127+
).handle_error(
128+
crimson::ct_error::invarg::handle([&res] (const auto& ec) {
129+
res = 1;
130+
return seastar::now();
131+
}),
132+
crimson::ct_error::assert_all("unexpected error")).get();
133+
});
134+
EXPECT_EQ(res, 1);
135+
}

0 commit comments

Comments
 (0)