From df012d048ac4ad50575da8ba729c486f8072bf0d Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 18 May 2016 15:44:06 -0700 Subject: [PATCH 1/3] Add proto file support in grpc_cli --- Makefile | 3 + build.yaml | 2 + test/cpp/util/cli_call.cc | 2 +- test/cpp/util/grpc_cli.cc | 129 ++++++++----- test/cpp/util/proto_file_parser.cc | 177 ++++++++++++++++++ test/cpp/util/proto_file_parser.h | 86 +++++++++ tools/run_tests/sources_and_headers.json | 3 + .../grpc++_test_util/grpc++_test_util.vcxproj | 3 + .../grpc++_test_util.vcxproj.filters | 6 + 9 files changed, 363 insertions(+), 48 deletions(-) create mode 100644 test/cpp/util/proto_file_parser.cc create mode 100644 test/cpp/util/proto_file_parser.h diff --git a/Makefile b/Makefile index 42cedf51c3a..e4ddc112c73 100644 --- a/Makefile +++ b/Makefile @@ -3426,6 +3426,7 @@ LIBGRPC++_TEST_UTIL_SRC = \ test/cpp/util/byte_buffer_proto_helper.cc \ test/cpp/util/cli_call.cc \ test/cpp/util/create_test_channel.cc \ + test/cpp/util/proto_file_parser.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ test/cpp/util/test_credentials_provider.cc \ @@ -3478,6 +3479,7 @@ $(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/gr $(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/proto_file_parser.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc @@ -14466,6 +14468,7 @@ test/cpp/util/benchmark_config.cc: $(OPENSSL_DEP) test/cpp/util/byte_buffer_proto_helper.cc: $(OPENSSL_DEP) test/cpp/util/cli_call.cc: $(OPENSSL_DEP) test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) +test/cpp/util/proto_file_parser.cc: $(OPENSSL_DEP) test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP) test/cpp/util/test_config.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index ac61612da40..e89399ffa26 100644 --- a/build.yaml +++ b/build.yaml @@ -915,6 +915,7 @@ libs: - test/cpp/util/byte_buffer_proto_helper.h - test/cpp/util/cli_call.h - test/cpp/util/create_test_channel.h + - test/cpp/util/proto_file_parser.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h @@ -926,6 +927,7 @@ libs: - test/cpp/util/byte_buffer_proto_helper.cc - test/cpp/util/cli_call.cc - test/cpp/util/create_test_channel.cc + - test/cpp/util/proto_file_parser.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc - test/cpp/util/test_credentials_provider.cc diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 99fad7f2fe9..98b9d930d60 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -86,7 +86,6 @@ Status CliCall::Call(std::shared_ptr channel, cq.Next(&got_tag, &ok); if (!ok) { std::cout << "Failed to read response." << std::endl; - return Status(StatusCode::INTERNAL, "Failed to read response"); } grpc::Status status; call->Finish(&status, tag(5)); @@ -103,6 +102,7 @@ Status CliCall::Call(std::shared_ptr channel, slices[i].size()); } } + *server_initial_metadata = ctx.GetServerInitialMetadata(); *server_trailing_metadata = ctx.GetServerTrailingMetadata(); return status; diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 68cf4114a8d..c52e48bae65 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -32,32 +32,33 @@ */ /* - A command line tool to talk to any grpc server. + A command line tool to talk to a grpc server. Example of talking to grpc interop server: - 1. Prepare request binary file: - a. create a text file input.txt, containing the following: - response_size: 10 - payload: { - body: "hello world" - } - b. under grpc/ run - protoc --proto_path=src/proto/grpc/testing/ \ - --encode=grpc.testing.SimpleRequest - src/proto/grpc/testing/messages.proto \ - < input.txt > input.bin - 2. Start a server - make interop_server && bins/opt/interop_server --port=50051 - 3. Run the tool - make grpc_cli && bins/opt/grpc_cli call localhost:50051 \ - /grpc.testing.TestService/UnaryCall --enable_ssl=false \ - --input_binary_file=input.bin --output_binary_file=output.bin - 4. Decode response - protoc --proto_path=src/proto/grpc/testing/ \ - --decode=grpc.testing.SimpleResponse src/proto/grpc/testing/messages.proto \ - < output.bin > output.txt - 5. Now the text form of response should be in output.txt - Optionally, metadata can be passed to server via flag --metadata, e.g. - --metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2" + grpc_cli call localhost:50051 UnaryCall src/proto/grpc/testing/test.proto \ + "response_size:10" --enable_ssl=false + + Options: + 1. --proto_path, if your proto file is not under current working directory, + use this flag to provide a search root. It should work similar to the + counterpart in protoc. + 2. --metadata specifies metadata to be sent to the server, such as: + --metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2" + 3. --enable_ssl, whether to use tls. + 4. --use_auth, if set to true, attach a GoogleDefaultCredentials to the call + 3. --input_binary_file, a file containing the serialized request. The file + can be generated by calling something like: + protoc --proto_path=src/proto/grpc/testing/ \ + --encode=grpc.testing.SimpleRequest \ + src/proto/grpc/testing/messages.proto \ + < input.txt > input.bin + If this is used and no proto file is provided in the argument list, the + method string has to be exact in the form of /package.service/method. + 4. --output_binary_file, a file to write binary format response into, it can + be later decoded using protoc: + protoc --proto_path=src/proto/grpc/testing/ \ + --decode=grpc.testing.SimpleResponse \ + src/proto/grpc/testing/messages.proto \ + < output.bin > output.txt */ #include @@ -72,6 +73,7 @@ #include #include "test/cpp/util/cli_call.h" +#include "test/cpp/util/proto_file_parser.h" #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_config.h" @@ -79,10 +81,11 @@ DEFINE_bool(enable_ssl, true, "Whether to use ssl/tls."); DEFINE_bool(use_auth, false, "Whether to create default google credentials."); DEFINE_string(input_binary_file, "", "Path to input file containing serialized request."); -DEFINE_string(output_binary_file, "output.bin", +DEFINE_string(output_binary_file, "", "Path to output file to write serialized response."); DEFINE_string(metadata, "", "Metadata to send to server, in the form of key1:val1:key2:val2"); +DEFINE_string(proto_path, ".", "Path to look for the proto file."); void ParseMetadataFlag( std::multimap* client_metadata) { @@ -126,28 +129,51 @@ void PrintMetadata(const T& m, const grpc::string& message) { int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); - if (argc < 4 || grpc::string(argv[1]) != "call") { - std::cout << "Usage: grpc_cli call server_host:port full_method_string\n" - << "Example: grpc_cli call service.googleapis.com " - << "/grpc.testing.TestService/UnaryCall " - << "--input_binary_file=input.bin --output_binary_file=output.bin" - << std::endl; + if (argc < 4 || argc == 5 || grpc::string(argv[1]) != "call") { + std::cout << "Usage: grpc_cli call server_host:port method_name " + << "[proto file] [text format request] []" << std::endl; } + + grpc::string file_name; + grpc::string request_text; grpc::string server_address(argv[2]); - // TODO(yangg) basic check of method string - grpc::string method(argv[3]); + grpc::string method_name(argv[3]); + std::unique_ptr parser; + grpc::string serialized_request_proto; - if (FLAGS_input_binary_file.empty()) { - std::cout << "Missing --input_binary_file for serialized request." - << std::endl; + if (argc == 6) { + file_name = argv[4]; + // TODO(yangg) read from stdin as well? + request_text = argv[5]; + } + + if (request_text.empty() && FLAGS_input_binary_file.empty()) { + std::cout << "Missing input. Use text format input or " + << "--input_binary_file for serialized request" << std::endl; return 1; + } else if (!request_text.empty()) { + parser.reset(new grpc::testing::ProtoFileParser(FLAGS_proto_path, file_name, + method_name)); + method_name = parser->GetFullMethodName(); + if (parser->HasError()) { + return 1; + } } - std::cout << "connecting to " << server_address << std::endl; - std::ifstream input_file(FLAGS_input_binary_file, - std::ios::in | std::ios::binary); - std::stringstream input_stream; - input_stream << input_file.rdbuf(); + if (parser) { + serialized_request_proto = + parser->GetSerializedProto(request_text, true /* is_request */); + if (parser->HasError()) { + return 1; + } + } else if (!FLAGS_input_binary_file.empty()) { + std::ifstream input_file(FLAGS_input_binary_file, + std::ios::in | std::ios::binary); + std::stringstream input_stream; + input_stream << input_file.rdbuf(); + serialized_request_proto = input_stream.str(); + } + std::cout << "connecting to " << server_address << std::endl; std::shared_ptr creds; if (!FLAGS_enable_ssl) { @@ -162,25 +188,34 @@ int main(int argc, char** argv) { std::shared_ptr channel = grpc::CreateChannel(server_address, creds); - grpc::string response; + grpc::string serialized_response_proto; std::multimap client_metadata; std::multimap server_initial_metadata, server_trailing_metadata; ParseMetadataFlag(&client_metadata); PrintMetadata(client_metadata, "Sending client initial metadata:"); grpc::Status s = grpc::testing::CliCall::Call( - channel, method, input_stream.str(), &response, client_metadata, - &server_initial_metadata, &server_trailing_metadata); + channel, method_name, serialized_request_proto, + &serialized_response_proto, client_metadata, &server_initial_metadata, + &server_trailing_metadata); PrintMetadata(server_initial_metadata, "Received initial metadata from server:"); PrintMetadata(server_trailing_metadata, "Received trailing metadata from server:"); if (s.ok()) { std::cout << "Rpc succeeded with OK status" << std::endl; - if (!response.empty()) { + if (parser) { + grpc::string response_text = parser->GetTextFormat( + serialized_response_proto, false /* is_request */); + if (parser->HasError()) { + return 1; + } + std::cout << "Response: \n " << response_text << std::endl; + } + if (!FLAGS_output_binary_file.empty()) { std::ofstream output_file(FLAGS_output_binary_file, std::ios::trunc | std::ios::binary); - output_file << response; + output_file << serialized_response_proto; } } else { std::cout << "Rpc failed with status code " << s.error_code() diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc new file mode 100644 index 00000000000..6557b95f585 --- /dev/null +++ b/test/cpp/util/proto_file_parser.cc @@ -0,0 +1,177 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/cpp/util/proto_file_parser.h" + +#include +#include +#include + +#include + +namespace grpc { +namespace testing { +namespace { + +// Match the user input method string to the full_name from method descriptor. +bool MethodNameMatch(const grpc::string& full_name, const grpc::string& input) { + grpc::string clean_input = input; + std::replace(clean_input.begin(), clean_input.end(), '/', '.'); + if (clean_input.size() > full_name.size()) { + return false; + } + return full_name.compare(full_name.size() - clean_input.size(), + clean_input.size(), clean_input) == 0; +} +} // namespace + +class ErrorPrinter + : public google::protobuf::compiler::MultiFileErrorCollector { + public: + explicit ErrorPrinter(ProtoFileParser* parser) : parser_(parser) {} + + void AddError(const grpc::string& filename, int line, int column, + const grpc::string& message) GRPC_OVERRIDE { + std::ostringstream oss; + oss << "error " << filename << " " << line << " " << column << " " + << message << "\n"; + parser_->LogError(oss.str()); + } + + void AddWarning(const grpc::string& filename, int line, int column, + const grpc::string& message) GRPC_OVERRIDE { + std::cout << "warning " << filename << " " << line << " " << column << " " + << message << std::endl; + } + + private: + ProtoFileParser* parser_; // not owned +}; + +ProtoFileParser::ProtoFileParser(const grpc::string& proto_path, + const grpc::string& file_name, + const grpc::string& method) + : has_error_(false) { + source_tree_.MapPath("", proto_path); + error_printer_.reset(new ErrorPrinter(this)); + importer_.reset(new google::protobuf::compiler::Importer( + &source_tree_, error_printer_.get())); + const auto* file_desc = importer_->Import(file_name); + if (!file_desc) { + LogError(""); + return; + } + dynamic_factory_.reset( + new google::protobuf::DynamicMessageFactory(importer_->pool())); + + const google::protobuf::MethodDescriptor* method_descriptor = nullptr; + for (int i = 0; !method_descriptor && i < file_desc->service_count(); i++) { + const auto* service_desc = file_desc->service(i); + for (int j = 0; j < service_desc->method_count(); j++) { + const auto* method_desc = service_desc->method(j); + if (MethodNameMatch(method_desc->full_name(), method)) { + if (method_descriptor) { + std::ostringstream error_stream("Ambiguous method names: "); + error_stream << method_descriptor->full_name() << " "; + error_stream << method_desc->full_name(); + LogError(error_stream.str()); + } + method_descriptor = method_desc; + } + } + } + if (!method_descriptor) { + LogError("Method name not found"); + } + if (has_error_) { + return; + } + full_method_name_ = method_descriptor->full_name(); + size_t last_dot = full_method_name_.find_last_of('.'); + if (last_dot != grpc::string::npos) { + full_method_name_[last_dot] = '/'; + } + full_method_name_.insert(full_method_name_.begin(), '/'); + + request_prototype_.reset( + dynamic_factory_->GetPrototype(method_descriptor->input_type())->New()); + response_prototype_.reset( + dynamic_factory_->GetPrototype(method_descriptor->output_type())->New()); +} + +ProtoFileParser::~ProtoFileParser() {} + +grpc::string ProtoFileParser::GetSerializedProto( + const grpc::string& text_format_proto, bool is_request) { + grpc::string serialized; + grpc::protobuf::Message* msg = + is_request ? request_prototype_.get() : response_prototype_.get(); + bool ok = + google::protobuf::TextFormat::ParseFromString(text_format_proto, msg); + if (!ok) { + LogError("Failed to parse text format to proto."); + return ""; + } + ok = request_prototype_->SerializeToString(&serialized); + if (!ok) { + LogError("Failed to serialize proto."); + return ""; + } + return serialized; +} + +grpc::string ProtoFileParser::GetTextFormat( + const grpc::string& serialized_proto, bool is_request) { + grpc::protobuf::Message* msg = + is_request ? request_prototype_.get() : response_prototype_.get(); + if (!msg->ParseFromString(serialized_proto)) { + LogError("Failed to deserialize proto."); + return ""; + } + grpc::string text_format; + if (!google::protobuf::TextFormat::PrintToString(*msg, &text_format)) { + LogError("Failed to print proto message to text format"); + return ""; + } + return text_format; +} + +void ProtoFileParser::LogError(const grpc::string& error_msg) { + if (!error_msg.empty()) { + std::cout << error_msg << std::endl; + } + has_error_ = true; +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h new file mode 100644 index 00000000000..a25285b3224 --- /dev/null +++ b/test/cpp/util/proto_file_parser.h @@ -0,0 +1,86 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_TEST_CPP_UTIL_PROTO_FILE_PARSER_H +#define GRPC_TEST_CPP_UTIL_PROTO_FILE_PARSER_H + +#include + +#include +#include + +#include "src/compiler/config.h" + +namespace grpc { +namespace testing { +class ErrorPrinter; + +// Find method and associated request/response types. +class ProtoFileParser { + public: + // The given proto file_name will be searched in a source tree rooted from + // proto_path. The method could be a partial string such as Service.Method or + // even just Method. It will log an error if there is ambiguity. + ProtoFileParser(const grpc::string& proto_path, const grpc::string& file_name, + const grpc::string& method); + ~ProtoFileParser(); + + grpc::string GetFullMethodName() const { return full_method_name_; } + + grpc::string GetSerializedProto(const grpc::string& text_format_proto, + bool is_request); + + grpc::string GetTextFormat(const grpc::string& serialized_proto, + bool is_request); + + bool HasError() const { return has_error_; } + + void LogError(const grpc::string& error_msg); + + private: + bool has_error_; + const grpc::protobuf::MethodDescriptor* method_descriptor_; + grpc::string request_text_; + grpc::string full_method_name_; + google::protobuf::compiler::DiskSourceTree source_tree_; + std::unique_ptr error_printer_; + std::unique_ptr importer_; + std::unique_ptr dynamic_factory_; + std::unique_ptr request_prototype_; + std::unique_ptr response_prototype_; +}; + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_UTIL_PROTO_FILE_PARSER_H diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 3866ebb0e55..c8502907a8e 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -4377,6 +4377,7 @@ "test/cpp/util/byte_buffer_proto_helper.h", "test/cpp/util/cli_call.h", "test/cpp/util/create_test_channel.h", + "test/cpp/util/proto_file_parser.h", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.h", "test/cpp/util/test_credentials_provider.h" @@ -4392,6 +4393,8 @@ "test/cpp/util/cli_call.h", "test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.h", + "test/cpp/util/proto_file_parser.cc", + "test/cpp/util/proto_file_parser.h", "test/cpp/util/string_ref_helper.cc", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.cc", diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index 33860af620b..a04969a854b 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -151,6 +151,7 @@ + @@ -188,6 +189,8 @@ + + diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index b35ba1fd91c..a53ed91c461 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -22,6 +22,9 @@ test\cpp\util + + test\cpp\util + test\cpp\util @@ -45,6 +48,9 @@ test\cpp\util + + test\cpp\util + test\cpp\util From abdec2d8338ff8ed3f79b400f82cb5774c07e159 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 19 May 2016 10:11:24 -0700 Subject: [PATCH 2/3] Separate the grpc_cli targets into a separate library --- Makefile | 68 +++++-- build.yaml | 18 +- tools/run_tests/sources_and_headers.json | 28 ++- .../grpc++_test_util/grpc++_test_util.vcxproj | 6 - .../grpc++_test_util.vcxproj.filters | 12 -- .../grpc_cli_libs/grpc_cli_libs.vcxproj | 176 ++++++++++++++++++ .../grpc_cli_libs.vcxproj.filters | 32 ++++ .../test/cli_call_test/cli_call_test.vcxproj | 3 + .../vcxproj/test/grpc_cli/grpc_cli.vcxproj | 3 + 9 files changed, 307 insertions(+), 39 deletions(-) create mode 100644 vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj create mode 100644 vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj.filters diff --git a/Makefile b/Makefile index e4ddc112c73..c21c0239c97 100644 --- a/Makefile +++ b/Makefile @@ -1211,7 +1211,7 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a ifeq ($(HAS_ZOOKEEPER),true) privatelibs_zookeeper: @@ -3424,9 +3424,7 @@ LIBGRPC++_TEST_UTIL_SRC = \ $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc \ test/cpp/end2end/test_service_impl.cc \ test/cpp/util/byte_buffer_proto_helper.cc \ - test/cpp/util/cli_call.cc \ test/cpp/util/create_test_channel.cc \ - test/cpp/util/proto_file_parser.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ test/cpp/util/test_credentials_provider.cc \ @@ -3477,9 +3475,7 @@ endif endif $(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/proto_file_parser.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc @@ -3663,6 +3659,56 @@ ifneq ($(NO_DEPS),true) endif +LIBGRPC_CLI_LIBS_SRC = \ + test/cpp/util/cli_call.cc \ + test/cpp/util/proto_file_parser.cc \ + +PUBLIC_HEADERS_CXX += \ + +LIBGRPC_CLI_LIBS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_CLI_LIBS_SRC)))) + + +ifeq ($(NO_SECURE),true) + +# You can't build secure libraries if you don't have OpenSSL. + +$(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a: openssl_dep_error + + +else + +ifeq ($(NO_PROTOBUF),true) + +# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. + +$(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a: protobuf_dep_error + + +else + +$(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC_CLI_LIBS_OBJS) + $(E) "[AR] Creating $@" + $(Q) mkdir -p `dirname $@` + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a + $(Q) $(AR) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBGRPC_CLI_LIBS_OBJS) +ifeq ($(SYSTEM),Darwin) + $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a +endif + + + + +endif + +endif + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LIBGRPC_CLI_LIBS_OBJS:.o=.dep) +endif +endif + + LIBGRPC_PLUGIN_SUPPORT_SRC = \ src/compiler/cpp_generator.cc \ src/compiler/csharp_generator.cc \ @@ -9914,16 +9960,16 @@ $(BINDIR)/$(CONFIG)/cli_call_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/cli_call_test: $(PROTOBUF_DEP) $(CLI_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/cli_call_test: $(PROTOBUF_DEP) $(CLI_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CLI_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/cli_call_test + $(Q) $(LDXX) $(LDFLAGS) $(CLI_CALL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/cli_call_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_cli_call_test: $(CLI_CALL_TEST_OBJS:.o=.dep) @@ -10566,16 +10612,16 @@ $(BINDIR)/$(CONFIG)/grpc_cli: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/grpc_cli: $(PROTOBUF_DEP) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/grpc_cli: $(PROTOBUF_DEP) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_cli + $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CLI_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_cli endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_cli.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/util/grpc_cli.o: $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_grpc_cli: $(GRPC_CLI_OBJS:.o=.dep) diff --git a/build.yaml b/build.yaml index e89399ffa26..839f6e88aef 100644 --- a/build.yaml +++ b/build.yaml @@ -913,9 +913,7 @@ libs: headers: - test/cpp/end2end/test_service_impl.h - test/cpp/util/byte_buffer_proto_helper.h - - test/cpp/util/cli_call.h - test/cpp/util/create_test_channel.h - - test/cpp/util/proto_file_parser.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h @@ -925,9 +923,7 @@ libs: - src/proto/grpc/testing/duplicate/echo_duplicate.proto - test/cpp/end2end/test_service_impl.cc - test/cpp/util/byte_buffer_proto_helper.cc - - test/cpp/util/cli_call.cc - test/cpp/util/create_test_channel.cc - - test/cpp/util/proto_file_parser.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc - test/cpp/util/test_credentials_provider.cc @@ -949,6 +945,18 @@ libs: - grpc++_codegen secure: false vs_project_guid: '{6EE56155-DF7C-4F6E-BFC4-F6F776BEB211}' +- name: grpc_cli_libs + build: private + language: c++ + headers: + - test/cpp/util/cli_call.h + - test/cpp/util/proto_file_parser.h + src: + - test/cpp/util/cli_call.cc + - test/cpp/util/proto_file_parser.cc + deps: + - grpc++ + - grpc_plugin_support - name: grpc_plugin_support build: protoc language: c++ @@ -2405,6 +2413,7 @@ targets: src: - test/cpp/util/cli_call_test.cc deps: + - grpc_cli_libs - grpc++_test_util - grpc_test_util - grpc++ @@ -2590,6 +2599,7 @@ targets: src: - test/cpp/util/grpc_cli.cc deps: + - grpc_cli_libs - grpc++_test_util - grpc_test_util - grpc++ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index c8502907a8e..01fab247d46 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -1889,6 +1889,7 @@ "grpc", "grpc++", "grpc++_test_util", + "grpc_cli_libs", "grpc_test_util" ], "headers": [], @@ -2151,6 +2152,7 @@ "grpc++", "grpc++_test_config", "grpc++_test_util", + "grpc_cli_libs", "grpc_test_util" ], "headers": [], @@ -4375,9 +4377,7 @@ "src/proto/grpc/testing/echo_messages.pb.h", "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/cli_call.h", "test/cpp/util/create_test_channel.h", - "test/cpp/util/proto_file_parser.h", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.h", "test/cpp/util/test_credentials_provider.h" @@ -4389,12 +4389,8 @@ "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.cc", "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/cli_call.cc", - "test/cpp/util/cli_call.h", "test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.h", - "test/cpp/util/proto_file_parser.cc", - "test/cpp/util/proto_file_parser.h", "test/cpp/util/string_ref_helper.cc", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.cc", @@ -4422,6 +4418,26 @@ "third_party": false, "type": "lib" }, + { + "deps": [ + "grpc++", + "grpc_plugin_support" + ], + "headers": [ + "test/cpp/util/cli_call.h", + "test/cpp/util/proto_file_parser.h" + ], + "language": "c++", + "name": "grpc_cli_libs", + "src": [ + "test/cpp/util/cli_call.cc", + "test/cpp/util/cli_call.h", + "test/cpp/util/proto_file_parser.cc", + "test/cpp/util/proto_file_parser.h" + ], + "third_party": false, + "type": "lib" + }, { "deps": [ "grpc++_config" diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index a04969a854b..68f28b1ac7f 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -149,9 +149,7 @@ - - @@ -185,12 +183,8 @@ - - - - diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index a53ed91c461..88bfb472ddc 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -16,15 +16,9 @@ test\cpp\util - - test\cpp\util - test\cpp\util - - test\cpp\util - test\cpp\util @@ -42,15 +36,9 @@ test\cpp\util - - test\cpp\util - test\cpp\util - - test\cpp\util - test\cpp\util diff --git a/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj b/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj new file mode 100644 index 00000000000..39cb1e0cb58 --- /dev/null +++ b/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {86E35862-43E8-F59E-F906-AFE0348AD3D2} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + grpc_cli_libs + + + grpc_cli_libs + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Windows + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Windows + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Windows + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Windows + true + false + true + true + + + + + + + + + + + + + + + + {C187A093-A0FE-489D-A40A-6E33DE0F9FEB} + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + diff --git a/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj.filters b/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj.filters new file mode 100644 index 00000000000..55ef18bf306 --- /dev/null +++ b/vsprojects/vcxproj/grpc_cli_libs/grpc_cli_libs.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + test\cpp\util + + + test\cpp\util + + + + + test\cpp\util + + + test\cpp\util + + + + + + {16a32a9f-93aa-5812-5a5e-be659aaa76aa} + + + {a6049b9f-9c4c-f814-ac67-dbd2b628b2d0} + + + {30f91d14-0a6a-c8e8-ff23-6a83142d42fd} + + + + diff --git a/vsprojects/vcxproj/test/cli_call_test/cli_call_test.vcxproj b/vsprojects/vcxproj/test/cli_call_test/cli_call_test.vcxproj index b5d2fc6d0c7..40fe5598b69 100644 --- a/vsprojects/vcxproj/test/cli_call_test/cli_call_test.vcxproj +++ b/vsprojects/vcxproj/test/cli_call_test/cli_call_test.vcxproj @@ -164,6 +164,9 @@ + + {86E35862-43E8-F59E-F906-AFE0348AD3D2} + {0BE77741-552A-929B-A497-4EF7ECE17A64} diff --git a/vsprojects/vcxproj/test/grpc_cli/grpc_cli.vcxproj b/vsprojects/vcxproj/test/grpc_cli/grpc_cli.vcxproj index eeb0e8cfa71..cd844d15794 100644 --- a/vsprojects/vcxproj/test/grpc_cli/grpc_cli.vcxproj +++ b/vsprojects/vcxproj/test/grpc_cli/grpc_cli.vcxproj @@ -164,6 +164,9 @@ + + {86E35862-43E8-F59E-F906-AFE0348AD3D2} + {0BE77741-552A-929B-A497-4EF7ECE17A64} From fe3e8b731361665658e911e9569116fdf6371037 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 19 May 2016 15:30:05 -0700 Subject: [PATCH 3/3] remote unused member --- test/cpp/util/proto_file_parser.h | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h index a25285b3224..46cdd665038 100644 --- a/test/cpp/util/proto_file_parser.h +++ b/test/cpp/util/proto_file_parser.h @@ -69,7 +69,6 @@ class ProtoFileParser { private: bool has_error_; - const grpc::protobuf::MethodDescriptor* method_descriptor_; grpc::string request_text_; grpc::string full_method_name_; google::protobuf::compiler::DiskSourceTree source_tree_;