From a0466860cac4697859c397b1db2991bf8b7f57fb Mon Sep 17 00:00:00 2001 From: Pranav Thulasiram Bhat Date: Wed, 4 Dec 2024 12:32:13 -0800 Subject: [PATCH] Test async stack tracing for fibers::Baton Summary: Make sure async stack traces are tracked for coroutines awaiting fibers::Baton. Reviewed By: mbucko Differential Revision: D66720217 fbshipit-source-id: 3a944ff6c7b5e0ef824d5d0ff37fd606923a16da --- folly/coro/test/SuspendedStackTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/folly/coro/test/SuspendedStackTest.cpp b/folly/coro/test/SuspendedStackTest.cpp index c855644d1cd..ed9d99641b6 100644 --- a/folly/coro/test/SuspendedStackTest.cpp +++ b/folly/coro/test/SuspendedStackTest.cpp @@ -96,6 +96,26 @@ CO_TEST(SuspendedStacksTest, testBaton) { expectSuspendedFrames(0); } +CO_TEST(SuspendedStacksTest, testFibersBaton) { + auto currentDepth = + (co_await folly::coro::co_current_async_stack_trace).size(); + auto* ex = co_await folly::coro::co_current_executor; + + expectSuspendedFrames(0); + + folly::fibers::Baton b; + waitOn(b).scheduleOn(ex).start(); + co_await folly::coro::co_reschedule_on_current_executor; + expectSuspendedFrames(1, currentDepth + coroDepth); + + // Only one fiber/coro can wait on a fibers::Baton + + b.post(); + co_await folly::coro::co_reschedule_on_current_executor; + + expectSuspendedFrames(0); +} + CO_TEST(SuspendedStacksTest, testLock) { auto currentDepth = (co_await folly::coro::co_current_async_stack_trace).size();