Debian Codegraph @

extra/protobuf/protobuf-24.4/conformance/conformance.proto

raw
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 syntax = "proto3";
32
33 package conformance;
34
35 option java_package = "com.google.protobuf.conformance";
36 option objc_class_prefix = "Conformance";
37
38 // This defines the conformance testing protocol. This protocol exists between
39 // the conformance test suite itself and the code being tested. For each test,
40 // the suite will send a ConformanceRequest message and expect a
41 // ConformanceResponse message.
42 //
43 // You can either run the tests in two different ways:
44 //
45 // 1. in-process (using the interface in conformance_test.h).
46 //
47 // 2. as a sub-process communicating over a pipe. Information about how to
48 // do this is in conformance_test_runner.cc.
49 //
50 // Pros/cons of the two approaches:
51 //
52 // - running as a sub-process is much simpler for languages other than C/C++.
53 //
54 // - running as a sub-process may be more tricky in unusual environments like
55 // iOS apps, where fork/stdin/stdout are not available.
56
57 enum WireFormat {
58 UNSPECIFIED = 0;
59 PROTOBUF = 1;
60 JSON = 2;
61 JSPB = 3; // Only used inside Google. Opensource testees just skip it.
62 TEXT_FORMAT = 4;
63 }
64
65 enum TestCategory {
66 UNSPECIFIED_TEST = 0;
67 BINARY_TEST = 1; // Test binary wire format.
68 JSON_TEST = 2; // Test json wire format.
69 // Similar to JSON_TEST. However, during parsing json, testee should ignore
70 // unknown fields. This feature is optional. Each implementation can decide
71 // whether to support it. See
72 // https://developers.google.com/protocol-buffers/docs/proto3#json_options
73 // for more detail.
74 JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
75 // Test jspb wire format. Only used inside Google. Opensource testees just
76 // skip it.
77 JSPB_TEST = 4;
78 // Test text format. For cpp, java and python, testees can already deal with
79 // this type. Testees of other languages can simply skip it.
80 TEXT_FORMAT_TEST = 5;
81 }
82
83 // The conformance runner will request a list of failures as the first request.
84 // This will be known by message_type == "conformance.FailureSet", a conformance
85 // test should return a serialized FailureSet in protobuf_payload.
86 message FailureSet {
87 repeated string failure = 1;
88 }
89
90 // Represents a single test case's input. The testee should:
91 //
92 // 1. parse this proto (which should always succeed)
93 // 2. parse the protobuf or JSON payload in "payload" (which may fail)
94 // 3. if the parse succeeded, serialize the message in the requested format.
95 message ConformanceRequest {
96 // The payload (whether protobuf of JSON) is always for a
97 // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
98 // src/google/protobuf/proto3_test_messages.proto).
99 oneof payload {
100 bytes protobuf_payload = 1;
101 string json_payload = 2;
102 // Only used inside Google. Opensource testees just skip it.
103 string jspb_payload = 7;
104 string text_payload = 8;
105 }
106
107 // Which format should the testee serialize its message to?
108 WireFormat requested_output_format = 3;
109
110 // The full name for the test message to use; for the moment, either:
111 // protobuf_test_messages.proto3.TestAllTypesProto3 or
112 // protobuf_test_messages.google.protobuf.TestAllTypesProto2.
113 string message_type = 4;
114
115 // Each test is given a specific test category. Some category may need
116 // specific support in testee programs. Refer to the definition of
117 // TestCategory for more information.
118 TestCategory test_category = 5;
119
120 // Specify details for how to encode jspb.
121 JspbEncodingConfig jspb_encoding_options = 6;
122
123 // This can be used in json and text format. If true, testee should print
124 // unknown fields instead of ignore. This feature is optional.
125 bool print_unknown_fields = 9;
126 }
127
128 // Represents a single test case's output.
129 message ConformanceResponse {
130 oneof result {
131 // This string should be set to indicate parsing failed. The string can
132 // provide more information about the parse error if it is available.
133 //
134 // Setting this string does not necessarily mean the testee failed the
135 // test. Some of the test cases are intentionally invalid input.
136 string parse_error = 1;
137
138 // If the input was successfully parsed but errors occurred when
139 // serializing it to the requested output format, set the error message in
140 // this field.
141 string serialize_error = 6;
142
143 // This should be set if the test program timed out. The string should
144 // provide more information about what the child process was doing when it
145 // was killed.
146 string timeout_error = 9;
147
148 // This should be set if some other error occurred. This will always
149 // indicate that the test failed. The string can provide more information
150 // about the failure.
151 string runtime_error = 2;
152
153 // If the input was successfully parsed and the requested output was
154 // protobuf, serialize it to protobuf and set it in this field.
155 bytes protobuf_payload = 3;
156
157 // If the input was successfully parsed and the requested output was JSON,
158 // serialize to JSON and set it in this field.
159 string json_payload = 4;
160
161 // For when the testee skipped the test, likely because a certain feature
162 // wasn't supported, like JSON input/output.
163 string skipped = 5;
164
165 // If the input was successfully parsed and the requested output was JSPB,
166 // serialize to JSPB and set it in this field. JSPB is only used inside
167 // Google. Opensource testees can just skip it.
168 string jspb_payload = 7;
169
170 // If the input was successfully parsed and the requested output was
171 // TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.
172 string text_payload = 8;
173 }
174 }
175
176 // Encoding options for jspb format.
177 message JspbEncodingConfig {
178 // Encode the value field of Any as jspb array if true, otherwise binary.
179 bool use_jspb_array_any_format = 1;
180 }