Source release 15.2.0
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.AbstractMessage;
|
||||
import com.google.protobuf.Parser;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.CodedInputStream;
|
||||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2;
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.Parser;
|
||||
import com.google.protobuf.TextFormat;
|
||||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import com.google.protobuf.util.JsonFormat.TypeRegistry;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -56,7 +57,7 @@ class ConformanceJava {
|
||||
buf[3] = (byte)(val >> 24);
|
||||
writeToStdout(buf);
|
||||
}
|
||||
|
||||
|
||||
private enum BinaryDecoderType {
|
||||
BTYE_STRING_DECODER,
|
||||
BYTE_ARRAY_DECODER,
|
||||
@@ -68,11 +69,11 @@ class ConformanceJava {
|
||||
}
|
||||
|
||||
private static class BinaryDecoder <MessageType extends AbstractMessage> {
|
||||
public MessageType decode (ByteString bytes, BinaryDecoderType type,
|
||||
public MessageType decode (ByteString bytes, BinaryDecoderType type,
|
||||
Parser <MessageType> parser, ExtensionRegistry extensions)
|
||||
throws InvalidProtocolBufferException {
|
||||
switch (type) {
|
||||
case BTYE_STRING_DECODER:
|
||||
case BTYE_STRING_DECODER:
|
||||
return parser.parseFrom(bytes, extensions);
|
||||
case BYTE_ARRAY_DECODER:
|
||||
return parser.parseFrom(bytes.toByteArray(), extensions);
|
||||
@@ -93,7 +94,7 @@ class ConformanceJava {
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
case DIRECT_BYTE_BUFFER_DECODER: {
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
|
||||
bytes.copyTo(buffer);
|
||||
@@ -134,7 +135,7 @@ class ConformanceJava {
|
||||
ArrayList <MessageType> messages = new ArrayList <MessageType> ();
|
||||
ArrayList <InvalidProtocolBufferException> exceptions =
|
||||
new ArrayList <InvalidProtocolBufferException>();
|
||||
|
||||
|
||||
for (int i = 0; i < BinaryDecoderType.values().length; i++) {
|
||||
messages.add(null);
|
||||
exceptions.add(null);
|
||||
@@ -233,16 +234,48 @@ class ConformanceJava {
|
||||
}
|
||||
case JSON_PAYLOAD: {
|
||||
try {
|
||||
TestMessagesProto3.TestAllTypesProto3.Builder builder =
|
||||
TestMessagesProto3.TestAllTypesProto3.Builder builder =
|
||||
TestMessagesProto3.TestAllTypesProto3.newBuilder();
|
||||
JsonFormat.parser().usingTypeRegistry(typeRegistry)
|
||||
.merge(request.getJsonPayload(), builder);
|
||||
JsonFormat.Parser parser = JsonFormat.parser().usingTypeRegistry(typeRegistry);
|
||||
if (request.getTestCategory()
|
||||
== Conformance.TestCategory.JSON_IGNORE_UNKNOWN_PARSING_TEST) {
|
||||
parser = parser.ignoringUnknownFields();
|
||||
}
|
||||
parser.merge(request.getJsonPayload(), builder);
|
||||
testMessage = builder.build();
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TEXT_PAYLOAD: {
|
||||
if (isProto3) {
|
||||
try {
|
||||
TestMessagesProto3.TestAllTypesProto3.Builder builder =
|
||||
TestMessagesProto3.TestAllTypesProto3.newBuilder();
|
||||
TextFormat.merge(request.getTextPayload(), builder);
|
||||
testMessage = builder.build();
|
||||
} catch (TextFormat.ParseException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder()
|
||||
.setParseError(e.getMessage())
|
||||
.build();
|
||||
}
|
||||
} else if (isProto2) {
|
||||
try {
|
||||
TestMessagesProto2.TestAllTypesProto2.Builder builder =
|
||||
TestMessagesProto2.TestAllTypesProto2.newBuilder();
|
||||
TextFormat.merge(request.getTextPayload(), builder);
|
||||
testMessage = builder.build();
|
||||
} catch (TextFormat.ParseException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder()
|
||||
.setParseError(e.getMessage())
|
||||
.build();
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("Protobuf request doesn't have specific payload type.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PAYLOAD_NOT_SET: {
|
||||
throw new RuntimeException("Request didn't have payload.");
|
||||
}
|
||||
@@ -257,7 +290,7 @@ class ConformanceJava {
|
||||
throw new RuntimeException("Unspecified output format.");
|
||||
|
||||
case PROTOBUF: {
|
||||
ByteString MessageString = testMessage.toByteString();
|
||||
ByteString MessageString = testMessage.toByteString();
|
||||
return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(MessageString).build();
|
||||
}
|
||||
|
||||
@@ -270,6 +303,10 @@ class ConformanceJava {
|
||||
e.getMessage()).build();
|
||||
}
|
||||
|
||||
case TEXT_FORMAT:
|
||||
return Conformance.ConformanceResponse.newBuilder().setTextPayload(
|
||||
TextFormat.printToString(testMessage)).build();
|
||||
|
||||
default: {
|
||||
throw new RuntimeException("Unexpected request output.");
|
||||
}
|
||||
|
||||
25
third_party/protobuf/conformance/Makefile.am
vendored
25
third_party/protobuf/conformance/Makefile.am
vendored
@@ -107,6 +107,7 @@ other_language_protoc_outputs = \
|
||||
google/protobuf/wrappers_pb2.py \
|
||||
Conformance/ConformanceRequest.php \
|
||||
Conformance/ConformanceResponse.php \
|
||||
Conformance/FailureSet.php \
|
||||
Conformance/WireFormat.php \
|
||||
GPBMetadata/Conformance.php \
|
||||
GPBMetadata/Google/Protobuf/Any.php \
|
||||
@@ -206,6 +207,11 @@ EXTRA_DIST = \
|
||||
|
||||
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
|
||||
conformance_test_main.cc \
|
||||
binary_json_conformance_suite.h \
|
||||
binary_json_conformance_suite.cc \
|
||||
text_format_conformance_suite.h \
|
||||
text_format_conformance_suite.cc \
|
||||
conformance_test_runner.cc \
|
||||
third_party/jsoncpp/json.h \
|
||||
third_party/jsoncpp/jsoncpp.cpp
|
||||
@@ -310,7 +316,7 @@ conformance-java-lite: javac_middleman_lite
|
||||
conformance-csharp: $(other_language_protoc_outputs)
|
||||
@echo "Writing shortcut script conformance-csharp..."
|
||||
@echo '#! /bin/sh' > conformance-csharp
|
||||
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
|
||||
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp2.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
|
||||
@chmod +x conformance-csharp
|
||||
|
||||
conformance-php:
|
||||
@@ -330,30 +336,33 @@ test_cpp: protoc_middleman conformance-test-runner conformance-cpp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp
|
||||
|
||||
test_java: protoc_middleman conformance-test-runner conformance-java
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt ./conformance-java
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt --text_format_failure_list text_format_failure_list_java.txt ./conformance-java
|
||||
|
||||
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
|
||||
./conformance-test-runner --enforce_recommended ./conformance-java-lite
|
||||
|
||||
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt ./conformance-csharp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp
|
||||
|
||||
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt ./conformance_ruby.rb
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
|
||||
|
||||
test_ruby_mac: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby_mac.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
|
||||
|
||||
test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt ./conformance-php
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php
|
||||
|
||||
test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
|
||||
|
||||
test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt ./conformance-php-c
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
|
||||
|
||||
# These depend on library paths being properly set up. The easiest way to
|
||||
# run them is to just use "tox" from the python dir.
|
||||
test_python: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt ./conformance_python.py
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py
|
||||
|
||||
test_python_cpp: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py
|
||||
|
||||
74
third_party/protobuf/conformance/Makefile.in
vendored
74
third_party/protobuf/conformance/Makefile.in
vendored
@@ -142,6 +142,9 @@ conformance_objc_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
|
||||
$(OBJCFLAGS) $(conformance_objc_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am_conformance_test_runner_OBJECTS = \
|
||||
conformance_test_runner-conformance_test.$(OBJEXT) \
|
||||
conformance_test_runner-conformance_test_main.$(OBJEXT) \
|
||||
conformance_test_runner-binary_json_conformance_suite.$(OBJEXT) \
|
||||
conformance_test_runner-text_format_conformance_suite.$(OBJEXT) \
|
||||
conformance_test_runner-conformance_test_runner.$(OBJEXT) \
|
||||
third_party/jsoncpp/conformance_test_runner-jsoncpp.$(OBJEXT)
|
||||
nodist_conformance_test_runner_OBJECTS = \
|
||||
@@ -311,6 +314,7 @@ ISAINFO = @ISAINFO@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
|
||||
LIBATOMIC_LIBS = @LIBATOMIC_LIBS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
@@ -521,6 +525,7 @@ other_language_protoc_outputs = \
|
||||
google/protobuf/wrappers_pb2.py \
|
||||
Conformance/ConformanceRequest.php \
|
||||
Conformance/ConformanceResponse.php \
|
||||
Conformance/FailureSet.php \
|
||||
Conformance/WireFormat.php \
|
||||
GPBMetadata/Conformance.php \
|
||||
GPBMetadata/Google/Protobuf/Any.php \
|
||||
@@ -579,6 +584,11 @@ EXTRA_DIST = \
|
||||
|
||||
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
|
||||
conformance_test_main.cc \
|
||||
binary_json_conformance_suite.h \
|
||||
binary_json_conformance_suite.cc \
|
||||
text_format_conformance_suite.h \
|
||||
text_format_conformance_suite.cc \
|
||||
conformance_test_runner.cc \
|
||||
third_party/jsoncpp/json.h \
|
||||
third_party/jsoncpp/jsoncpp.cpp
|
||||
@@ -753,9 +763,12 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_cpp-conformance_cpp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_objc-Conformance.pbobjc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_objc-conformance_objc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance.pb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance_test.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance_test_main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance_test_runner.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/conformance_cpp-test_messages_proto2.pb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/conformance_cpp-test_messages_proto3.pb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/conformance_objc-TestMessagesProto2.pbobjc.Po@am__quote@
|
||||
@@ -858,6 +871,48 @@ conformance_test_runner-conformance_test.obj: conformance_test.cc
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test.obj `if test -f 'conformance_test.cc'; then $(CYGPATH_W) 'conformance_test.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test.cc'; fi`
|
||||
|
||||
conformance_test_runner-conformance_test_main.o: conformance_test_main.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test_main.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test_main.Tpo -c -o conformance_test_runner-conformance_test_main.o `test -f 'conformance_test_main.cc' || echo '$(srcdir)/'`conformance_test_main.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test_main.Tpo $(DEPDIR)/conformance_test_runner-conformance_test_main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='conformance_test_main.cc' object='conformance_test_runner-conformance_test_main.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test_main.o `test -f 'conformance_test_main.cc' || echo '$(srcdir)/'`conformance_test_main.cc
|
||||
|
||||
conformance_test_runner-conformance_test_main.obj: conformance_test_main.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test_main.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test_main.Tpo -c -o conformance_test_runner-conformance_test_main.obj `if test -f 'conformance_test_main.cc'; then $(CYGPATH_W) 'conformance_test_main.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test_main.cc'; fi`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test_main.Tpo $(DEPDIR)/conformance_test_runner-conformance_test_main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='conformance_test_main.cc' object='conformance_test_runner-conformance_test_main.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test_main.obj `if test -f 'conformance_test_main.cc'; then $(CYGPATH_W) 'conformance_test_main.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test_main.cc'; fi`
|
||||
|
||||
conformance_test_runner-binary_json_conformance_suite.o: binary_json_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-binary_json_conformance_suite.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Tpo -c -o conformance_test_runner-binary_json_conformance_suite.o `test -f 'binary_json_conformance_suite.cc' || echo '$(srcdir)/'`binary_json_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Tpo $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='binary_json_conformance_suite.cc' object='conformance_test_runner-binary_json_conformance_suite.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-binary_json_conformance_suite.o `test -f 'binary_json_conformance_suite.cc' || echo '$(srcdir)/'`binary_json_conformance_suite.cc
|
||||
|
||||
conformance_test_runner-binary_json_conformance_suite.obj: binary_json_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-binary_json_conformance_suite.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Tpo -c -o conformance_test_runner-binary_json_conformance_suite.obj `if test -f 'binary_json_conformance_suite.cc'; then $(CYGPATH_W) 'binary_json_conformance_suite.cc'; else $(CYGPATH_W) '$(srcdir)/binary_json_conformance_suite.cc'; fi`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Tpo $(DEPDIR)/conformance_test_runner-binary_json_conformance_suite.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='binary_json_conformance_suite.cc' object='conformance_test_runner-binary_json_conformance_suite.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-binary_json_conformance_suite.obj `if test -f 'binary_json_conformance_suite.cc'; then $(CYGPATH_W) 'binary_json_conformance_suite.cc'; else $(CYGPATH_W) '$(srcdir)/binary_json_conformance_suite.cc'; fi`
|
||||
|
||||
conformance_test_runner-text_format_conformance_suite.o: text_format_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-text_format_conformance_suite.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Tpo -c -o conformance_test_runner-text_format_conformance_suite.o `test -f 'text_format_conformance_suite.cc' || echo '$(srcdir)/'`text_format_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Tpo $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='text_format_conformance_suite.cc' object='conformance_test_runner-text_format_conformance_suite.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-text_format_conformance_suite.o `test -f 'text_format_conformance_suite.cc' || echo '$(srcdir)/'`text_format_conformance_suite.cc
|
||||
|
||||
conformance_test_runner-text_format_conformance_suite.obj: text_format_conformance_suite.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-text_format_conformance_suite.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Tpo -c -o conformance_test_runner-text_format_conformance_suite.obj `if test -f 'text_format_conformance_suite.cc'; then $(CYGPATH_W) 'text_format_conformance_suite.cc'; else $(CYGPATH_W) '$(srcdir)/text_format_conformance_suite.cc'; fi`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Tpo $(DEPDIR)/conformance_test_runner-text_format_conformance_suite.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='text_format_conformance_suite.cc' object='conformance_test_runner-text_format_conformance_suite.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-text_format_conformance_suite.obj `if test -f 'text_format_conformance_suite.cc'; then $(CYGPATH_W) 'text_format_conformance_suite.cc'; else $(CYGPATH_W) '$(srcdir)/text_format_conformance_suite.cc'; fi`
|
||||
|
||||
conformance_test_runner-conformance_test_runner.o: conformance_test_runner.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test_runner.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo -c -o conformance_test_runner-conformance_test_runner.o `test -f 'conformance_test_runner.cc' || echo '$(srcdir)/'`conformance_test_runner.cc
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo $(DEPDIR)/conformance_test_runner-conformance_test_runner.Po
|
||||
@@ -1371,7 +1426,7 @@ conformance-java-lite: javac_middleman_lite
|
||||
conformance-csharp: $(other_language_protoc_outputs)
|
||||
@echo "Writing shortcut script conformance-csharp..."
|
||||
@echo '#! /bin/sh' > conformance-csharp
|
||||
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
|
||||
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp2.1/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
|
||||
@chmod +x conformance-csharp
|
||||
|
||||
conformance-php:
|
||||
@@ -1391,30 +1446,33 @@ test_cpp: protoc_middleman conformance-test-runner conformance-cpp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp
|
||||
|
||||
test_java: protoc_middleman conformance-test-runner conformance-java
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt ./conformance-java
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt --text_format_failure_list text_format_failure_list_java.txt ./conformance-java
|
||||
|
||||
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
|
||||
./conformance-test-runner --enforce_recommended ./conformance-java-lite
|
||||
|
||||
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt ./conformance-csharp
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp
|
||||
|
||||
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt ./conformance_ruby.rb
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
|
||||
|
||||
test_ruby_mac: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby_mac.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
|
||||
|
||||
test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt ./conformance-php
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php
|
||||
|
||||
test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
|
||||
|
||||
test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt ./conformance-php-c
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
|
||||
|
||||
# These depend on library paths being properly set up. The easiest way to
|
||||
# run them is to just use "tox" from the python dir.
|
||||
test_python: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt ./conformance_python.py
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py
|
||||
|
||||
test_python_cpp: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py
|
||||
|
||||
6
third_party/protobuf/conformance/README.md
vendored
6
third_party/protobuf/conformance/README.md
vendored
@@ -1,8 +1,6 @@
|
||||
Protocol Buffers - Google's data interchange format
|
||||
===================================================
|
||||
|
||||
[](https://travis-ci.org/google/protobuf)
|
||||
|
||||
Copyright 2008 Google Inc.
|
||||
|
||||
This directory contains conformance tests for testing completeness and
|
||||
@@ -59,10 +57,10 @@ Testing other Protocol Buffer implementations
|
||||
To run these tests against a new Protocol Buffers implementation, write a
|
||||
program in your language that uses the protobuf implementation you want
|
||||
to test. This program should implement the testing protocol defined in
|
||||
[conformance.proto](https://github.com/google/protobuf/blob/master/conformance/conformance.proto).
|
||||
[conformance.proto](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance.proto).
|
||||
This is designed to be as easy as possible: the C++ version is only
|
||||
150 lines and is a good example for what this program should look like
|
||||
(see [conformance_cpp.cc](https://github.com/google/protobuf/blob/master/conformance/conformance_cpp.cc)).
|
||||
(see [conformance_cpp.cc](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance_cpp.cc)).
|
||||
The program only needs to be able to read from stdin and write to stdout.
|
||||
|
||||
Portability
|
||||
|
||||
2458
third_party/protobuf/conformance/binary_json_conformance_suite.cc
vendored
Normal file
2458
third_party/protobuf/conformance/binary_json_conformance_suite.cc
vendored
Normal file
File diff suppressed because it is too large
Load Diff
121
third_party/protobuf/conformance/binary_json_conformance_suite.h
vendored
Normal file
121
third_party/protobuf/conformance/binary_json_conformance_suite.h
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// 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 CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
|
||||
#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
|
||||
|
||||
#include "conformance_test.h"
|
||||
#include "third_party/jsoncpp/json.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {
|
||||
public:
|
||||
BinaryAndJsonConformanceSuite() {}
|
||||
|
||||
private:
|
||||
void RunSuiteImpl();
|
||||
void RunValidJsonTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidJsonTestWithProtobufInput(
|
||||
const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const protobuf_test_messages::proto3::TestAllTypesProto3& input,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidJsonIgnoreUnknownTest(
|
||||
const string& test_name, ConformanceLevel level, const string& input_json,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
|
||||
const string& input_protobuf,
|
||||
const string& equivalent_text_format,
|
||||
bool is_proto3);
|
||||
void RunValidBinaryProtobufTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_protobuf,
|
||||
bool is_proto3);
|
||||
void RunValidProtobufTestWithMessage(
|
||||
const string& test_name, ConformanceLevel level,
|
||||
const Message *input,
|
||||
const string& equivalent_text_format,
|
||||
bool is_proto3);
|
||||
|
||||
bool ParseJsonResponse(
|
||||
const conformance::ConformanceResponse& response,
|
||||
Message* test_message);
|
||||
bool ParseResponse(
|
||||
const conformance::ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting,
|
||||
Message* test_message) override;
|
||||
|
||||
typedef std::function<bool(const Json::Value&)> Validator;
|
||||
void RunValidJsonTestWithValidator(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json,
|
||||
const Validator& validator);
|
||||
void ExpectParseFailureForJson(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json);
|
||||
void ExpectSerializeFailureForJson(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& text_format);
|
||||
void ExpectParseFailureForProtoWithProtoVersion (const string& proto,
|
||||
const string& test_name,
|
||||
ConformanceLevel level,
|
||||
bool is_proto3);
|
||||
void ExpectParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name,
|
||||
ConformanceLevel level);
|
||||
void ExpectHardParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name,
|
||||
ConformanceLevel level);
|
||||
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
|
||||
void TestIllegalTags();
|
||||
template <class MessageType>
|
||||
void TestOneofMessage (MessageType &message,
|
||||
bool is_proto3);
|
||||
template <class MessageType>
|
||||
void TestUnknownMessage (MessageType &message,
|
||||
bool is_proto3);
|
||||
void TestValidDataForType(
|
||||
google::protobuf::FieldDescriptor::Type,
|
||||
std::vector<std::pair<std::string, std::string>> values);
|
||||
|
||||
std::unique_ptr<google::protobuf::util::TypeResolver>
|
||||
type_resolver_;
|
||||
std::string type_url_;
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
|
||||
@@ -55,6 +55,32 @@ enum WireFormat {
|
||||
UNSPECIFIED = 0;
|
||||
PROTOBUF = 1;
|
||||
JSON = 2;
|
||||
JSPB = 3; // Google internal only. Opensource testees just skip it.
|
||||
TEXT_FORMAT = 4;
|
||||
}
|
||||
|
||||
enum TestCategory {
|
||||
UNSPECIFIED_TEST = 0;
|
||||
BINARY_TEST = 1; // Test binary wire format.
|
||||
JSON_TEST = 2; // Test json wire format.
|
||||
// Similar to JSON_TEST. However, during parsing json, testee should ignore
|
||||
// unknown fields. This feature is optional. Each implementation can descide
|
||||
// whether to support it. See
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#json_options
|
||||
// for more detail.
|
||||
JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
|
||||
// Test jspb wire format. Google internal only. Opensource testees just skip it.
|
||||
JSPB_TEST = 4;
|
||||
// Test text format. For cpp, java and python, testees can already deal with
|
||||
// this type. Testees of other languages can simply skip it.
|
||||
TEXT_FORMAT_TEST = 5;
|
||||
}
|
||||
|
||||
// The conformance runner will request a list of failures as the first request.
|
||||
// This will be known by message_type == "conformance.FailureSet", a conformance
|
||||
// test should return a serialized FailureSet in protobuf_payload.
|
||||
message FailureSet {
|
||||
repeated string failure = 1;
|
||||
}
|
||||
|
||||
// Represents a single test case's input. The testee should:
|
||||
@@ -73,6 +99,9 @@ message ConformanceRequest {
|
||||
oneof payload {
|
||||
bytes protobuf_payload = 1;
|
||||
string json_payload = 2;
|
||||
// Google internal only. Opensource testees just skip it.
|
||||
string jspb_payload = 7;
|
||||
string text_payload = 8;
|
||||
}
|
||||
|
||||
// Which format should the testee serialize its message to?
|
||||
@@ -82,6 +111,18 @@ message ConformanceRequest {
|
||||
// protobuf_test_messages.proto3.TestAllTypesProto3 or
|
||||
// protobuf_test_messages.proto2.TestAllTypesProto2.
|
||||
string message_type = 4;
|
||||
|
||||
// Each test is given a specific test category. Some category may need
|
||||
// spedific support in testee programs. Refer to the defintion of TestCategory
|
||||
// for more information.
|
||||
TestCategory test_category = 5;
|
||||
|
||||
// Specify details for how to encode jspb.
|
||||
JspbEncodingConfig jspb_encoding_options = 6;
|
||||
|
||||
// This can be used in json and text format. If true, testee should print
|
||||
// unknown fields instead of ignore. This feature is optional.
|
||||
bool print_unknown_fields = 9;
|
||||
}
|
||||
|
||||
// Represents a single test case's output.
|
||||
@@ -115,5 +156,21 @@ message ConformanceResponse {
|
||||
// For when the testee skipped the test, likely because a certain feature
|
||||
// wasn't supported, like JSON input/output.
|
||||
string skipped = 5;
|
||||
|
||||
// If the input was successfully parsed and the requested output was JSPB,
|
||||
// serialize to JSPB and set it in this field. JSPB is google internal only
|
||||
// format. Opensource testees can just skip it.
|
||||
string jspb_payload = 7;
|
||||
|
||||
// If the input was successfully parsed and the requested output was
|
||||
// TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.
|
||||
string text_payload = 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Encoding options for jspb format.
|
||||
message JspbEncodingConfig {
|
||||
// Encode the value field of Any as jspb array if ture, otherwise binary.
|
||||
bool use_jspb_array_any_format = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#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>
|
||||
|
||||
@@ -45,17 +46,48 @@ using google::protobuf::Descriptor;
|
||||
using google::protobuf::DescriptorPool;
|
||||
using google::protobuf::Message;
|
||||
using google::protobuf::MessageFactory;
|
||||
using google::protobuf::TextFormat;
|
||||
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::proto3::TestAllTypesProto3;
|
||||
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) {
|
||||
return string(kTypeUrlPrefix) + "/" + message->full_name();
|
||||
}
|
||||
@@ -112,8 +144,13 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
|
||||
|
||||
case ConformanceRequest::kJsonPayload: {
|
||||
string proto_binary;
|
||||
JsonParseOptions options;
|
||||
options.ignore_unknown_fields =
|
||||
(request.test_category() ==
|
||||
conformance::JSON_IGNORE_UNKNOWN_PARSING_TEST);
|
||||
Status status = JsonToBinaryString(type_resolver, *type_url,
|
||||
request.json_payload(), &proto_binary);
|
||||
request.json_payload(), &proto_binary,
|
||||
options);
|
||||
if (!status.ok()) {
|
||||
response->set_parse_error(string("Parse error: ") +
|
||||
status.error_message().as_string());
|
||||
@@ -128,9 +165,28 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
|
||||
break;
|
||||
}
|
||||
|
||||
case ConformanceRequest::kTextPayload: {
|
||||
if (!TextFormat::ParseFromString(request.text_payload(), test_message)) {
|
||||
response->set_parse_error("Parse error");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ConformanceRequest::PAYLOAD_NOT_SET:
|
||||
GOOGLE_LOG(FATAL) << "Request didn't have payload.";
|
||||
break;
|
||||
|
||||
default:
|
||||
GOOGLE_LOG(FATAL) << "unknown payload type: "
|
||||
<< request.payload_case();
|
||||
break;
|
||||
}
|
||||
|
||||
conformance::FailureSet failures;
|
||||
if (descriptor == failures.GetDescriptor()) {
|
||||
for (const char* s : kFailures) failures.add_failure(s);
|
||||
test_message = &failures;
|
||||
}
|
||||
|
||||
switch (request.requested_output_format()) {
|
||||
@@ -157,6 +213,14 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
|
||||
break;
|
||||
}
|
||||
|
||||
case conformance::TEXT_FORMAT: {
|
||||
TextFormat::Printer printer;
|
||||
printer.SetHideUnknownFields(!request.print_unknown_fields());
|
||||
GOOGLE_CHECK(printer.PrintToString(*test_message,
|
||||
response->mutable_text_payload()));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
GOOGLE_LOG(FATAL) << "Unknown output format: "
|
||||
<< request.requested_output_format();
|
||||
|
||||
@@ -92,6 +92,16 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
|
||||
case ConformanceRequest_Payload_OneOfCase_JsonPayload:
|
||||
response.skipped = @"ObjC doesn't support parsing JSON";
|
||||
break;
|
||||
|
||||
case ConformanceRequest_Payload_OneOfCase_JspbPayload:
|
||||
response.skipped =
|
||||
@"ConformanceRequest had a jspb_payload ConformanceRequest.payload;"
|
||||
" those aren't supposed to happen with opensource.";
|
||||
break;
|
||||
|
||||
case ConformanceRequest_Payload_OneOfCase_TextPayload:
|
||||
response.skipped = @"ObjC doesn't support parsing TextFormat";
|
||||
break;
|
||||
}
|
||||
|
||||
if (testMessage) {
|
||||
@@ -112,6 +122,18 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
|
||||
case WireFormat_Json:
|
||||
response.skipped = @"ObjC doesn't support generating JSON";
|
||||
break;
|
||||
|
||||
case WireFormat_Jspb:
|
||||
response.skipped =
|
||||
@"ConformanceRequest had a requested_output_format of JSPB WireFormat; that"
|
||||
" isn't supposed to happen with opensource.";
|
||||
break;
|
||||
|
||||
case WireFormat_TextFormat:
|
||||
// ObjC only has partial objc generation, so don't attempt any tests that need
|
||||
// support.
|
||||
response.skipped = @"ObjC doesn't support generating TextFormat";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,20 @@
|
||||
require_once("Conformance/WireFormat.php");
|
||||
require_once("Conformance/ConformanceResponse.php");
|
||||
require_once("Conformance/ConformanceRequest.php");
|
||||
require_once("Conformance/FailureSet.php");
|
||||
require_once("Conformance/JspbEncodingConfig.php");
|
||||
require_once("Conformance/TestCategory.php");
|
||||
require_once("Protobuf_test_messages/Proto3/ForeignMessage.php");
|
||||
require_once("Protobuf_test_messages/Proto3/ForeignEnum.php");
|
||||
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3.php");
|
||||
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/AliasedEnum.php");
|
||||
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedMessage.php");
|
||||
require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedEnum.php");
|
||||
|
||||
require_once("GPBMetadata/Conformance.php");
|
||||
require_once("GPBMetadata/Google/Protobuf/TestMessagesProto3.php");
|
||||
|
||||
use \Conformance\TestCategory;
|
||||
use \Conformance\WireFormat;
|
||||
|
||||
if (!ini_get("date.timezone")) {
|
||||
@@ -25,7 +30,10 @@ function doTest($request)
|
||||
$test_message = new \Protobuf_test_messages\Proto3\TestAllTypesProto3();
|
||||
$response = new \Conformance\ConformanceResponse();
|
||||
if ($request->getPayload() == "protobuf_payload") {
|
||||
if ($request->getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
|
||||
if ($request->getMessageType() == "conformance.FailureSet") {
|
||||
$response->setProtobufPayload("");
|
||||
return $response;
|
||||
} elseif ($request->getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
|
||||
try {
|
||||
$test_message->mergeFromString($request->getProtobufPayload());
|
||||
} catch (Exception $e) {
|
||||
@@ -39,13 +47,20 @@ function doTest($request)
|
||||
trigger_error("Protobuf request doesn't have specific payload type", E_USER_ERROR);
|
||||
}
|
||||
} elseif ($request->getPayload() == "json_payload") {
|
||||
$ignore_json_unknown =
|
||||
($request->getTestCategory() ==
|
||||
TestCategory::JSON_IGNORE_UNKNOWN_PARSING_TEST);
|
||||
try {
|
||||
$test_message->mergeFromJsonString($request->getJsonPayload());
|
||||
$test_message->mergeFromJsonString($request->getJsonPayload(),
|
||||
$ignore_json_unknown);
|
||||
} catch (Exception $e) {
|
||||
$response->setParseError($e->getMessage());
|
||||
return $response;
|
||||
}
|
||||
} else {
|
||||
} elseif ($request->getPayload() == "text_payload") {
|
||||
$response->setSkipped("PHP doesn't support text format yet");
|
||||
return $response;
|
||||
} else {
|
||||
trigger_error("Request didn't have payload.", E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ from google.protobuf import json_format
|
||||
from google.protobuf import message
|
||||
from google.protobuf import test_messages_proto3_pb2
|
||||
from google.protobuf import test_messages_proto2_pb2
|
||||
from google.protobuf import text_format
|
||||
import conformance_pb2
|
||||
|
||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
|
||||
@@ -56,29 +57,94 @@ class ProtocolError(Exception):
|
||||
pass
|
||||
|
||||
def do_test(request):
|
||||
response = conformance_pb2.ConformanceResponse()
|
||||
|
||||
if request.message_type == "conformance.FailureSet":
|
||||
failure_set = conformance_pb2.FailureSet()
|
||||
failures = []
|
||||
# TODO(gerbens): Remove, this is a hack to detect if the old vs new
|
||||
# parser is used by the cpp code. Relying on a bug in the old parser.
|
||||
hack_proto = test_messages_proto2_pb2.TestAllTypesProto2()
|
||||
old_parser = True
|
||||
try:
|
||||
hack_proto.ParseFromString(b"\322\002\001")
|
||||
except message.DecodeError as e:
|
||||
old_parser = False
|
||||
if old_parser:
|
||||
# the string above is one of the failing conformance test strings of the
|
||||
# old parser. If we succeed the c++ implementation is using the old
|
||||
# parser so we add the list of failing conformance tests.
|
||||
failures = [
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
|
||||
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
|
||||
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
|
||||
]
|
||||
for x in failures:
|
||||
failure_set.failure.append(x)
|
||||
response.protobuf_payload = failure_set.SerializeToString()
|
||||
return response
|
||||
|
||||
isProto3 = (request.message_type == "protobuf_test_messages.proto3.TestAllTypesProto3")
|
||||
isJson = (request.WhichOneof('payload') == 'json_payload')
|
||||
isProto2 = (request.message_type == "protobuf_test_messages.proto2.TestAllTypesProto2")
|
||||
|
||||
|
||||
if (not isProto3) and (not isJson) and (not isProto2):
|
||||
raise ProtocolError("Protobuf request doesn't have specific payload type")
|
||||
|
||||
|
||||
test_message = test_messages_proto2_pb2.TestAllTypesProto2() if isProto2 else \
|
||||
test_messages_proto3_pb2.TestAllTypesProto3()
|
||||
|
||||
response = conformance_pb2.ConformanceResponse()
|
||||
|
||||
try:
|
||||
if request.WhichOneof('payload') == 'protobuf_payload':
|
||||
try:
|
||||
test_message.ParseFromString(request.protobuf_payload)
|
||||
except message.DecodeError as e:
|
||||
response.parse_error = str(e)
|
||||
return response
|
||||
|
||||
return response
|
||||
|
||||
elif request.WhichOneof('payload') == 'json_payload':
|
||||
try:
|
||||
json_format.Parse(request.json_payload, test_message)
|
||||
ignore_unknown_fields = \
|
||||
request.test_category == \
|
||||
conformance_pb2.JSON_IGNORE_UNKNOWN_PARSING_TEST
|
||||
json_format.Parse(request.json_payload, test_message,
|
||||
ignore_unknown_fields)
|
||||
except Exception as e:
|
||||
response.parse_error = str(e)
|
||||
return response
|
||||
|
||||
elif request.WhichOneof('payload') == 'text_payload':
|
||||
try:
|
||||
text_format.Parse(request.text_payload, test_message)
|
||||
except Exception as e:
|
||||
response.parse_error = str(e)
|
||||
return response
|
||||
@@ -93,12 +159,16 @@ def do_test(request):
|
||||
response.protobuf_payload = test_message.SerializeToString()
|
||||
|
||||
elif request.requested_output_format == conformance_pb2.JSON:
|
||||
try:
|
||||
try:
|
||||
response.json_payload = json_format.MessageToJson(test_message)
|
||||
except Exception as e:
|
||||
response.serialize_error = str(e)
|
||||
return response
|
||||
|
||||
elif request.requested_output_format == conformance_pb2.TEXT_FORMAT:
|
||||
response.text_payload = text_format.MessageToString(
|
||||
test_message, print_unknown_fields=request.print_unknown_fields)
|
||||
|
||||
except Exception as e:
|
||||
response.runtime_error = str(e)
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ def do_test(request)
|
||||
elsif request.message_type.eql?('protobuf_test_messages.proto2.TestAllTypesProto2')
|
||||
response.skipped = "Ruby doesn't support proto2"
|
||||
return response
|
||||
else
|
||||
else
|
||||
fail "Protobuf request doesn't have specific payload type"
|
||||
end
|
||||
|
||||
@@ -66,6 +66,12 @@ def do_test(request)
|
||||
response.parse_error = err.message.encode('utf-8')
|
||||
return response
|
||||
end
|
||||
|
||||
when :text_payload
|
||||
begin
|
||||
response.skipped = "Ruby doesn't support proto2"
|
||||
return response
|
||||
end
|
||||
|
||||
when nil
|
||||
fail "Request didn't have payload"
|
||||
|
||||
2573
third_party/protobuf/conformance/conformance_test.cc
vendored
2573
third_party/protobuf/conformance/conformance_test.cc
vendored
File diff suppressed because it is too large
Load Diff
243
third_party/protobuf/conformance/conformance_test.h
vendored
243
third_party/protobuf/conformance/conformance_test.h
vendored
@@ -40,11 +40,13 @@
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/util/type_resolver.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
|
||||
#include "third_party/jsoncpp/json.h"
|
||||
#include "conformance.pb.h"
|
||||
|
||||
namespace conformance {
|
||||
class ConformanceRequest;
|
||||
@@ -60,6 +62,8 @@ class TestAllTypesProto3;
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
class ConformanceTestSuite;
|
||||
|
||||
class ConformanceTestRunner {
|
||||
public:
|
||||
virtual ~ConformanceTestRunner() {}
|
||||
@@ -76,39 +80,74 @@ class ConformanceTestRunner {
|
||||
std::string* output) = 0;
|
||||
};
|
||||
|
||||
// Test runner that spawns the process being tested and communicates with it
|
||||
// over a pipe.
|
||||
class ForkPipeRunner : public ConformanceTestRunner {
|
||||
public:
|
||||
// Note: Run() doesn't take ownership of the pointers inside suites.
|
||||
static int Run(int argc, char *argv[],
|
||||
const std::vector<ConformanceTestSuite*>& suites);
|
||||
|
||||
ForkPipeRunner(const std::string &executable)
|
||||
: child_pid_(-1), executable_(executable) {}
|
||||
|
||||
virtual ~ForkPipeRunner() {}
|
||||
|
||||
void RunTest(const std::string& test_name,
|
||||
const std::string& request,
|
||||
std::string* response);
|
||||
|
||||
private:
|
||||
void SpawnTestProgram();
|
||||
|
||||
void CheckedWrite(int fd, const void *buf, size_t len);
|
||||
bool TryRead(int fd, void *buf, size_t len);
|
||||
void CheckedRead(int fd, void *buf, size_t len);
|
||||
|
||||
int write_fd_;
|
||||
int read_fd_;
|
||||
pid_t child_pid_;
|
||||
std::string executable_;
|
||||
std::string current_test_name_;
|
||||
};
|
||||
|
||||
// Class representing the test suite itself. To run it, implement your own
|
||||
// class derived from ConformanceTestRunner and then write code like:
|
||||
// class derived from ConformanceTestRunner, class derived from
|
||||
// ConformanceTestSuite and then write code like:
|
||||
//
|
||||
// class MyConformanceTestSuite : public ConformanceTestSuite {
|
||||
// public:
|
||||
// void RunSuiteImpl() {
|
||||
// // INSERT ACTURAL TESTS.
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// class MyConformanceTestRunner : public ConformanceTestRunner {
|
||||
// public:
|
||||
// static int Run(int argc, char *argv[],
|
||||
// ConformanceTestSuite* suite);
|
||||
//
|
||||
// private:
|
||||
// virtual void RunTest(...) {
|
||||
// // INSERT YOUR FRAMEWORK-SPECIFIC CODE HERE.
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// int main() {
|
||||
// MyConformanceTestRunner runner;
|
||||
// google::protobuf::ConformanceTestSuite suite;
|
||||
//
|
||||
// std::string output;
|
||||
// suite.RunSuite(&runner, &output);
|
||||
// MyConformanceTestSuite suite;
|
||||
// MyConformanceTestRunner::Run(argc, argv, &suite);
|
||||
// }
|
||||
//
|
||||
class ConformanceTestSuite {
|
||||
public:
|
||||
ConformanceTestSuite() : verbose_(false), enforce_recommended_(false) {}
|
||||
ConformanceTestSuite()
|
||||
: verbose_(false),
|
||||
enforce_recommended_(false),
|
||||
failure_list_flag_name_("--failure_list") {}
|
||||
virtual ~ConformanceTestSuite() {}
|
||||
|
||||
void SetVerbose(bool verbose) { verbose_ = verbose; }
|
||||
|
||||
// Sets the list of tests that are expected to fail when RunSuite() is called.
|
||||
// RunSuite() will fail unless the set of failing tests is exactly the same
|
||||
// as this list.
|
||||
//
|
||||
// The filename here is *only* used to create/format useful error messages for
|
||||
// how to update the failure list. We do NOT read this file at all.
|
||||
void SetFailureList(const std::string& filename,
|
||||
const std::vector<std::string>& failure_list);
|
||||
|
||||
// Whether to require the testee to pass RECOMMENDED tests. By default failing
|
||||
// a RECOMMENDED test case will not fail the entire suite but will only
|
||||
// generated a warning. If this flag is set to true, RECOMMENDED tests will
|
||||
@@ -121,15 +160,28 @@ class ConformanceTestSuite {
|
||||
enforce_recommended_ = value;
|
||||
}
|
||||
|
||||
// Gets the flag name to the failure list file.
|
||||
// By default, this would return --failure_list
|
||||
string GetFailureListFlagName() {
|
||||
return failure_list_flag_name_;
|
||||
}
|
||||
|
||||
void SetFailureListFlagName(const std::string& failure_list_flag_name) {
|
||||
failure_list_flag_name_ = failure_list_flag_name;
|
||||
}
|
||||
|
||||
// Run all the conformance tests against the given test runner.
|
||||
// Test output will be stored in "output".
|
||||
//
|
||||
// Returns true if the set of failing tests was exactly the same as the
|
||||
// failure list. If SetFailureList() was not called, returns true if all
|
||||
// tests passed.
|
||||
bool RunSuite(ConformanceTestRunner* runner, std::string* output);
|
||||
// failure list.
|
||||
// The filename here is *only* used to create/format useful error messages for
|
||||
// how to update the failure list. We do NOT read this file at all.
|
||||
bool RunSuite(ConformanceTestRunner* runner, std::string* output,
|
||||
const std::string& filename,
|
||||
conformance::FailureSet* failure_list);
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Test cases are classified into a few categories:
|
||||
// REQUIRED: the test case must be passed for an implementation to be
|
||||
// interoperable with other implementations. For example, a
|
||||
@@ -146,7 +198,70 @@ class ConformanceTestSuite {
|
||||
REQUIRED = 0,
|
||||
RECOMMENDED = 1,
|
||||
};
|
||||
string ConformanceLevelToString(ConformanceLevel level);
|
||||
|
||||
class ConformanceRequestSetting {
|
||||
public:
|
||||
ConformanceRequestSetting(
|
||||
ConformanceLevel level,
|
||||
conformance::WireFormat input_format,
|
||||
conformance::WireFormat output_format,
|
||||
conformance::TestCategory test_category,
|
||||
const Message& prototype_message,
|
||||
const string& test_name, const string& input);
|
||||
virtual ~ConformanceRequestSetting() {}
|
||||
|
||||
Message* GetTestMessage() const;
|
||||
|
||||
string GetTestName() const;
|
||||
|
||||
const conformance::ConformanceRequest& GetRequest() const {
|
||||
return request_;
|
||||
}
|
||||
|
||||
const ConformanceLevel GetLevel() const {
|
||||
return level_;
|
||||
}
|
||||
|
||||
string ConformanceLevelToString(ConformanceLevel level) const;
|
||||
|
||||
void SetPrintUnknownFields(bool print_unknown_fields) {
|
||||
request_.set_print_unknown_fields(true);
|
||||
}
|
||||
|
||||
void SetPrototypeMessageForCompare(const Message& message) {
|
||||
prototype_message_for_compare_.reset(message.New());
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual string InputFormatString(conformance::WireFormat format) const;
|
||||
virtual string OutputFormatString(conformance::WireFormat format) const;
|
||||
conformance::ConformanceRequest request_;
|
||||
|
||||
private:
|
||||
ConformanceLevel level_;
|
||||
::conformance::WireFormat input_format_;
|
||||
::conformance::WireFormat output_format_;
|
||||
const Message& prototype_message_;
|
||||
std::unique_ptr<Message> prototype_message_for_compare_;
|
||||
string test_name_;
|
||||
};
|
||||
|
||||
bool CheckSetEmpty(const std::set<string>& set_to_check,
|
||||
const std::string& write_to_file, const std::string& msg);
|
||||
string WireFormatToString(conformance::WireFormat wire_format);
|
||||
|
||||
// Parse payload in the response to the given message. Returns true on
|
||||
// success.
|
||||
virtual bool ParseResponse(
|
||||
const conformance::ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting,
|
||||
Message* test_message) = 0;
|
||||
|
||||
void VerifyResponse(
|
||||
const ConformanceRequestSetting& setting,
|
||||
const string& equivalent_wire_format,
|
||||
const conformance::ConformanceResponse& response,
|
||||
bool need_report_success);
|
||||
|
||||
void ReportSuccess(const std::string& test_name);
|
||||
void ReportFailure(const string& test_name,
|
||||
@@ -157,86 +272,27 @@ class ConformanceTestSuite {
|
||||
void ReportSkip(const string& test_name,
|
||||
const conformance::ConformanceRequest& request,
|
||||
const conformance::ConformanceResponse& response);
|
||||
|
||||
void RunValidInputTest(const ConformanceRequestSetting& setting,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidBinaryInputTest(const ConformanceRequestSetting& setting,
|
||||
const string& equivalent_wire_format);
|
||||
|
||||
void RunTest(const std::string& test_name,
|
||||
const conformance::ConformanceRequest& request,
|
||||
conformance::ConformanceResponse* response);
|
||||
void RunValidInputTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input,
|
||||
conformance::WireFormat input_format,
|
||||
const string& equivalent_text_format,
|
||||
conformance::WireFormat requested_output,
|
||||
bool isProto3);
|
||||
void RunValidBinaryInputTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input,
|
||||
conformance::WireFormat input_format,
|
||||
const string& equivalent_wire_format,
|
||||
conformance::WireFormat requested_output,
|
||||
bool isProto3);
|
||||
void RunValidJsonTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidJsonTestWithProtobufInput(
|
||||
const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const protobuf_test_messages::proto3::TestAllTypesProto3& input,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
|
||||
const string& input_protobuf,
|
||||
const string& equivalent_text_format,
|
||||
bool isProto3);
|
||||
void RunValidBinaryProtobufTest(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_protobuf,
|
||||
bool isProto3);
|
||||
void RunValidProtobufTestWithMessage(
|
||||
const string& test_name, ConformanceLevel level,
|
||||
const Message *input,
|
||||
const string& equivalent_text_format,
|
||||
bool isProto3);
|
||||
|
||||
typedef std::function<bool(const Json::Value&)> Validator;
|
||||
void RunValidJsonTestWithValidator(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json,
|
||||
const Validator& validator);
|
||||
void ExpectParseFailureForJson(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_json);
|
||||
void ExpectSerializeFailureForJson(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& text_format);
|
||||
void ExpectParseFailureForProtoWithProtoVersion (const string& proto,
|
||||
const string& test_name,
|
||||
ConformanceLevel level,
|
||||
bool isProto3);
|
||||
void ExpectParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name,
|
||||
ConformanceLevel level);
|
||||
void ExpectHardParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name,
|
||||
ConformanceLevel level);
|
||||
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
|
||||
void TestIllegalTags();
|
||||
template <class MessageType>
|
||||
void TestOneofMessage (MessageType &message,
|
||||
bool isProto3);
|
||||
template <class MessageType>
|
||||
void TestUnknownMessage (MessageType &message,
|
||||
bool isProto3);
|
||||
void TestValidDataForType(
|
||||
google::protobuf::FieldDescriptor::Type,
|
||||
std::vector<std::pair<std::string, std::string>> values);
|
||||
bool CheckSetEmpty(const std::set<string>& set_to_check,
|
||||
const std::string& write_to_file, const std::string& msg);
|
||||
void AddExpectedFailedTest(const std::string& test_name);
|
||||
|
||||
virtual void RunSuiteImpl() = 0;
|
||||
|
||||
ConformanceTestRunner* runner_;
|
||||
int successes_;
|
||||
int expected_failures_;
|
||||
bool verbose_;
|
||||
bool enforce_recommended_;
|
||||
std::string output_;
|
||||
std::string failure_list_flag_name_;
|
||||
std::string failure_list_filename_;
|
||||
|
||||
// The set of test names that are expected to fail in this run, but haven't
|
||||
@@ -255,9 +311,6 @@ class ConformanceTestSuite {
|
||||
|
||||
// The set of tests that the testee opted out of;
|
||||
std::set<std::string> skipped_;
|
||||
|
||||
std::unique_ptr<google::protobuf::util::TypeResolver> type_resolver_;
|
||||
std::string type_url_;
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
|
||||
40
third_party/protobuf/conformance/conformance_test_main.cc
vendored
Normal file
40
third_party/protobuf/conformance/conformance_test_main.cc
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// 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 "binary_json_conformance_suite.h"
|
||||
#include "conformance_test.h"
|
||||
#include "text_format_conformance_suite.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
google::protobuf::BinaryAndJsonConformanceSuite binary_and_json_suite;
|
||||
google::protobuf::TextFormatConformanceTestSuite text_format_suite;
|
||||
return google::protobuf::ForkPipeRunner::Run(
|
||||
argc, argv, {&binary_and_json_suite, &text_format_suite});
|
||||
}
|
||||
@@ -66,9 +66,9 @@
|
||||
#include "conformance.pb.h"
|
||||
#include "conformance_test.h"
|
||||
|
||||
using conformance::ConformanceRequest;
|
||||
using conformance::ConformanceResponse;
|
||||
using google::protobuf::StringAppendF;
|
||||
using google::protobuf::ConformanceTestSuite;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
@@ -80,190 +80,11 @@ using std::vector;
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
// Test runner that spawns the process being tested and communicates with it
|
||||
// over a pipe.
|
||||
class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
|
||||
public:
|
||||
ForkPipeRunner(const std::string &executable)
|
||||
: child_pid_(-1), executable_(executable) {}
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
virtual ~ForkPipeRunner() {}
|
||||
|
||||
void RunTest(const std::string& test_name,
|
||||
const std::string& request,
|
||||
std::string* response) {
|
||||
if (child_pid_ < 0) {
|
||||
SpawnTestProgram();
|
||||
}
|
||||
|
||||
current_test_name_ = test_name;
|
||||
|
||||
uint32_t len = request.size();
|
||||
CheckedWrite(write_fd_, &len, sizeof(uint32_t));
|
||||
CheckedWrite(write_fd_, request.c_str(), request.size());
|
||||
|
||||
if (!TryRead(read_fd_, &len, sizeof(uint32_t))) {
|
||||
// We failed to read from the child, assume a crash and try to reap.
|
||||
GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_;
|
||||
|
||||
int status;
|
||||
waitpid(child_pid_, &status, WEXITED);
|
||||
|
||||
string error_msg;
|
||||
if (WIFEXITED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child exited, status=%d", WEXITSTATUS(status));
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child killed by signal %d", WTERMSIG(status));
|
||||
}
|
||||
GOOGLE_LOG(INFO) << error_msg;
|
||||
child_pid_ = -1;
|
||||
|
||||
conformance::ConformanceResponse response_obj;
|
||||
response_obj.set_runtime_error(error_msg);
|
||||
response_obj.SerializeToString(response);
|
||||
return;
|
||||
}
|
||||
|
||||
response->resize(len);
|
||||
CheckedRead(read_fd_, (void*)response->c_str(), len);
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO(haberman): make this work on Windows, instead of using these
|
||||
// UNIX-specific APIs.
|
||||
//
|
||||
// There is a platform-agnostic API in
|
||||
// src/google/protobuf/compiler/subprocess.h
|
||||
//
|
||||
// However that API only supports sending a single message to the subprocess.
|
||||
// We really want to be able to send messages and receive responses one at a
|
||||
// time:
|
||||
//
|
||||
// 1. Spawning a new process for each test would take way too long for thousands
|
||||
// of tests and subprocesses like java that can take 100ms or more to start
|
||||
// up.
|
||||
//
|
||||
// 2. Sending all the tests in one big message and receiving all results in one
|
||||
// big message would take away our visibility about which test(s) caused a
|
||||
// crash or other fatal error. It would also give us only a single failure
|
||||
// instead of all of them.
|
||||
void SpawnTestProgram() {
|
||||
int toproc_pipe_fd[2];
|
||||
int fromproc_pipe_fd[2];
|
||||
if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pid) {
|
||||
// Parent.
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
write_fd_ = toproc_pipe_fd[1];
|
||||
read_fd_ = fromproc_pipe_fd[0];
|
||||
child_pid_ = pid;
|
||||
} else {
|
||||
// Child.
|
||||
CHECK_SYSCALL(close(STDIN_FILENO));
|
||||
CHECK_SYSCALL(close(STDOUT_FILENO));
|
||||
CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO));
|
||||
CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO));
|
||||
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[0]));
|
||||
|
||||
std::unique_ptr<char[]> executable(new char[executable_.size() + 1]);
|
||||
memcpy(executable.get(), executable_.c_str(), executable_.size());
|
||||
executable[executable_.size()] = '\0';
|
||||
|
||||
char *const argv[] = {executable.get(), NULL};
|
||||
CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
|
||||
}
|
||||
}
|
||||
|
||||
void CheckedWrite(int fd, const void *buf, size_t len) {
|
||||
if (write(fd, buf, len) != len) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error writing to test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
bool TryRead(int fd, void *buf, size_t len) {
|
||||
size_t ofs = 0;
|
||||
while (len > 0) {
|
||||
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
|
||||
|
||||
if (bytes_read == 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": unexpected EOF from test program";
|
||||
return false;
|
||||
} else if (bytes_read < 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
len -= bytes_read;
|
||||
ofs += bytes_read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckedRead(int fd, void *buf, size_t len) {
|
||||
if (!TryRead(fd, buf, len)) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
int write_fd_;
|
||||
int read_fd_;
|
||||
pid_t child_pid_;
|
||||
std::string executable_;
|
||||
std::string current_test_name_;
|
||||
};
|
||||
|
||||
void UsageError() {
|
||||
fprintf(stderr,
|
||||
"Usage: conformance-test-runner [options] <test-program>\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr,
|
||||
" --failure_list <filename> Use to specify list of tests\n");
|
||||
fprintf(stderr,
|
||||
" that are expected to fail. File\n");
|
||||
fprintf(stderr,
|
||||
" should contain one test name per\n");
|
||||
fprintf(stderr,
|
||||
" line. Use '#' for comments.\n");
|
||||
fprintf(stderr,
|
||||
" --enforce_recommended Enforce that recommended test\n");
|
||||
fprintf(stderr,
|
||||
" cases are also passing. Specify\n");
|
||||
fprintf(stderr,
|
||||
" this flag if you want to be\n");
|
||||
fprintf(stderr,
|
||||
" strictly conforming to protobuf\n");
|
||||
fprintf(stderr,
|
||||
" spec.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void ParseFailureList(const char *filename, std::vector<string>* failure_list) {
|
||||
void ParseFailureList(const char *filename,
|
||||
conformance::FailureSet *failure_list) {
|
||||
std::ifstream infile(filename);
|
||||
|
||||
if (!infile.is_open()) {
|
||||
@@ -280,46 +101,243 @@ void ParseFailureList(const char *filename, std::vector<string>* failure_list) {
|
||||
line = line.substr(0, line.find("#"));
|
||||
|
||||
if (!line.empty()) {
|
||||
failure_list->push_back(line);
|
||||
failure_list->add_failure(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *program;
|
||||
google::protobuf::ConformanceTestSuite suite;
|
||||
void UsageError() {
|
||||
fprintf(stderr,
|
||||
"Usage: conformance-test-runner [options] <test-program>\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr,
|
||||
" --failure_list <filename> Use to specify list of tests\n");
|
||||
fprintf(stderr,
|
||||
" that are expected to fail. File\n");
|
||||
fprintf(stderr,
|
||||
" should contain one test name per\n");
|
||||
fprintf(stderr,
|
||||
" line. Use '#' for comments.\n");
|
||||
fprintf(stderr,
|
||||
" --text_format_failure_list <filename> Use to specify list \n");
|
||||
fprintf(stderr,
|
||||
" of tests that are expected to \n");
|
||||
fprintf(stderr,
|
||||
" fail in the \n");
|
||||
fprintf(stderr,
|
||||
" text_format_conformance_suite. \n");
|
||||
fprintf(stderr,
|
||||
" File should contain one test name \n");
|
||||
fprintf(stderr,
|
||||
" per line. Use '#' for comments.\n");
|
||||
|
||||
string failure_list_filename;
|
||||
std::vector<string> failure_list;
|
||||
fprintf(stderr,
|
||||
" --enforce_recommended Enforce that recommended test\n");
|
||||
fprintf(stderr,
|
||||
" cases are also passing. Specify\n");
|
||||
fprintf(stderr,
|
||||
" this flag if you want to be\n");
|
||||
fprintf(stderr,
|
||||
" strictly conforming to protobuf\n");
|
||||
fprintf(stderr,
|
||||
" spec.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], "--failure_list") == 0) {
|
||||
if (++arg == argc) UsageError();
|
||||
failure_list_filename = argv[arg];
|
||||
ParseFailureList(argv[arg], &failure_list);
|
||||
} else if (strcmp(argv[arg], "--verbose") == 0) {
|
||||
suite.SetVerbose(true);
|
||||
} else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
|
||||
suite.SetEnforceRecommended(true);
|
||||
} else if (argv[arg][0] == '-') {
|
||||
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
|
||||
UsageError();
|
||||
} else {
|
||||
if (arg != argc - 1) {
|
||||
fprintf(stderr, "Too many arguments.\n");
|
||||
UsageError();
|
||||
void ForkPipeRunner::RunTest(
|
||||
const std::string& test_name,
|
||||
const std::string& request,
|
||||
std::string* response) {
|
||||
if (child_pid_ < 0) {
|
||||
SpawnTestProgram();
|
||||
}
|
||||
|
||||
current_test_name_ = test_name;
|
||||
|
||||
uint32_t len = request.size();
|
||||
CheckedWrite(write_fd_, &len, sizeof(uint32_t));
|
||||
CheckedWrite(write_fd_, request.c_str(), request.size());
|
||||
|
||||
if (!TryRead(read_fd_, &len, sizeof(uint32_t))) {
|
||||
// We failed to read from the child, assume a crash and try to reap.
|
||||
GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_;
|
||||
|
||||
int status;
|
||||
waitpid(child_pid_, &status, WEXITED);
|
||||
|
||||
string error_msg;
|
||||
if (WIFEXITED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child exited, status=%d", WEXITSTATUS(status));
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child killed by signal %d", WTERMSIG(status));
|
||||
}
|
||||
GOOGLE_LOG(INFO) << error_msg;
|
||||
child_pid_ = -1;
|
||||
|
||||
conformance::ConformanceResponse response_obj;
|
||||
response_obj.set_runtime_error(error_msg);
|
||||
response_obj.SerializeToString(response);
|
||||
return;
|
||||
}
|
||||
|
||||
response->resize(len);
|
||||
CheckedRead(read_fd_, (void*)response->c_str(), len);
|
||||
}
|
||||
|
||||
int ForkPipeRunner::Run(
|
||||
int argc, char *argv[], const std::vector<ConformanceTestSuite*>& suites) {
|
||||
if (suites.empty()) {
|
||||
fprintf(stderr, "No test suites found.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
bool all_ok = true;
|
||||
for (ConformanceTestSuite* suite : suites) {
|
||||
char *program;
|
||||
string failure_list_filename;
|
||||
conformance::FailureSet failure_list;
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
|
||||
if (++arg == argc) UsageError();
|
||||
failure_list_filename = argv[arg];
|
||||
ParseFailureList(argv[arg], &failure_list);
|
||||
} else if (strcmp(argv[arg], "--verbose") == 0) {
|
||||
suite->SetVerbose(true);
|
||||
} else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
|
||||
suite->SetEnforceRecommended(true);
|
||||
} else if (argv[arg][0] == '-') {
|
||||
bool recognized_flag = false;
|
||||
for (ConformanceTestSuite* suite : suites) {
|
||||
if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
|
||||
if (++arg == argc) UsageError();
|
||||
recognized_flag = true;
|
||||
}
|
||||
}
|
||||
if (!recognized_flag) {
|
||||
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
|
||||
UsageError();
|
||||
}
|
||||
} else {
|
||||
if (arg != argc - 1) {
|
||||
fprintf(stderr, "Too many arguments.\n");
|
||||
UsageError();
|
||||
}
|
||||
program = argv[arg];
|
||||
}
|
||||
program = argv[arg];
|
||||
}
|
||||
|
||||
ForkPipeRunner runner(program);
|
||||
|
||||
std::string output;
|
||||
all_ok = all_ok &&
|
||||
suite->RunSuite(&runner, &output, failure_list_filename, &failure_list);
|
||||
|
||||
fwrite(output.c_str(), 1, output.size(), stderr);
|
||||
}
|
||||
return all_ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO(haberman): make this work on Windows, instead of using these
|
||||
// UNIX-specific APIs.
|
||||
//
|
||||
// There is a platform-agnostic API in
|
||||
// src/google/protobuf/compiler/subprocess.h
|
||||
//
|
||||
// However that API only supports sending a single message to the subprocess.
|
||||
// We really want to be able to send messages and receive responses one at a
|
||||
// time:
|
||||
//
|
||||
// 1. Spawning a new process for each test would take way too long for thousands
|
||||
// of tests and subprocesses like java that can take 100ms or more to start
|
||||
// up.
|
||||
//
|
||||
// 2. Sending all the tests in one big message and receiving all results in one
|
||||
// big message would take away our visibility about which test(s) caused a
|
||||
// crash or other fatal error. It would also give us only a single failure
|
||||
// instead of all of them.
|
||||
void ForkPipeRunner::SpawnTestProgram() {
|
||||
int toproc_pipe_fd[2];
|
||||
int fromproc_pipe_fd[2];
|
||||
if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
suite.SetFailureList(failure_list_filename, failure_list);
|
||||
ForkPipeRunner runner(program);
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string output;
|
||||
bool ok = suite.RunSuite(&runner, &output);
|
||||
if (pid) {
|
||||
// Parent.
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
write_fd_ = toproc_pipe_fd[1];
|
||||
read_fd_ = fromproc_pipe_fd[0];
|
||||
child_pid_ = pid;
|
||||
} else {
|
||||
// Child.
|
||||
CHECK_SYSCALL(close(STDIN_FILENO));
|
||||
CHECK_SYSCALL(close(STDOUT_FILENO));
|
||||
CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO));
|
||||
CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO));
|
||||
|
||||
fwrite(output.c_str(), 1, output.size(), stderr);
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[0]));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
std::unique_ptr<char[]> executable(new char[executable_.size() + 1]);
|
||||
memcpy(executable.get(), executable_.c_str(), executable_.size());
|
||||
executable[executable_.size()] = '\0';
|
||||
|
||||
char *const argv[] = {executable.get(), NULL};
|
||||
CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
|
||||
}
|
||||
}
|
||||
|
||||
void ForkPipeRunner::CheckedWrite(int fd, const void *buf, size_t len) {
|
||||
if (write(fd, buf, len) != len) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error writing to test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
bool ForkPipeRunner::TryRead(int fd, void *buf, size_t len) {
|
||||
size_t ofs = 0;
|
||||
while (len > 0) {
|
||||
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
|
||||
|
||||
if (bytes_read == 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": unexpected EOF from test program";
|
||||
return false;
|
||||
} else if (bytes_read < 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
len -= bytes_read;
|
||||
ofs += bytes_read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ForkPipeRunner::CheckedRead(int fd, void *buf, size_t len) {
|
||||
if (!TryRead(fd, buf, len)) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
@@ -34,23 +34,3 @@ Recommended.Proto3.JsonInput.TrailingCommaInAnObject
|
||||
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithNewlines
|
||||
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpace
|
||||
Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
|
||||
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
|
||||
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
|
||||
|
||||
@@ -13,6 +13,10 @@ Required.Proto3.JsonInput.FloatFieldTooSmall
|
||||
Required.Proto3.JsonInput.DoubleFieldTooSmall
|
||||
Required.Proto3.JsonInput.Int32FieldNotInteger
|
||||
Required.Proto3.JsonInput.Int64FieldNotInteger
|
||||
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||
Required.Proto3.JsonInput.RepeatedListValue.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedListValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldNotAString
|
||||
Required.Proto3.JsonInput.Uint32FieldNotInteger
|
||||
Required.Proto3.JsonInput.Uint64FieldNotInteger
|
||||
Required.Proto3.JsonInput.Int32FieldLeadingSpace
|
||||
|
||||
@@ -1,182 +1,45 @@
|
||||
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||
Recommended.Proto3.JsonInput.BoolFieldIntegerOne
|
||||
Recommended.Proto3.JsonInput.BoolFieldIntegerZero
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHas9FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
|
||||
Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
|
||||
Recommended.Proto3.JsonInput.MapFieldValueIsNull
|
||||
Recommended.Proto3.JsonInput.OneofZeroBytes.JsonOutput
|
||||
Recommended.Proto3.JsonInput.OneofZeroBytes.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.OneofZeroString.JsonOutput
|
||||
Recommended.Proto3.JsonInput.OneofZeroString.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
|
||||
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||
Recommended.Proto3.JsonInput.StringEndsWithEscapeChar
|
||||
Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder
|
||||
Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
|
||||
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
|
||||
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
|
||||
Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput
|
||||
Recommended.Proto3.ProtobufInput.OneofZeroBytes.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.OneofZeroString.JsonOutput
|
||||
Recommended.Proto3.ProtobufInput.OneofZeroString.ProtobufOutput
|
||||
Required.DurationProtoInputTooLarge.JsonOutput
|
||||
Required.DurationProtoInputTooSmall.JsonOutput
|
||||
Required.Proto3.JsonInput.Any.JsonOutput
|
||||
Required.Proto3.JsonInput.Any.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyNested.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyNested.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithDuration.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithDuration.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithStruct.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithStruct.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithTimestamp.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
Required.Proto3.JsonInput.BoolMapField.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldInfinity.ProtobufOutput
|
||||
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNan.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldQuotedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DurationMaxValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMaxValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DurationMinValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMinValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||
Required.Proto3.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||
Required.Proto3.JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||
Required.Proto3.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||
Required.Proto3.JsonInput.EnumFieldUnknownValue.Validator
|
||||
Required.Proto3.JsonInput.FieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.FieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldInfinity.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNan.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldQuotedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldQuotedValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldTooLarge
|
||||
Required.Proto3.JsonInput.FloatFieldTooSmall
|
||||
Required.Proto3.JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int32FieldStringValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldStringValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int32FieldStringValueEscaped.JsonOutput
|
||||
Required.Proto3.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int64FieldMaxValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Int64FieldMaxValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Int64FieldMinValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Int64FieldMinValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.MessageField.JsonOutput
|
||||
Required.Proto3.JsonInput.MessageField.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalStringWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OneofFieldDuplicate
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
|
||||
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||
Required.Proto3.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldEscape.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldEscape.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldNotAString
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscape.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Struct.JsonOutput
|
||||
Required.Proto3.JsonInput.Struct.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Uint64FieldMaxValue.JsonOutput
|
||||
Required.Proto3.JsonInput.Uint64FieldMaxValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptBool.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptFloat.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptInteger.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptList.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptList.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptNull.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptObject.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptString.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptString.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
|
||||
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||
|
||||
@@ -20,35 +20,3 @@ Required.Proto3.JsonInput.FloatFieldTooLarge
|
||||
Required.Proto3.JsonInput.FloatFieldTooSmall
|
||||
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
|
||||
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32
|
||||
Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64
|
||||
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
|
||||
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
|
||||
|
||||
@@ -5,8 +5,7 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHas9FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
|
||||
Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
|
||||
Recommended.Proto3.JsonInput.MapFieldValueIsNull
|
||||
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
|
||||
@@ -17,117 +16,42 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
|
||||
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
|
||||
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.TimestampHas9FractionalDigits.Validator
|
||||
Recommended.Proto3.JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||
Recommended.Proto3.JsonInput.TimestampZeroNormalized.Validator
|
||||
Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
|
||||
Required.DurationProtoInputTooLarge.JsonOutput
|
||||
Required.DurationProtoInputTooSmall.JsonOutput
|
||||
Required.Proto3.JsonInput.Any.JsonOutput
|
||||
Required.Proto3.JsonInput.Any.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyNested.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyNested.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithDuration.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithDuration.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithStruct.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithStruct.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithTimestamp.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
Required.Proto3.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMaxValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMaxValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DurationMinValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationMinValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FieldMask.JsonOutput
|
||||
Required.Proto3.JsonInput.FieldMask.ProtobufOutput
|
||||
Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
|
||||
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||
Required.Proto3.JsonInput.OneofFieldDuplicate
|
||||
Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalStringWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||
Required.Proto3.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||
Required.Proto3.JsonInput.Struct.JsonOutput
|
||||
Required.Proto3.JsonInput.Struct.ProtobufOutput
|
||||
Required.Proto3.JsonInput.TimestampMaxValue.JsonOutput
|
||||
Required.Proto3.JsonInput.TimestampMaxValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.TimestampMinValue.JsonOutput
|
||||
Required.Proto3.JsonInput.TimestampMinValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.TimestampRepeatedValue.JsonOutput
|
||||
Required.Proto3.JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||
Required.Proto3.JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||
Required.Proto3.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||
Required.Proto3.JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||
Required.Proto3.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptBool.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptFloat.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptInteger.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptList.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptList.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptListWithNull.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptListWithNull.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptNull.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptObject.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptString.JsonOutput
|
||||
Required.Proto3.JsonInput.ValueAcceptString.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||
@@ -135,3 +59,9 @@ Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
|
||||
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput
|
||||
Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput
|
||||
|
||||
317
third_party/protobuf/conformance/text_format_conformance_suite.cc
vendored
Normal file
317
third_party/protobuf/conformance/text_format_conformance_suite.cc
vendored
Normal file
@@ -0,0 +1,317 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// 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 "text_format_conformance_suite.h"
|
||||
|
||||
#include "conformance_test.h"
|
||||
|
||||
#include <google/protobuf/any.pb.h>
|
||||
#include <google/protobuf/test_messages_proto2.pb.h>
|
||||
#include <google/protobuf/test_messages_proto3.pb.h>
|
||||
#include <google/protobuf/text_format.h>
|
||||
|
||||
using conformance::ConformanceRequest;
|
||||
using conformance::ConformanceResponse;
|
||||
using conformance::WireFormat;
|
||||
using google::protobuf::Message;
|
||||
using google::protobuf::TextFormat;
|
||||
using protobuf_test_messages::proto2::TestAllTypesProto2;
|
||||
using protobuf_test_messages::proto2::UnknownToTestAllTypes;
|
||||
using protobuf_test_messages::proto3::TestAllTypesProto3;
|
||||
using std::string;
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
TextFormatConformanceTestSuite::TextFormatConformanceTestSuite() {
|
||||
SetFailureListFlagName("--text_format_failure_list");
|
||||
}
|
||||
|
||||
bool TextFormatConformanceTestSuite::ParseTextFormatResponse(
|
||||
const ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting, Message* test_message) {
|
||||
TextFormat::Parser parser;
|
||||
const ConformanceRequest& request = setting.GetRequest();
|
||||
if (request.print_unknown_fields()) {
|
||||
parser.AllowFieldNumber(true);
|
||||
}
|
||||
if (!parser.ParseFromString(response.text_payload(), test_message)) {
|
||||
GOOGLE_LOG(ERROR) << "INTERNAL ERROR: internal text->protobuf transcode "
|
||||
<< "yielded unparseable proto. Text payload: "
|
||||
<< response.text_payload();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextFormatConformanceTestSuite::ParseResponse(
|
||||
const ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting, Message* test_message) {
|
||||
const ConformanceRequest& request = setting.GetRequest();
|
||||
WireFormat requested_output = request.requested_output_format();
|
||||
const string& test_name = setting.GetTestName();
|
||||
ConformanceLevel level = setting.GetLevel();
|
||||
|
||||
switch (response.result_case()) {
|
||||
case ConformanceResponse::kProtobufPayload: {
|
||||
if (requested_output != conformance::PROTOBUF) {
|
||||
ReportFailure(
|
||||
test_name, level, request, response,
|
||||
StrCat("Test was asked for ", WireFormatToString(requested_output),
|
||||
" output but provided PROTOBUF instead.")
|
||||
.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!test_message->ParseFromString(response.protobuf_payload())) {
|
||||
ReportFailure(test_name, level, request, response,
|
||||
"Protobuf output we received from test was unparseable.");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ConformanceResponse::kTextPayload: {
|
||||
if (requested_output != conformance::TEXT_FORMAT) {
|
||||
ReportFailure(
|
||||
test_name, level, request, response,
|
||||
StrCat("Test was asked for ", WireFormatToString(requested_output),
|
||||
" output but provided TEXT_FORMAT instead.")
|
||||
.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ParseTextFormatResponse(response, setting, test_message)) {
|
||||
ReportFailure(
|
||||
test_name, level, request, response,
|
||||
"TEXT_FORMAT output we received from test was unparseable.");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
GOOGLE_LOG(FATAL) << test_name
|
||||
<< ": unknown payload type: " << response.result_case();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::ExpectParseFailure(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input) {
|
||||
TestAllTypesProto3 prototype;
|
||||
// We don't expect output, but if the program erroneously accepts the protobuf
|
||||
// we let it send its response as this. We must not leave it unspecified.
|
||||
ConformanceRequestSetting setting(
|
||||
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input);
|
||||
const ConformanceRequest& request = setting.GetRequest();
|
||||
ConformanceResponse response;
|
||||
string effective_test_name = StrCat(setting.ConformanceLevelToString(level),
|
||||
".Proto3.TextFormatInput.", test_name);
|
||||
|
||||
RunTest(effective_test_name, request, &response);
|
||||
if (response.result_case() == ConformanceResponse::kParseError) {
|
||||
ReportSuccess(effective_test_name);
|
||||
} else if (response.result_case() == ConformanceResponse::kSkipped) {
|
||||
ReportSkip(effective_test_name, request, response);
|
||||
} else {
|
||||
ReportFailure(effective_test_name, level, request, response,
|
||||
"Should have failed to parse, but didn't.");
|
||||
}
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTest(
|
||||
const string& test_name, ConformanceLevel level, const string& input_text) {
|
||||
TestAllTypesProto3 prototype;
|
||||
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype);
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTestProto2(
|
||||
const string& test_name, ConformanceLevel level, const string& input_text) {
|
||||
TestAllTypesProto2 prototype;
|
||||
RunValidTextFormatTestWithMessage(test_name, level, input_text, prototype);
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::RunValidTextFormatTestWithMessage(
|
||||
const string& test_name, ConformanceLevel level, const string& input_text,
|
||||
const Message& prototype) {
|
||||
ConformanceRequestSetting setting1(
|
||||
level, conformance::TEXT_FORMAT, conformance::PROTOBUF,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text);
|
||||
RunValidInputTest(setting1, input_text);
|
||||
ConformanceRequestSetting setting2(
|
||||
level, conformance::TEXT_FORMAT, conformance::TEXT_FORMAT,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name, input_text);
|
||||
RunValidInputTest(setting2, input_text);
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::RunValidUnknownTextFormatTest(
|
||||
const string& test_name, const Message& message) {
|
||||
string serialized_input;
|
||||
message.SerializeToString(&serialized_input);
|
||||
TestAllTypesProto3 prototype;
|
||||
ConformanceRequestSetting setting1(
|
||||
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Drop",
|
||||
serialized_input);
|
||||
setting1.SetPrototypeMessageForCompare(message);
|
||||
RunValidBinaryInputTest(setting1, "");
|
||||
|
||||
ConformanceRequestSetting setting2(
|
||||
RECOMMENDED, conformance::PROTOBUF, conformance::TEXT_FORMAT,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, test_name + "_Print",
|
||||
serialized_input);
|
||||
setting2.SetPrototypeMessageForCompare(message);
|
||||
setting2.SetPrintUnknownFields(true);
|
||||
RunValidBinaryInputTest(setting2, serialized_input);
|
||||
}
|
||||
|
||||
void TextFormatConformanceTestSuite::RunSuiteImpl() {
|
||||
RunValidTextFormatTest("HelloWorld", REQUIRED,
|
||||
"optional_string: 'Hello, World!'");
|
||||
// Integer fields.
|
||||
RunValidTextFormatTest("Int32FieldMaxValue", REQUIRED,
|
||||
"optional_int32: 2147483647");
|
||||
RunValidTextFormatTest("Int32FieldMinValue", REQUIRED,
|
||||
"optional_int32: -2147483648");
|
||||
RunValidTextFormatTest("Uint32FieldMaxValue", REQUIRED,
|
||||
"optional_uint32: 4294967295");
|
||||
RunValidTextFormatTest("Int64FieldMaxValue", REQUIRED,
|
||||
"optional_int64: 9223372036854775807");
|
||||
RunValidTextFormatTest("Int64FieldMinValue", REQUIRED,
|
||||
"optional_int64: -9223372036854775808");
|
||||
RunValidTextFormatTest("Uint64FieldMaxValue", REQUIRED,
|
||||
"optional_uint64: 18446744073709551615");
|
||||
|
||||
// Parsers reject out-of-bound integer values.
|
||||
ExpectParseFailure("Int32FieldTooLarge", REQUIRED,
|
||||
"optional_int32: 2147483648");
|
||||
ExpectParseFailure("Int32FieldTooSmall", REQUIRED,
|
||||
"optional_int32: -2147483649");
|
||||
ExpectParseFailure("Uint32FieldTooLarge", REQUIRED,
|
||||
"optional_uint32: 4294967296");
|
||||
ExpectParseFailure("Int64FieldTooLarge", REQUIRED,
|
||||
"optional_int64: 9223372036854775808");
|
||||
ExpectParseFailure("Int64FieldTooSmall", REQUIRED,
|
||||
"optional_int64: -9223372036854775809");
|
||||
ExpectParseFailure("Uint64FieldTooLarge", REQUIRED,
|
||||
"optional_uint64: 18446744073709551616");
|
||||
|
||||
// Floating point fields
|
||||
RunValidTextFormatTest("FloatField", REQUIRED,
|
||||
"optional_float: 3.192837");
|
||||
RunValidTextFormatTest("FloatFieldWithVeryPreciseNumber", REQUIRED,
|
||||
"optional_float: 3.123456789123456789");
|
||||
RunValidTextFormatTest("FloatFieldMaxValue", REQUIRED,
|
||||
"optional_float: 3.4028235e+38");
|
||||
RunValidTextFormatTest("FloatFieldMinValue", REQUIRED,
|
||||
"optional_float: 1.17549e-38");
|
||||
RunValidTextFormatTest("FloatFieldNaNValue", REQUIRED,
|
||||
"optional_float: NaN");
|
||||
RunValidTextFormatTest("FloatFieldPosInfValue", REQUIRED,
|
||||
"optional_float: inf");
|
||||
RunValidTextFormatTest("FloatFieldNegInfValue", REQUIRED,
|
||||
"optional_float: -inf");
|
||||
RunValidTextFormatTest("FloatFieldWithInt32Max", REQUIRED,
|
||||
"optional_float: 4294967296");
|
||||
RunValidTextFormatTest("FloatFieldLargerThanInt64", REQUIRED,
|
||||
"optional_float: 9223372036854775808");
|
||||
RunValidTextFormatTest("FloatFieldTooLarge", REQUIRED,
|
||||
"optional_float: 3.4028235e+39");
|
||||
RunValidTextFormatTest("FloatFieldTooSmall", REQUIRED,
|
||||
"optional_float: 1.17549e-39");
|
||||
RunValidTextFormatTest("FloatFieldLargerThanUint64", REQUIRED,
|
||||
"optional_float: 18446744073709551616");
|
||||
|
||||
// Group fields
|
||||
RunValidTextFormatTestProto2("GroupFieldNoColon", REQUIRED,
|
||||
"Data { group_int32: 1 }");
|
||||
RunValidTextFormatTestProto2("GroupFieldWithColon", REQUIRED,
|
||||
"Data: { group_int32: 1 }");
|
||||
RunValidTextFormatTestProto2("GroupFieldEmpty", REQUIRED,
|
||||
"Data {}");
|
||||
|
||||
|
||||
// Unknown Fields
|
||||
UnknownToTestAllTypes message;
|
||||
// Unable to print unknown Fixed32/Fixed64 fields as if they are known.
|
||||
// Fixed32/Fixed64 fields are not added in the tests.
|
||||
message.set_optional_int32(123);
|
||||
message.set_optional_string("hello");
|
||||
message.set_optional_bool(true);
|
||||
RunValidUnknownTextFormatTest("ScalarUnknownFields", message);
|
||||
|
||||
message.Clear();
|
||||
message.mutable_nested_message()->set_c(111);
|
||||
RunValidUnknownTextFormatTest("MessageUnknownFields", message);
|
||||
|
||||
message.Clear();
|
||||
message.mutable_optionalgroup()->set_a(321);
|
||||
RunValidUnknownTextFormatTest("GroupUnknownFields", message);
|
||||
|
||||
message.add_repeated_int32(1);
|
||||
message.add_repeated_int32(2);
|
||||
message.add_repeated_int32(3);
|
||||
RunValidUnknownTextFormatTest("RepeatedUnknownFields", message);
|
||||
|
||||
// Any fields
|
||||
RunValidTextFormatTest("AnyField", REQUIRED,
|
||||
R"(
|
||||
optional_any: {
|
||||
[type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3] {
|
||||
optional_int32: 12345
|
||||
}
|
||||
}
|
||||
)");
|
||||
RunValidTextFormatTest("AnyFieldWithRawBytes", REQUIRED,
|
||||
R"(
|
||||
optional_any: {
|
||||
type_url: "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypesProto3"
|
||||
value: "\b\271`"
|
||||
}
|
||||
)");
|
||||
ExpectParseFailure("AnyFieldWithInvalidType", REQUIRED,
|
||||
R"(
|
||||
optional_any: {
|
||||
[type.googleapis.com/unknown] {
|
||||
optional_int32: 12345
|
||||
}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
69
third_party/protobuf/conformance/text_format_conformance_suite.h
vendored
Normal file
69
third_party/protobuf/conformance/text_format_conformance_suite.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// 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 TEXT_FORMAT_CONFORMANCE_SUITE_H_
|
||||
#define TEXT_FORMAT_CONFORMANCE_SUITE_H_
|
||||
|
||||
#include "conformance_test.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
class TextFormatConformanceTestSuite : public ConformanceTestSuite {
|
||||
public:
|
||||
TextFormatConformanceTestSuite();
|
||||
|
||||
private:
|
||||
void RunSuiteImpl();
|
||||
void RunValidTextFormatTest(const string& test_name, ConformanceLevel level,
|
||||
const string& input);
|
||||
void RunValidTextFormatTestProto2(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input);
|
||||
void RunValidTextFormatTestWithMessage(const string& test_name,
|
||||
ConformanceLevel level,
|
||||
const string& input_text,
|
||||
const Message& prototype);
|
||||
void RunValidUnknownTextFormatTest(const string& test_name,
|
||||
const Message& message);
|
||||
void ExpectParseFailure(const string& test_name, ConformanceLevel level,
|
||||
const string& input);
|
||||
bool ParseTextFormatResponse(const conformance::ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting,
|
||||
Message* test_message);
|
||||
bool ParseResponse(const conformance::ConformanceResponse& response,
|
||||
const ConformanceRequestSetting& setting,
|
||||
Message* test_message) override;
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // TEXT_FORMAT_CONFORMANCE_SUITE_H_
|
||||
@@ -6,28 +6,28 @@
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
tests and demonstration applications, are licensed under the following
|
||||
conditions...
|
||||
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||
released under the terms of the MIT License (see below).
|
||||
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
Public Domain/MIT License conditions described here, as they choose.
|
||||
|
||||
The MIT License is about as close to Public Domain as a license can get, and is
|
||||
described in clear, concise terms at:
|
||||
|
||||
http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
@@ -434,7 +434,7 @@ protected:
|
||||
/** Exceptions which the user cannot easily avoid.
|
||||
*
|
||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||
*
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API RuntimeError : public Exception {
|
||||
@@ -445,7 +445,7 @@ public:
|
||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||
*
|
||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||
*
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API LogicError : public Exception {
|
||||
@@ -1570,7 +1570,7 @@ public:
|
||||
- `"rejectDupKeys": false or true`
|
||||
- If true, `parse()` returns false when a key is duplicated within an object.
|
||||
- `"allowSpecialFloats": false or true`
|
||||
- If true, special float values (NaNs and infinities) are allowed
|
||||
- If true, special float values (NaNs and infinities) are allowed
|
||||
and their values are lossfree restorable.
|
||||
|
||||
You can examine 'settings_` yourself
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
// //////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
The JsonCpp library's source code, including accompanying documentation,
|
||||
tests and demonstration applications, are licensed under the following
|
||||
conditions...
|
||||
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||
released under the terms of the MIT License (see below).
|
||||
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
In jurisdictions which recognize Public Domain property, the user of this
|
||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||
Public Domain/MIT License conditions described here, as they choose.
|
||||
|
||||
The MIT License is about as close to Public Domain as a license can get, and is
|
||||
described in clear, concise terms at:
|
||||
|
||||
http://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
@@ -207,7 +207,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
||||
#include <limits>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
||||
#define snprintf sprintf_s
|
||||
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
||||
#define snprintf std::snprintf
|
||||
@@ -4029,7 +4029,7 @@ Value& Path::make(Value& root) const {
|
||||
#define snprintf std::snprintf
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#if defined(__BORLANDC__)
|
||||
#include <float.h>
|
||||
#define isfinite _finite
|
||||
#define snprintf _snprintf
|
||||
@@ -5096,7 +5096,7 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||
std::string cs_str = settings_["commentStyle"].asString();
|
||||
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
||||
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
||||
bool usf = settings_["useSpecialFloats"].asBool();
|
||||
bool usf = settings_["useSpecialFloats"].asBool();
|
||||
unsigned int pre = settings_["precision"].asUInt();
|
||||
CommentStyle::Enum cs = CommentStyle::All;
|
||||
if (cs_str == "All") {
|
||||
|
||||
Reference in New Issue
Block a user