xref: /aosp_15_r20/external/grpc-grpc/test/core/event_engine/test_init.cc (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 // Copyright 2022 The 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 #include "test/core/event_engine/test_init.h"
15 
16 #include <string>
17 
18 #include "absl/strings/str_cat.h"
19 
20 #include <grpc/support/port_platform.h>
21 
22 namespace grpc_event_engine {
23 namespace experimental {
24 
25 /// Sets the default EventEngine factory, used for testing.
26 /// Currently the only valid engine is 'default' or ''.
27 /// When more engines are added, this should be updated accordingly.
InitializeTestingEventEngineFactory(absl::string_view engine)28 absl::Status InitializeTestingEventEngineFactory(absl::string_view engine) {
29   if (engine == "default" || engine.empty()) {
30     // No-op, the default will be used
31     return absl::OkStatus();
32   }
33   return absl::InvalidArgumentError(
34       absl::StrCat("Unknown EventEngine implementation: ", engine));
35 }
36 
37 }  // namespace experimental
38 }  // namespace grpc_event_engine
39