• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 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 
15 #include <memory>
16 
17 #include "gtest/gtest.h"
18 #include "src/core/lib/channel/channel_args.h"
19 #include "src/core/lib/resource_quota/arena.h"
20 #include "src/core/telemetry/call_tracer.h"
21 #include "src/core/util/crash.h"
22 
23 namespace grpc_core {
24 namespace {
25 
26 class TestServerCallTracerFactory : public ServerCallTracerFactory {
27  public:
CreateNewServerCallTracer(Arena *,const ChannelArgs &)28   ServerCallTracer* CreateNewServerCallTracer(
29       Arena* /*arena*/, const ChannelArgs& /*args*/) override {
30     Crash("Not implemented");
31   }
32 };
33 
TEST(ServerCallTracerFactoryTest,GlobalRegistration)34 TEST(ServerCallTracerFactoryTest, GlobalRegistration) {
35   TestServerCallTracerFactory factory;
36   ServerCallTracerFactory::RegisterGlobal(&factory);
37   EXPECT_EQ(ServerCallTracerFactory::Get(ChannelArgs()), &factory);
38 }
39 
TEST(ServerCallTracerFactoryTest,UsingChannelArgs)40 TEST(ServerCallTracerFactoryTest, UsingChannelArgs) {
41   TestServerCallTracerFactory factory;
42   ChannelArgs args = ChannelArgs().SetObject(&factory);
43   EXPECT_EQ(ServerCallTracerFactory::Get(args), &factory);
44 }
45 
46 }  // namespace
47 }  // namespace grpc_core
48 
main(int argc,char ** argv)49 int main(int argc, char** argv) {
50   ::testing::InitGoogleTest(&argc, argv);
51   return RUN_ALL_TESTS();
52 }
53