Skip to content

Commit 6533f26

Browse files
committed
test/crimson/test_crimson_coroutine: add test_coroutine_loops
Signed-off-by: Matan Breizman <[email protected]>
1 parent 1f80b38 commit 6533f26

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/crimson/test_crimson_coroutine.cc

+23
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <numeric>
66

77
#include "seastar/core/sleep.hh"
8+
#include "seastar/core/loop.hh"
89

910
#include "crimson/common/coroutine.h"
1011
#include "crimson/common/errorator.h"
@@ -103,6 +104,28 @@ TEST_F(coroutine_test_t, test_coroutine)
103104
});
104105
}
105106

107+
TEST_F(coroutine_test_t, test_coroutine_loops)
108+
{
109+
run_scl([]() -> seastar::future<> {
110+
int CHECK = 0;
111+
std::vector<int> v = {1,2,3};
112+
co_await seastar::parallel_for_each(v,
113+
[&CHECK] (auto i) -> seastar::future<> {
114+
CHECK++;
115+
co_return;
116+
});
117+
EXPECT_EQ(CHECK, v.size());
118+
119+
co_await seastar::do_until(
120+
[&CHECK] { return CHECK == 0; },
121+
[&CHECK] () -> seastar::future<> {
122+
CHECK--;
123+
co_return;
124+
});
125+
EXPECT_EQ(CHECK, 0);
126+
});
127+
}
128+
106129
TEST_F(coroutine_test_t, test_ertr_coroutine_basic)
107130
{
108131
run_ertr_scl([]() -> ertr::future<> {

0 commit comments

Comments
 (0)