exec_ctx_wakeup_scheduler_test.cc
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #include <stdlib.h>
18 
19 #include <memory>
20 
21 #include "absl/status/status.h"
22 #include "gtest/gtest.h"
23 
26 
27 namespace grpc_core {
28 
29 TEST(ExecCtxWakeupSchedulerTest, Works) {
30  int state = 0;
31  bool done = false;
32  auto activity = MakeActivity(
33  [&state]() mutable -> Poll<absl::Status> {
34  ++state;
35  switch (state) {
36  case 1:
37  return Pending();
38  case 2:
39  return absl::OkStatus();
40  default:
41  abort();
42  }
43  },
47  done = true;
48  });
49 
50  EXPECT_EQ(state, 1);
52  {
55  activity->ForceWakeup();
57  EXPECT_EQ(state, 1);
59  }
60  EXPECT_EQ(state, 2);
62 }
63 
64 } // namespace grpc_core
65 
66 int main(int argc, char** argv) {
67  ::testing::InitGoogleTest(&argc, argv);
68  return RUN_ALL_TESTS();
69 }
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
main
int main(int argc, char **argv)
Definition: exec_ctx_wakeup_scheduler_test.cc:66
grpc_core
Definition: call_metric_recorder.h:31
absl::OkStatus
Status OkStatus()
Definition: third_party/abseil-cpp/absl/status/status.h:882
grpc_core::TEST
TEST(AvlTest, NoOp)
Definition: avl_test.cc:21
status
absl::Status status
Definition: rls.cc:251
grpc_core::ExecCtx::HasWork
bool HasWork()
Definition: exec_ctx.h:152
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
grpc_core::MakeActivity
ActivityPtr MakeActivity(Factory promise_factory, WakeupScheduler wakeup_scheduler, OnDone on_done, Contexts &&... contexts)
Definition: activity.h:522
grpc_core::Pending
Definition: poll.h:29
exec_ctx_wakeup_scheduler.h
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
grpc_core::ExecCtx
Definition: exec_ctx.h:97
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
poll.h
absl::Status
Definition: third_party/abseil-cpp/absl/status/status.h:424
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
grpc_core::ExecCtxWakeupScheduler
Definition: exec_ctx_wakeup_scheduler.h:29
activity.h
absl::variant
Definition: abseil-cpp/absl/types/internal/variant.h:46
state
static struct rpc_state state
Definition: bad_server_response_test.cc:87


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:20