blob: a53b5e21d490f75480819f3124e2fa5f977fa61c [file] [log] [blame]
Josh Haberman35a1cc72015-04-01 17:23:48 -07001// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
Josh Haberman35a1cc72015-04-01 17:23:48 -07003//
Joshua Haberman8a4bfd62023-09-08 19:26:10 -07004// 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 Haberman35a1cc72015-04-01 17:23:48 -07007
8syntax = "proto3";
Thomas Van Lenten76c3e692022-10-03 12:39:16 -04009
Josh Haberman35a1cc72015-04-01 17:23:48 -070010package conformance;
Thomas Van Lenten76c3e692022-10-03 12:39:16 -040011
Josh Haberman420f9382015-04-16 12:50:39 -070012option java_package = "com.google.protobuf.conformance";
Thomas Van Lenten76c3e692022-10-03 12:39:16 -040013option objc_class_prefix = "Conformance";
Josh Haberman35a1cc72015-04-01 17:23:48 -070014
15// This defines the conformance testing protocol. This protocol exists between
Josh Haberman4e63b522015-04-14 13:45:39 -070016// 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 Haberman35a1cc72015-04-01 17:23:48 -070019//
Josh Haberman4e63b522015-04-14 13:45:39 -070020// You can either run the tests in two different ways:
Josh Haberman35a1cc72015-04-01 17:23:48 -070021//
Josh Haberman4e63b522015-04-14 13:45:39 -070022// 1. in-process (using the interface in conformance_test.h).
Josh Haberman35a1cc72015-04-01 17:23:48 -070023//
Josh Haberman4e63b522015-04-14 13:45:39 -070024// 2. as a sub-process communicating over a pipe. Information about how to
25// do this is in conformance_test_runner.cc.
Josh Haberman35a1cc72015-04-01 17:23:48 -070026//
Josh Haberman4e63b522015-04-14 13:45:39 -070027// 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 Haberman35a1cc72015-04-01 17:23:48 -070033
Josh Habermanb0500b32015-07-10 16:36:59 -070034enum WireFormat {
35 UNSPECIFIED = 0;
36 PROTOBUF = 1;
37 JSON = 2;
Protobuf Team Bota83da512023-12-28 14:04:53 -080038 JSPB = 3; // Only used inside Google. Opensource testees just skip it.
Yilun Chongcb95a7f2019-01-11 11:40:52 -080039 TEXT_FORMAT = 4;
Josh Habermanb0500b32015-07-10 16:36:59 -070040}
41
Feng Xiao6bbe1972018-08-08 17:00:41 -070042enum TestCategory {
43 UNSPECIFIED_TEST = 0;
44 BINARY_TEST = 1; // Test binary wire format.
Yilun Chong0adb74c2019-01-08 15:06:30 -080045 JSON_TEST = 2; // Test json wire format.
Feng Xiao6bbe1972018-08-08 17:00:41 -070046 // Similar to JSON_TEST. However, during parsing json, testee should ignore
Peter Newmane2cc2de2020-08-10 19:08:25 +010047 // unknown fields. This feature is optional. Each implementation can decide
Feng Xiao6bbe1972018-08-08 17:00:41 -070048 // 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 Bota83da512023-12-28 14:04:53 -080052 // Test jspb wire format. Only used inside Google. Opensource testees just
53 // skip it.
54 JSPB_TEST = 4;
Yilun Chonga2a0afb2019-01-13 17:40:58 -080055 // Test text format. For cpp, java and python, testees can already deal with
Yilun Chongcb95a7f2019-01-11 11:40:52 -080056 // this type. Testees of other languages can simply skip it.
57 TEXT_FORMAT_TEST = 5;
Feng Xiao6bbe1972018-08-08 17:00:41 -070058}
59
Protobuf Team Botecb82142024-07-22 15:14:33 -070060// 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}
67
Yilun Chongcb95a7f2019-01-11 11:40:52 -080068// 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 Chong0adb74c2019-01-08 15:06:30 -080071message FailureSet {
Protobuf Team Botecb82142024-07-22 15:14:33 -070072 repeated TestStatus test = 2;
73 reserved 1;
Yilun Chong0adb74c2019-01-08 15:06:30 -080074}
75
Josh Haberman35a1cc72015-04-01 17:23:48 -070076// 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.
81message ConformanceRequest {
Joshua Habermanf1ce60e2016-12-03 11:51:25 -050082 // 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 Haberman35a1cc72015-04-01 17:23:48 -070085 oneof payload {
86 bytes protobuf_payload = 1;
87 string json_payload = 2;
Protobuf Team Bota83da512023-12-28 14:04:53 -080088 // Only used inside Google. Opensource testees just skip it.
89 string jspb_payload = 7;
Yilun Chongcb95a7f2019-01-11 11:40:52 -080090 string text_payload = 8;
Josh Haberman35a1cc72015-04-01 17:23:48 -070091 }
92
Josh Haberman35a1cc72015-04-01 17:23:48 -070093 // Which format should the testee serialize its message to?
Josh Habermanb0500b32015-07-10 16:36:59 -070094 WireFormat requested_output_format = 3;
Yilun Chong2ad74e12017-06-26 17:46:34 -070095
Thomas Van Lenten9a4692d2017-07-26 16:44:42 -040096 // The full name for the test message to use; for the moment, either:
97 // protobuf_test_messages.proto3.TestAllTypesProto3 or
Protobuf Team Botb4ca4932024-06-18 12:15:38 -070098 // protobuf_test_messages.proto2.TestAllTypesProto2 or
99 // protobuf_test_messages.editions.proto2.TestAllTypesProto2 or
Protobuf Team Bot023e69d2024-05-30 11:03:50 -0700100 // protobuf_test_messages.editions.proto3.TestAllTypesProto3 or
101 // protobuf_test_messages.editions.TestAllTypesEdition2023.
Yilun Chong2ad74e12017-06-26 17:46:34 -0700102 string message_type = 4;
Paul Yang26eeec92018-07-09 14:29:23 -0700103
Feng Xiao6bbe1972018-08-08 17:00:41 -0700104 // Each test is given a specific test category. Some category may need
Mike Kruskal32bea522022-10-06 16:48:39 -0700105 // specific support in testee programs. Refer to the definition of
106 // TestCategory for more information.
Feng Xiao6bbe1972018-08-08 17:00:41 -0700107 TestCategory test_category = 5;
Paul Yangcecba292018-12-14 16:05:03 -0800108
Protobuf Team Bota83da512023-12-28 14:04:53 -0800109 // Specify details for how to encode jspb.
110 JspbEncodingConfig jspb_encoding_options = 6;
111
Hao Nguyen2f864fd2019-03-20 11:45:01 -0700112 // 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 Haberman35a1cc72015-04-01 17:23:48 -0700115}
116
117// Represents a single test case's output.
118message 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 Xiaoe841bac2015-12-11 17:09:20 -0800127 // 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 Kruskal32bea522022-10-06 16:48:39 -0700132 // 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 Haberman35a1cc72015-04-01 17:23:48 -0700137 // 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 Habermanb0500b32015-07-10 16:36:59 -0700149
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 Yangcecba292018-12-14 16:05:03 -0800153
Protobuf Team Bota83da512023-12-28 14:04:53 -0800154 // 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 Chongcb95a7f2019-01-11 11:40:52 -0800159 // 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 Haberman35a1cc72015-04-01 17:23:48 -0700162 }
Protobuf Team Bota83da512023-12-28 14:04:53 -0800163}
Paul Yangcecba292018-12-14 16:05:03 -0800164
Protobuf Team Bota83da512023-12-28 14:04:53 -0800165// Encoding options for jspb format.
166message JspbEncodingConfig {
167 // Encode the value field of Any as jspb array if true, otherwise binary.
168 bool use_jspb_array_any_format = 1;
Paul Yangcecba292018-12-14 16:05:03 -0800169}