29
29
using namespace seastar ;
30
30
31
31
SEASTAR_TEST_CASE (deferred_close_test) {
32
- int count = 0 ;
33
- int expected = 42 ;
34
- gate g;
35
-
32
+ return do_with (gate (), 0 , 42 , [] (gate& g, int & count, int & expected) {
36
33
return async ([&] {
37
34
auto close_gate = deferred_close (g);
38
35
@@ -47,13 +44,11 @@ SEASTAR_TEST_CASE(deferred_close_test) {
47
44
BOOST_REQUIRE (g.is_closed ());
48
45
BOOST_REQUIRE_EQUAL (count, expected);
49
46
});
47
+ });
50
48
}
51
49
52
50
SEASTAR_TEST_CASE (close_now_test) {
53
- int count = 0 ;
54
- int expected = 42 ;
55
- gate g;
56
-
51
+ return do_with (gate (), 0 , 42 , [] (gate& g, int & count, int & expected) {
57
52
return async ([&] {
58
53
auto close_gate = deferred_close (g);
59
54
@@ -68,6 +63,7 @@ SEASTAR_TEST_CASE(close_now_test) {
68
63
BOOST_REQUIRE_EQUAL (count, expected);
69
64
// gate must not be double-closed.
70
65
});
66
+ });
71
67
}
72
68
73
69
namespace {
@@ -84,19 +80,18 @@ struct count_stops {
84
80
} // anonymous namespace
85
81
86
82
SEASTAR_TEST_CASE (deferred_stop_test) {
87
- count_stops cs;
88
-
83
+ return do_with (count_stops (), [] (count_stops& cs) {
89
84
return async ([&] {
90
85
auto stop_counting = deferred_stop (cs);
91
86
}).then ([&] {
92
87
// cs.stop() should be called when stop_counting is destroyed
93
88
BOOST_REQUIRE_EQUAL (cs.stopped , 1 );
94
89
});
90
+ });
95
91
}
96
92
97
93
SEASTAR_TEST_CASE (stop_now_test) {
98
- count_stops cs;
99
-
94
+ return do_with (count_stops (), [] (count_stops& cs) {
100
95
return async ([&] {
101
96
auto stop_counting = deferred_stop (cs);
102
97
@@ -108,4 +103,5 @@ SEASTAR_TEST_CASE(stop_now_test) {
108
103
// cs.stop() should be called exactly once
109
104
BOOST_REQUIRE_EQUAL (cs.stopped , 1 );
110
105
});
106
+ });
111
107
}
0 commit comments