Source release 16.4.0

This commit is contained in:
John W. Bruce
2020-10-09 16:08:56 -07:00
parent 160df9f57a
commit 9d17a531ee
562 changed files with 52913 additions and 37426 deletions

View File

@@ -32,13 +32,14 @@
#include <stdarg.h>
#include <unistd.h>
#include "conformance.pb.h"
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
#include "conformance.pb.h"
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/stubs/status.h>
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
@@ -51,41 +52,13 @@ using google::protobuf::util::BinaryToJsonString;
using google::protobuf::util::JsonParseOptions;
using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::Status;
using google::protobuf::util::TypeResolver;
using protobuf_test_messages::proto2::TestAllTypesProto2;
using protobuf_test_messages::proto3::TestAllTypesProto3;
using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
const char* kFailures[] = {
#if !GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
"Required.Proto2.ProtobufInput."
"PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput."
"PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
"Required.Proto3.ProtobufInput."
"PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput."
"PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
#endif
};
static string GetTypeUrl(const Descriptor* message) {
@@ -97,6 +70,10 @@ bool verbose = false;
TypeResolver* type_resolver;
string* type_url;
namespace google {
namespace protobuf {
using util::Status;
bool CheckedRead(int fd, void *buf, size_t len) {
size_t ofs = 0;
@@ -106,7 +83,7 @@ bool CheckedRead(int fd, void *buf, size_t len) {
if (bytes_read == 0) return false;
if (bytes_read < 0) {
GOOGLE_LOG(FATAL) << "Error reading from test runner: " << strerror(errno);
GOOGLE_LOG(FATAL) << "Error reading from test runner: " << strerror(errno);
}
len -= bytes_read;
@@ -153,7 +130,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
options);
if (!status.ok()) {
response->set_parse_error(string("Parse error: ") +
status.error_message().as_string());
std::string(status.error_message()));
return;
}
@@ -178,8 +155,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
break;
default:
GOOGLE_LOG(FATAL) << "unknown payload type: "
<< request.payload_case();
GOOGLE_LOG(FATAL) << "unknown payload type: " << request.payload_case();
break;
}
@@ -195,7 +171,8 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
break;
case conformance::PROTOBUF: {
GOOGLE_CHECK(test_message->SerializeToString(response->mutable_protobuf_payload()));
GOOGLE_CHECK(test_message->SerializeToString(
response->mutable_protobuf_payload()));
break;
}
@@ -207,7 +184,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
if (!status.ok()) {
response->set_serialize_error(
string("Failed to serialize JSON output: ") +
status.error_message().as_string());
std::string(status.error_message()));
return;
}
break;
@@ -217,13 +194,13 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
TextFormat::Printer printer;
printer.SetHideUnknownFields(!request.print_unknown_fields());
GOOGLE_CHECK(printer.PrintToString(*test_message,
response->mutable_text_payload()));
response->mutable_text_payload()));
break;
}
default:
GOOGLE_LOG(FATAL) << "Unknown output format: "
<< request.requested_output_format();
<< request.requested_output_format();
}
}
@@ -269,12 +246,15 @@ bool DoTestIo() {
return true;
}
} // namespace protobuf
} // namespace google
int main() {
type_resolver = NewTypeResolverForDescriptorPool(
kTypeUrlPrefix, DescriptorPool::generated_pool());
type_url = new string(GetTypeUrl(TestAllTypesProto3::descriptor()));
while (1) {
if (!DoTestIo()) {
if (!google::protobuf::DoTestIo()) {
fprintf(stderr, "conformance-cpp: received EOF from test runner "
"after %d tests, exiting\n", test_count);
return 0;