From: Xuehan Xu Date: Wed, 11 Mar 2026 08:04:51 +0000 (+0800) Subject: test/crimson/test_interruptible_future: add UT cases for interruption X-Git-Tag: v21.0.1~683^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e1b4457d8573c3acd3acc141041c9a49e63c0714;p=ceph.git test/crimson/test_interruptible_future: add UT cases for interruption handling in interruptor::green_get/yield/maybe_yield Signed-off-by: Xuehan Xu --- diff --git a/src/test/crimson/test_interruptible_future.cc b/src/test/crimson/test_interruptible_future.cc index 697c35788729..338a82e8e29d 100644 --- a/src/test/crimson/test_interruptible_future.cc +++ b/src/test/crimson/test_interruptible_future.cc @@ -35,6 +35,10 @@ public: return true; return false; } + + void set_interrupt() { + interrupt = true; + } private: bool interrupt = false; }; @@ -262,6 +266,66 @@ TEST_F(seastar_test_suite_t, interruptible_async) return fut; }, [](std::exception_ptr) {}, false).get(); }); + +} + +TEST_F(seastar_test_suite_t, interruptible_yield) +{ + using interruptor = + interruptible::interruptor; + + run_async([] { + bool interrupted = false; + auto fut = interruptor::with_interruption([] { + return interruptor::async([] { + interruptible::interrupt_cond< + TestInterruptCondition>.interrupt_cond->set_interrupt(); + interruptor::yield(); + // the execution should be interrupted, the run should + // never reach here. + ceph_abort(); + }); + }, [&interrupted](std::exception_ptr) { + std::cout << "interrupted" << std::endl; + interrupted = true; + }, false); + fut.wait(); + ceph_assert(interrupted); + + interrupted = false; + fut = interruptor::with_interruption([] { + return interruptor::async([] { + interruptible::interrupt_cond< + TestInterruptCondition>.interrupt_cond->set_interrupt(); + interruptor::green_get(seastar::yield()); + // the execution should be interrupted, the run should + // never reach here. + ceph_abort(); + }); + }, [&interrupted](std::exception_ptr) { + std::cout << "interrupted" << std::endl; + interrupted = true; + }, false); + fut.wait(); + ceph_assert(interrupted); + + interrupted = false; + fut = interruptor::with_interruption([] { + return interruptor::async([] { + interruptible::interrupt_cond< + TestInterruptCondition>.interrupt_cond->set_interrupt(); + interruptor::make_interruptible(seastar::yield()).get(); + // the execution should be interrupted, the run should + // never reach here. + ceph_abort(); + }); + }, [&interrupted](std::exception_ptr) { + std::cout << "interrupted" << std::endl; + interrupted = true; + }, false); + fut.wait(); + ceph_assert(interrupted); + }); } TEST_F(seastar_test_suite_t, DISABLED_nested_interruptors)