From: Samuel Just Date: Mon, 21 Jun 2021 23:57:48 +0000 (-0700) Subject: test/crimson/test_interruptible_future: add tests for errorated behavior X-Git-Tag: v17.1.0~1567^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=28a9016634a85d799ee0c71d548f1abc09df6035;p=ceph.git test/crimson/test_interruptible_future: add tests for errorated behavior Signed-off-by: Samuel Just --- diff --git a/src/test/crimson/test_interruptible_future.cc b/src/test/crimson/test_interruptible_future.cc index ddaeed80ed13..74613fbf7505 100644 --- a/src/test/crimson/test_interruptible_future.cc +++ b/src/test/crimson/test_interruptible_future.cc @@ -167,3 +167,80 @@ TEST_F(seastar_test_suite_t, loops) }, [](std::exception_ptr) {}, false).get0(); }); } + +using base_intr = interruptible::interruptor; + +using base_ertr = errorator; +using base_iertr = interruptible::interruptible_errorator< + TestInterruptCondition, + base_ertr>; + +using base2_ertr = base_ertr::extend; +using base2_iertr = interruptible::interruptible_errorator< + TestInterruptCondition, + base2_ertr>; + +template +auto with_intr(F &&f) { + return base_intr::with_interruption_to_error( + std::forward(f), + TestInterruptCondition(false)); +} + +TEST_F(seastar_test_suite_t, errorated) +{ + run_async([] { + base_ertr::future<> ret = with_intr( + []() { + return base_iertr::now(); + } + ); + ret.unsafe_get0(); + }); +} + +TEST_F(seastar_test_suite_t, errorated_value) +{ + run_async([] { + base_ertr::future ret = with_intr( + []() { + return base_iertr::make_ready_future( + 1 + ); + }); + EXPECT_EQ(ret.unsafe_get0(), 1); + }); +} + +TEST_F(seastar_test_suite_t, expand_errorated_value) +{ + run_async([] { + base2_ertr::future<> ret = with_intr( + []() { + return base_iertr::make_ready_future( + 1 + ).si_then([](auto) { + return base2_iertr::make_ready_future<>(); + }); + }); + ret.unsafe_get0(); + }); +} + +TEST_F(seastar_test_suite_t, handle_error) +{ + run_async([] { + base_ertr::future<> ret = with_intr( + []() { + return base2_iertr::make_ready_future( + 1 + ).handle_error_interruptible( + base_iertr::pass_further{}, + ct_error::assert_all{"crash on eio"} + ).si_then([](auto) { + return base_iertr::now(); + }); + }); + ret.unsafe_get0(); + }); +}