1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file or at 6// https://developers.google.com/open-source/licenses/bsd 7 8syntax = "proto3"; 9 10package conformance; 11 12option java_package = "com.google.protobuf.conformance"; 13option objc_class_prefix = "Conformance"; 14 15// This defines the conformance testing protocol. This protocol exists between 16// the conformance test suite itself and the code being tested. For each test, 17// the suite will send a ConformanceRequest message and expect a 18// ConformanceResponse message. 19// 20// You can either run the tests in two different ways: 21// 22// 1. in-process (using the interface in conformance_test.h). 23// 24// 2. as a sub-process communicating over a pipe. Information about how to 25// do this is in conformance_test_runner.cc. 26// 27// Pros/cons of the two approaches: 28// 29// - running as a sub-process is much simpler for languages other than C/C++. 30// 31// - running as a sub-process may be more tricky in unusual environments like 32// iOS apps, where fork/stdin/stdout are not available. 33 34enum WireFormat { 35 UNSPECIFIED = 0; 36 PROTOBUF = 1; 37 JSON = 2; 38 JSPB = 3; // Only used inside Google. Opensource testees just skip it. 39 TEXT_FORMAT = 4; 40} 41 42enum TestCategory { 43 UNSPECIFIED_TEST = 0; 44 BINARY_TEST = 1; // Test binary wire format. 45 JSON_TEST = 2; // Test json wire format. 46 // Similar to JSON_TEST. However, during parsing json, testee should ignore 47 // unknown fields. This feature is optional. Each implementation can decide 48 // whether to support it. See 49 // https://developers.google.com/protocol-buffers/docs/proto3#json_options 50 // for more detail. 51 JSON_IGNORE_UNKNOWN_PARSING_TEST = 3; 52 // Test jspb wire format. Only used inside Google. Opensource testees just 53 // skip it. 54 JSPB_TEST = 4; 55 // Test text format. For cpp, java and python, testees can already deal with 56 // this type. Testees of other languages can simply skip it. 57 TEXT_FORMAT_TEST = 5; 58} 59 60// Meant to encapsulate all types of tests: successes, skips, failures, etc. 61// Therefore, this may or may not have a failure message. Failure messages 62// may be truncated for our failure lists. 63message TestStatus { 64 string name = 1; 65 string failure_message = 2; 66 // What an actual test name matched to in a failure list. Can be wildcarded or 67 // an exact match without wildcards. 68 string matched_name = 3; 69} 70 71// The conformance runner will request a list of failures as the first request. 72// This will be known by message_type == "conformance.FailureSet", a conformance 73// test should return a serialized FailureSet in protobuf_payload. 74message FailureSet { 75 repeated TestStatus test = 2; 76 reserved 1; 77} 78 79// Represents a single test case's input. The testee should: 80// 81// 1. parse this proto (which should always succeed) 82// 2. parse the protobuf or JSON payload in "payload" (which may fail) 83// 3. if the parse succeeded, serialize the message in the requested format. 84message ConformanceRequest { 85 // The payload (whether protobuf of JSON) is always for a 86 // protobuf_test_messages.proto3.TestAllTypes proto (as defined in 87 // src/google/protobuf/proto3_test_messages.proto). 88 oneof payload { 89 bytes protobuf_payload = 1; 90 string json_payload = 2; 91 // Only used inside Google. Opensource testees just skip it. 92 string jspb_payload = 7; 93 string text_payload = 8; 94 } 95 96 // Which format should the testee serialize its message to? 97 WireFormat requested_output_format = 3; 98 99 // The full name for the test message to use; for the moment, either: 100 // protobuf_test_messages.proto3.TestAllTypesProto3 or 101 // protobuf_test_messages.proto2.TestAllTypesProto2 or 102 // protobuf_test_messages.editions.proto2.TestAllTypesProto2 or 103 // protobuf_test_messages.editions.proto3.TestAllTypesProto3 or 104 // protobuf_test_messages.editions.TestAllTypesEdition2023. 105 string message_type = 4; 106 107 // Each test is given a specific test category. Some category may need 108 // specific support in testee programs. Refer to the definition of 109 // TestCategory for more information. 110 TestCategory test_category = 5; 111 112 // Specify details for how to encode jspb. 113 JspbEncodingConfig jspb_encoding_options = 6; 114 115 // This can be used in json and text format. If true, testee should print 116 // unknown fields instead of ignore. This feature is optional. 117 bool print_unknown_fields = 9; 118} 119 120// Represents a single test case's output. 121message ConformanceResponse { 122 oneof result { 123 // This string should be set to indicate parsing failed. The string can 124 // provide more information about the parse error if it is available. 125 // 126 // Setting this string does not necessarily mean the testee failed the 127 // test. Some of the test cases are intentionally invalid input. 128 string parse_error = 1; 129 130 // If the input was successfully parsed but errors occurred when 131 // serializing it to the requested output format, set the error message in 132 // this field. 133 string serialize_error = 6; 134 135 // This should be set if the test program timed out. The string should 136 // provide more information about what the child process was doing when it 137 // was killed. 138 string timeout_error = 9; 139 140 // This should be set if some other error occurred. This will always 141 // indicate that the test failed. The string can provide more information 142 // about the failure. 143 string runtime_error = 2; 144 145 // If the input was successfully parsed and the requested output was 146 // protobuf, serialize it to protobuf and set it in this field. 147 bytes protobuf_payload = 3; 148 149 // If the input was successfully parsed and the requested output was JSON, 150 // serialize to JSON and set it in this field. 151 string json_payload = 4; 152 153 // For when the testee skipped the test, likely because a certain feature 154 // wasn't supported, like JSON input/output. 155 string skipped = 5; 156 157 // If the input was successfully parsed and the requested output was JSPB, 158 // serialize to JSPB and set it in this field. JSPB is only used inside 159 // Google. Opensource testees can just skip it. 160 string jspb_payload = 7; 161 162 // If the input was successfully parsed and the requested output was 163 // TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field. 164 string text_payload = 8; 165 } 166} 167 168// Encoding options for jspb format. 169message JspbEncodingConfig { 170 // Encode the value field of Any as jspb array if true, otherwise binary. 171 bool use_jspb_array_any_format = 1; 172} 173