conformance.proto 7.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
// 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.

syntax = "proto3";
package conformance;
33
option java_package = "com.google.protobuf.conformance";
34 35

// This defines the conformance testing protocol.  This protocol exists between
36 37 38
// the conformance test suite itself and the code being tested.  For each test,
// the suite will send a ConformanceRequest message and expect a
// ConformanceResponse message.
39
//
40
// You can either run the tests in two different ways:
41
//
42
//   1. in-process (using the interface in conformance_test.h).
43
//
44 45
//   2. as a sub-process communicating over a pipe.  Information about how to
//      do this is in conformance_test_runner.cc.
46
//
47 48 49 50 51 52
// Pros/cons of the two approaches:
//
//   - running as a sub-process is much simpler for languages other than C/C++.
//
//   - running as a sub-process may be more tricky in unusual environments like
//     iOS apps, where fork/stdin/stdout are not available.
53

54 55 56 57
enum WireFormat {
  UNSPECIFIED = 0;
  PROTOBUF = 1;
  JSON = 2;
58
  JSPB = 3;  // Google internal only. Opensource testees just skip it.
59
  TEXT_FORMAT = 4;
60 61
}

62 63 64
enum TestCategory {
  UNSPECIFIED_TEST = 0;
  BINARY_TEST = 1;  // Test binary wire format.
65
  JSON_TEST = 2;    // Test json wire format.
66 67 68 69 70 71
  // 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;
72 73
  // Test jspb wire format. Google internal only. Opensource testees just skip it.
  JSPB_TEST = 4;
74
  // Test text format. For cpp, java and python, testees can already deal with
75 76
  // this type. Testees of other languages can simply skip it.
  TEXT_FORMAT_TEST = 5;
77 78
}

79 80 81
// 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.
82 83 84 85
message FailureSet {
  repeated string failure = 1;
}

86 87 88 89 90 91
// Represents a single test case's input.  The testee should:
//
//   1. parse this proto (which should always succeed)
//   2. parse the protobuf or JSON payload in "payload" (which may fail)
//   3. if the parse succeeded, serialize the message in the requested format.
message ConformanceRequest {
92 93 94 95 96 97 98
  // The payload (whether protobuf of JSON) is always for a
  // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
  // src/google/protobuf/proto3_test_messages.proto).
  //
  // TODO(haberman): if/when we expand the conformance tests to support proto2,
  // we will want to include a field that lets the payload/response be a
  // protobuf_test_messages.proto2.TestAllTypes message instead.
99 100 101
  oneof payload {
    bytes protobuf_payload = 1;
    string json_payload = 2;
102 103
    // Google internal only.  Opensource testees just skip it.
    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;
Yilun Chong's avatar
Yilun Chong committed
109

110 111 112
  // The full name for the test message to use; for the moment, either:
  // protobuf_test_messages.proto3.TestAllTypesProto3 or
  // protobuf_test_messages.proto2.TestAllTypesProto2.
Yilun Chong's avatar
Yilun Chong committed
113
  string message_type = 4;
114

115 116 117 118
  // 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;
119 120 121

  // Specify details for how to encode jspb.
  JspbEncodingConfig jspb_encoding_options = 6;
Hao Nguyen's avatar
Hao Nguyen committed
122 123 124 125

  // 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;
126 127 128 129 130 131 132 133 134 135 136 137
}

// Represents a single test case's output.
message ConformanceResponse {
  oneof result {
    // This string should be set to indicate parsing failed.  The string can
    // provide more information about the parse error if it is available.
    //
    // Setting this string does not necessarily mean the testee failed the
    // test.  Some of the test cases are intentionally invalid input.
    string parse_error = 1;

138 139 140 141 142
    // If the input was successfully parsed but errors occurred when
    // serializing it to the requested output format, set the error message in
    // this field.
    string serialize_error = 6;

143 144 145 146 147 148 149 150 151 152 153 154
    // This should be set if some other error occurred.  This will always
    // indicate that the test failed.  The string can provide more information
    // about the failure.
    string runtime_error = 2;

    // If the input was successfully parsed and the requested output was
    // protobuf, serialize it to protobuf and set it in this field.
    bytes protobuf_payload = 3;

    // If the input was successfully parsed and the requested output was JSON,
    // serialize to JSON and set it in this field.
    string json_payload = 4;
155 156 157 158

    // For when the testee skipped the test, likely because a certain feature
    // wasn't supported, like JSON input/output.
    string skipped = 5;
159 160 161 162 163

    // 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;
164 165 166 167

    // 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;
168 169
  }
}
170 171 172 173 174 175

// 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;
}
176