From: Xuehan Xu Date: Thu, 19 Aug 2021 08:29:38 +0000 (+0800) Subject: test/crimson: add interruptible async unit test X-Git-Tag: v17.1.0~1038^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d01f0eb69d7f8adaabc5fc2a36dc174bc1bb4254;p=ceph.git test/crimson: add interruptible async unit test Signed-off-by: Xuehan Xu --- diff --git a/src/test/crimson/test_interruptible_future.cc b/src/test/crimson/test_interruptible_future.cc index 8f98a7d98bc3..4e4288686dea 100644 --- a/src/test/crimson/test_interruptible_future.cc +++ b/src/test/crimson/test_interruptible_future.cc @@ -41,7 +41,7 @@ private: namespace crimson::interruptible { template -thread_local InterruptCondRef +thread_local interrupt_cond_t interrupt_cond; } @@ -233,6 +233,30 @@ TEST_F(seastar_test_suite_t, expand_errorated_value) }); } +TEST_F(seastar_test_suite_t, interruptible_async) +{ + using interruptor = + interruptible::interruptor; + + run_async([] { + interruptor::with_interruption([] { + auto fut = interruptor::async([] { + interruptor::make_interruptible( + seastar::sleep(std::chrono::milliseconds(10))).get(); + ceph_assert(interruptible::interrupt_cond< + TestInterruptCondition>.interrupt_cond); + ceph_assert(interruptible::interrupt_cond< + TestInterruptCondition>.ref_count == 1); + }); + ceph_assert(interruptible::interrupt_cond< + TestInterruptCondition>.interrupt_cond); + ceph_assert(interruptible::interrupt_cond< + TestInterruptCondition>.ref_count == 1); + return fut; + }, [](std::exception_ptr) {}, false).get0(); + }); +} + #if 0 // This seems to cause a hang in the gcc-9 linker on bionic TEST_F(seastar_test_suite_t, handle_error)