xref: /aosp_15_r20/external/grpc-grpc/test/core/end2end/end2end_test_main.cc (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 // Copyright 2022 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 <string>
16 #include <vector>
17 
18 #include "absl/functional/any_invocable.h"
19 #include "absl/strings/str_cat.h"
20 #include "absl/types/optional.h"
21 #include "gtest/gtest.h"
22 
23 #include "src/core/lib/config/config_vars.h"
24 #include "test/core/end2end/end2end_tests.h"
25 #include "test/core/end2end/fixtures/h2_tls_common.h"
26 #include "test/core/util/test_config.h"
27 
28 namespace grpc_core {
29 extern void EnsureSuitesLinked();
30 }
31 
main(int argc,char ** argv)32 int main(int argc, char** argv) {
33   grpc::testing::TestEnvironment env(&argc, argv);
34   grpc_core::EnsureSuitesLinked();
35   ::testing::InitGoogleTest(&argc, argv);
36   // TODO(ctiller): make this per fixture?
37   grpc_core::ConfigVars::Overrides overrides;
38   overrides.default_ssl_roots_file_path = CA_CERT_PATH;
39   grpc_core::ConfigVars::SetOverrides(overrides);
40   const auto all_tests = grpc_core::CoreEnd2endTestRegistry::Get().AllTests();
41   for (const auto& test : all_tests) {
42     ::testing::RegisterTest(
43         absl::StrCat(test.suite).c_str(),
44         absl::StrCat(test.name, "/", test.config->name).c_str(), nullptr,
45         nullptr, __FILE__, __LINE__,
46         [test = &test]() -> grpc_core::CoreEnd2endTest* {
47           return test->make_test(test->config);
48         });
49   }
50   return RUN_ALL_TESTS();
51 }
52