Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 3 | // |
Joshua Haberman | 8a4bfd6 | 2023-09-08 19:26:10 -0700 | [diff] [blame] | 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 |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 7 | |
| 8 | syntax = "proto3"; |
Thomas Van Lenten | 76c3e69 | 2022-10-03 12:39:16 -0400 | [diff] [blame] | 9 | |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 10 | package conformance; |
Thomas Van Lenten | 76c3e69 | 2022-10-03 12:39:16 -0400 | [diff] [blame] | 11 | |
Josh Haberman | 420f938 | 2015-04-16 12:50:39 -0700 | [diff] [blame] | 12 | option java_package = "com.google.protobuf.conformance"; |
Thomas Van Lenten | 76c3e69 | 2022-10-03 12:39:16 -0400 | [diff] [blame] | 13 | option objc_class_prefix = "Conformance"; |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 14 | |
| 15 | // This defines the conformance testing protocol. This protocol exists between |
Josh Haberman | 4e63b52 | 2015-04-14 13:45:39 -0700 | [diff] [blame] | 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. |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 19 | // |
Josh Haberman | 4e63b52 | 2015-04-14 13:45:39 -0700 | [diff] [blame] | 20 | // You can either run the tests in two different ways: |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 21 | // |
Josh Haberman | 4e63b52 | 2015-04-14 13:45:39 -0700 | [diff] [blame] | 22 | // 1. in-process (using the interface in conformance_test.h). |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 23 | // |
Josh Haberman | 4e63b52 | 2015-04-14 13:45:39 -0700 | [diff] [blame] | 24 | // 2. as a sub-process communicating over a pipe. Information about how to |
| 25 | // do this is in conformance_test_runner.cc. |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 26 | // |
Josh Haberman | 4e63b52 | 2015-04-14 13:45:39 -0700 | [diff] [blame] | 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. |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 33 | |
Josh Haberman | b0500b3 | 2015-07-10 16:36:59 -0700 | [diff] [blame] | 34 | enum WireFormat { |
| 35 | UNSPECIFIED = 0; |
| 36 | PROTOBUF = 1; |
| 37 | JSON = 2; |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 38 | JSPB = 3; // Only used inside Google. Opensource testees just skip it. |
Yilun Chong | cb95a7f | 2019-01-11 11:40:52 -0800 | [diff] [blame] | 39 | TEXT_FORMAT = 4; |
Josh Haberman | b0500b3 | 2015-07-10 16:36:59 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 42 | enum TestCategory { |
| 43 | UNSPECIFIED_TEST = 0; |
| 44 | BINARY_TEST = 1; // Test binary wire format. |
Yilun Chong | 0adb74c | 2019-01-08 15:06:30 -0800 | [diff] [blame] | 45 | JSON_TEST = 2; // Test json wire format. |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 46 | // Similar to JSON_TEST. However, during parsing json, testee should ignore |
Peter Newman | e2cc2de | 2020-08-10 19:08:25 +0100 | [diff] [blame] | 47 | // unknown fields. This feature is optional. Each implementation can decide |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 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; |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 52 | // Test jspb wire format. Only used inside Google. Opensource testees just |
| 53 | // skip it. |
| 54 | JSPB_TEST = 4; |
Yilun Chong | a2a0afb | 2019-01-13 17:40:58 -0800 | [diff] [blame] | 55 | // Test text format. For cpp, java and python, testees can already deal with |
Yilun Chong | cb95a7f | 2019-01-11 11:40:52 -0800 | [diff] [blame] | 56 | // this type. Testees of other languages can simply skip it. |
| 57 | TEXT_FORMAT_TEST = 5; |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Protobuf Team Bot | ecb8214 | 2024-07-22 15:14:33 -0700 | [diff] [blame] | 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. |
| 63 | message TestStatus { |
| 64 | string name = 1; |
| 65 | string failure_message = 2; |
| 66 | } |
| 67 | |
Yilun Chong | cb95a7f | 2019-01-11 11:40:52 -0800 | [diff] [blame] | 68 | // The conformance runner will request a list of failures as the first request. |
| 69 | // This will be known by message_type == "conformance.FailureSet", a conformance |
| 70 | // test should return a serialized FailureSet in protobuf_payload. |
Yilun Chong | 0adb74c | 2019-01-08 15:06:30 -0800 | [diff] [blame] | 71 | message FailureSet { |
Protobuf Team Bot | ecb8214 | 2024-07-22 15:14:33 -0700 | [diff] [blame] | 72 | repeated TestStatus test = 2; |
| 73 | reserved 1; |
Yilun Chong | 0adb74c | 2019-01-08 15:06:30 -0800 | [diff] [blame] | 74 | } |
| 75 | |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 76 | // Represents a single test case's input. The testee should: |
| 77 | // |
| 78 | // 1. parse this proto (which should always succeed) |
| 79 | // 2. parse the protobuf or JSON payload in "payload" (which may fail) |
| 80 | // 3. if the parse succeeded, serialize the message in the requested format. |
| 81 | message ConformanceRequest { |
Joshua Haberman | f1ce60e | 2016-12-03 11:51:25 -0500 | [diff] [blame] | 82 | // The payload (whether protobuf of JSON) is always for a |
| 83 | // protobuf_test_messages.proto3.TestAllTypes proto (as defined in |
| 84 | // src/google/protobuf/proto3_test_messages.proto). |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 85 | oneof payload { |
| 86 | bytes protobuf_payload = 1; |
| 87 | string json_payload = 2; |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 88 | // Only used inside Google. Opensource testees just skip it. |
| 89 | string jspb_payload = 7; |
Yilun Chong | cb95a7f | 2019-01-11 11:40:52 -0800 | [diff] [blame] | 90 | string text_payload = 8; |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 93 | // Which format should the testee serialize its message to? |
Josh Haberman | b0500b3 | 2015-07-10 16:36:59 -0700 | [diff] [blame] | 94 | WireFormat requested_output_format = 3; |
Yilun Chong | 2ad74e1 | 2017-06-26 17:46:34 -0700 | [diff] [blame] | 95 | |
Thomas Van Lenten | 9a4692d | 2017-07-26 16:44:42 -0400 | [diff] [blame] | 96 | // The full name for the test message to use; for the moment, either: |
| 97 | // protobuf_test_messages.proto3.TestAllTypesProto3 or |
Protobuf Team Bot | b4ca493 | 2024-06-18 12:15:38 -0700 | [diff] [blame] | 98 | // protobuf_test_messages.proto2.TestAllTypesProto2 or |
| 99 | // protobuf_test_messages.editions.proto2.TestAllTypesProto2 or |
Protobuf Team Bot | 023e69d | 2024-05-30 11:03:50 -0700 | [diff] [blame] | 100 | // protobuf_test_messages.editions.proto3.TestAllTypesProto3 or |
| 101 | // protobuf_test_messages.editions.TestAllTypesEdition2023. |
Yilun Chong | 2ad74e1 | 2017-06-26 17:46:34 -0700 | [diff] [blame] | 102 | string message_type = 4; |
Paul Yang | 26eeec9 | 2018-07-09 14:29:23 -0700 | [diff] [blame] | 103 | |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 104 | // Each test is given a specific test category. Some category may need |
Mike Kruskal | 32bea52 | 2022-10-06 16:48:39 -0700 | [diff] [blame] | 105 | // specific support in testee programs. Refer to the definition of |
| 106 | // TestCategory for more information. |
Feng Xiao | 6bbe197 | 2018-08-08 17:00:41 -0700 | [diff] [blame] | 107 | TestCategory test_category = 5; |
Paul Yang | cecba29 | 2018-12-14 16:05:03 -0800 | [diff] [blame] | 108 | |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 109 | // Specify details for how to encode jspb. |
| 110 | JspbEncodingConfig jspb_encoding_options = 6; |
| 111 | |
Hao Nguyen | 2f864fd | 2019-03-20 11:45:01 -0700 | [diff] [blame] | 112 | // This can be used in json and text format. If true, testee should print |
| 113 | // unknown fields instead of ignore. This feature is optional. |
| 114 | bool print_unknown_fields = 9; |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | // Represents a single test case's output. |
| 118 | message ConformanceResponse { |
| 119 | oneof result { |
| 120 | // This string should be set to indicate parsing failed. The string can |
| 121 | // provide more information about the parse error if it is available. |
| 122 | // |
| 123 | // Setting this string does not necessarily mean the testee failed the |
| 124 | // test. Some of the test cases are intentionally invalid input. |
| 125 | string parse_error = 1; |
| 126 | |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 127 | // If the input was successfully parsed but errors occurred when |
| 128 | // serializing it to the requested output format, set the error message in |
| 129 | // this field. |
| 130 | string serialize_error = 6; |
| 131 | |
Mike Kruskal | 32bea52 | 2022-10-06 16:48:39 -0700 | [diff] [blame] | 132 | // This should be set if the test program timed out. The string should |
| 133 | // provide more information about what the child process was doing when it |
| 134 | // was killed. |
| 135 | string timeout_error = 9; |
| 136 | |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 137 | // This should be set if some other error occurred. This will always |
| 138 | // indicate that the test failed. The string can provide more information |
| 139 | // about the failure. |
| 140 | string runtime_error = 2; |
| 141 | |
| 142 | // If the input was successfully parsed and the requested output was |
| 143 | // protobuf, serialize it to protobuf and set it in this field. |
| 144 | bytes protobuf_payload = 3; |
| 145 | |
| 146 | // If the input was successfully parsed and the requested output was JSON, |
| 147 | // serialize to JSON and set it in this field. |
| 148 | string json_payload = 4; |
Josh Haberman | b0500b3 | 2015-07-10 16:36:59 -0700 | [diff] [blame] | 149 | |
| 150 | // For when the testee skipped the test, likely because a certain feature |
| 151 | // wasn't supported, like JSON input/output. |
| 152 | string skipped = 5; |
Paul Yang | cecba29 | 2018-12-14 16:05:03 -0800 | [diff] [blame] | 153 | |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 154 | // If the input was successfully parsed and the requested output was JSPB, |
| 155 | // serialize to JSPB and set it in this field. JSPB is only used inside |
| 156 | // Google. Opensource testees can just skip it. |
| 157 | string jspb_payload = 7; |
| 158 | |
Yilun Chong | cb95a7f | 2019-01-11 11:40:52 -0800 | [diff] [blame] | 159 | // If the input was successfully parsed and the requested output was |
| 160 | // TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field. |
| 161 | string text_payload = 8; |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 162 | } |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 163 | } |
Paul Yang | cecba29 | 2018-12-14 16:05:03 -0800 | [diff] [blame] | 164 | |
Protobuf Team Bot | a83da51 | 2023-12-28 14:04:53 -0800 | [diff] [blame] | 165 | // Encoding options for jspb format. |
| 166 | message JspbEncodingConfig { |
| 167 | // Encode the value field of Any as jspb array if true, otherwise binary. |
| 168 | bool use_jspb_array_any_format = 1; |
Paul Yang | cecba29 | 2018-12-14 16:05:03 -0800 | [diff] [blame] | 169 | } |