xref: /aosp_15_r20/external/grpc-grpc/test/core/experiments/experiments_test.cc (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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 // Auto generated by tools/codegen/core/gen_experiments.py
16 
17 #include "test/core/experiments/fixtures/experiments.h"
18 
19 #include <memory>
20 
21 #include "gtest/gtest.h"
22 
23 #include <grpc/support/port_platform.h>
24 
25 #include "src/core/lib/experiments/config.h"
26 
27 #ifndef GRPC_EXPERIMENTS_ARE_FINAL
28 
29 #if defined(GRPC_CFSTREAM)
GetExperimentTestExperiment1ExpectedValue()30 bool GetExperimentTestExperiment1ExpectedValue() { return false; }
31 
GetExperimentTestExperiment2ExpectedValue()32 bool GetExperimentTestExperiment2ExpectedValue() { return true; }
33 
GetExperimentTestExperiment3ExpectedValue()34 bool GetExperimentTestExperiment3ExpectedValue() {
35 #ifdef NDEBUG
36   return false;
37 #else
38   return true;
39 #endif
40 }
41 
GetExperimentTestExperiment4ExpectedValue()42 bool GetExperimentTestExperiment4ExpectedValue() { return true; }
43 
44 #elif defined(GPR_WINDOWS)
GetExperimentTestExperiment1ExpectedValue()45 bool GetExperimentTestExperiment1ExpectedValue() { return false; }
46 
GetExperimentTestExperiment2ExpectedValue()47 bool GetExperimentTestExperiment2ExpectedValue() { return false; }
48 
GetExperimentTestExperiment3ExpectedValue()49 bool GetExperimentTestExperiment3ExpectedValue() {
50 
51 #ifdef NDEBUG
52   return false;
53 #else
54   return true;
55 #endif
56 }
57 
GetExperimentTestExperiment4ExpectedValue()58 bool GetExperimentTestExperiment4ExpectedValue() { return true; }
59 
60 #else
GetExperimentTestExperiment1ExpectedValue()61 bool GetExperimentTestExperiment1ExpectedValue() {
62 
63 #ifdef NDEBUG
64   return false;
65 #else
66   return true;
67 #endif
68 }
69 
GetExperimentTestExperiment2ExpectedValue()70 bool GetExperimentTestExperiment2ExpectedValue() {
71 
72 #ifdef NDEBUG
73   return false;
74 #else
75   return true;
76 #endif
77 }
78 
GetExperimentTestExperiment3ExpectedValue()79 bool GetExperimentTestExperiment3ExpectedValue() {
80 
81 #ifdef NDEBUG
82   return false;
83 #else
84   return true;
85 #endif
86 }
87 
GetExperimentTestExperiment4ExpectedValue()88 bool GetExperimentTestExperiment4ExpectedValue() { return false; }
89 #endif
90 
TEST(ExperimentsTest,CheckExperimentValuesTest)91 TEST(ExperimentsTest, CheckExperimentValuesTest) {
92   ASSERT_EQ(grpc_core::IsTestExperiment1Enabled(),
93             GetExperimentTestExperiment1ExpectedValue());
94 
95   ASSERT_EQ(grpc_core::IsTestExperiment2Enabled(),
96             GetExperimentTestExperiment2ExpectedValue());
97 
98   ASSERT_EQ(grpc_core::IsTestExperiment3Enabled(),
99             GetExperimentTestExperiment3ExpectedValue());
100 
101   ASSERT_EQ(grpc_core::IsTestExperiment4Enabled(),
102             GetExperimentTestExperiment4ExpectedValue());
103 }
104 
105 #endif  // GRPC_EXPERIMENTS_ARE_FINAL
106 
main(int argc,char ** argv)107 int main(int argc, char** argv) {
108   testing::InitGoogleTest(&argc, argv);
109   grpc_core::LoadTestOnlyExperimentsFromMetadata(
110       grpc_core::g_test_experiment_metadata, grpc_core::kNumTestExperiments);
111   return RUN_ALL_TESTS();
112 }
113