]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson: add interruptible async unit test
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 19 Aug 2021 08:29:38 +0000 (16:29 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Mon, 23 Aug 2021 10:23:41 +0000 (18:23 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/test/crimson/test_interruptible_future.cc

index 8f98a7d98bc3adba6de75a89f5a868743b41608f..4e4288686dea6a1cd50709ec410307d80311b307 100644 (file)
@@ -41,7 +41,7 @@ private:
 
 namespace crimson::interruptible {
 template
-thread_local InterruptCondRef<TestInterruptCondition>
+thread_local interrupt_cond_t<TestInterruptCondition>
 interrupt_cond<TestInterruptCondition>;
 }
 
@@ -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<TestInterruptCondition>;
+
+  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)