From fa8b4afa8149b40b59f535a9059db8fcf37e6043 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 31 Jan 2025 14:50:47 -0800 Subject: [PATCH] progress --- tools/artifact_gen/artifact_gen.cc | 106 +++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/tools/artifact_gen/artifact_gen.cc b/tools/artifact_gen/artifact_gen.cc index 5b6763c83bb6e..de27c8d8e7ed6 100644 --- a/tools/artifact_gen/artifact_gen.cc +++ b/tools/artifact_gen/artifact_gen.cc @@ -207,7 +207,108 @@ class ArtifactGen { } } + void PatchGrpcProtoLibraryRules() { + for (auto& [name, bazel_rule] : rules_) { + if (absl::StartsWith(name, "//") && + (bazel_rule.generator_function == "grpc_proto_library" || + bazel_rule.clazz == "cc_proto_library")) { + bazel_rule.deps.push_back("//third_party:protobuf"); + } + } + } + + void PatchDescriptorUpbProtoLibrary() { + auto it = rules_.find("@com_google_protobuf//upb:descriptor_upb_proto"); + if (it == rules_.end()) return; + auto& bazel_rule = it->second; + bazel_rule.srcs.push_back( + ":src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c"); + bazel_rule.hdrs.push_back( + ":src/core/ext/upb-gen/google/protobuf/descriptor.upb.h"); + } + + void PopulateCcTests() { + for (const auto& [_, bazel_rule] : rules_) { + if (bazel_rule.clazz != "cc_test") continue; + std::string test_name = bazel_rule.name; + if (!absl::StartsWith(test_name, "//")) continue; + test_name = test_name.substr(2); + if (!WantCcTest(test_name)) continue; + tests_.push_back(test_name); + } + } + + void GenerateExtraMetadataForTests() { + for (const auto& test : tests_) { + LOG(FATAL) << "unimplemented"; + } + } + private: + bool WantCcTest(absl::string_view test) { + // most qps tests are autogenerated, we are fine without them + if (absl::StartsWith(test, "test/cpp/qps:")) return false; + // microbenchmarks aren't needed for checking correctness + if (absl::StartsWith(test, "test/cpp/microbenchmarks:")) return false; + if (absl::StartsWith(test, "test/core/promise/benchmark:")) return false; + // we have trouble with census dependency outside of bazel + if (absl::StartsWith(test, "test/cpp/ext/filters/census:")) return false; + if (absl::StartsWith(test, + "test/core/server:xds_channel_stack_modifier_test")) { + return false; + } + if (absl::StartsWith(test, "test/cpp/ext/gcp:")) return false; + if (absl::StartsWith(test, "test/cpp/ext/filters/logging:")) return false; + if (absl::StartsWith(test, "test/cpp/interop:observability_interop")) { + return false; + } + // we have not added otel dependency outside of bazel + if (absl::StartsWith(test, "test/cpp/ext/csm:")) return false; + if (absl::StartsWith(test, "test/cpp/interop:xds_interop")) return false; + // missing opencensus/stats/stats.h + if (absl::StartsWith( + test, "test/cpp/end2end:server_load_reporting_end2end_test")) { + return false; + } + if (absl::StartsWith( + test, "test/cpp/server/load_reporter:lb_load_reporter_test")) { + return false; + } + // The test uses --running_under_bazel cmdline argument + // To avoid the trouble needing to adjust it, we just skip the test + if (absl::StartsWith( + test, "test/cpp/naming:resolver_component_tests_runner_invoker")) { + return false; + } + // the test requires 'client_crash_test_server' to be built + if (absl::StartsWith(test, "test/cpp/end2end:time_change_test")) { + return false; + } + if (absl::StartsWith(test, "test/cpp/end2end:client_crash_test")) { + return false; + } + // the test requires 'server_crash_test_client' to be built + if (absl::StartsWith(test, "test/cpp/end2end:server_crash_test")) { + return false; + } + // test never existed under build.yaml and it fails -> skip it + if (absl::StartsWith(test, "test/core/tsi:ssl_session_cache_test")) { + return false; + } + // the binary of this test does not get built with cmake + if (absl::StartsWith(test, "test/cpp/util:channelz_sampler_test")) { + return false; + } + // chaotic good not supported outside bazel + if (absl::StartsWith(test, "test/core/transport/chaotic_good")) { + return false; + } + // we don't need to generate fuzzers outside of bazel + if (absl::EndsWith(test, "_fuzzer")) return false; + if (absl::StrContains(test, "_fuzzer_")) return false; + return true; + } + std::set GetTransitiveProtos(std::string root) { std::queue todo; std::set visited; @@ -262,6 +363,7 @@ class ArtifactGen { } std::map rules_; + std::vector tests_; const std::map external_source_prefixes_ = { // TODO(veblush) : Remove @utf8_range// item once protobuf is upgraded // to 26.x @@ -308,5 +410,9 @@ int main(int argc, char** argv) { generator.LoadRulesXml(argv[i]); } generator.ExpandUpbProtoLibraryRules(); + generator.PatchGrpcProtoLibraryRules(); + generator.PatchDescriptorUpbProtoLibrary(); + generator.PopulateCcTests(); + generator.GenerateExtraMetadataForTests(); return 0; }