conformance.proto 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. syntax = "proto3";
  31. package conformance;
  32. option java_package = "com.google.protobuf.conformance";
  33. // This defines the conformance testing protocol. This protocol exists between
  34. // the conformance test suite itself and the code being tested. For each test,
  35. // the suite will send a ConformanceRequest message and expect a
  36. // ConformanceResponse message.
  37. //
  38. // You can either run the tests in two different ways:
  39. //
  40. // 1. in-process (using the interface in conformance_test.h).
  41. //
  42. // 2. as a sub-process communicating over a pipe. Information about how to
  43. // do this is in conformance_test_runner.cc.
  44. //
  45. // Pros/cons of the two approaches:
  46. //
  47. // - running as a sub-process is much simpler for languages other than C/C++.
  48. //
  49. // - running as a sub-process may be more tricky in unusual environments like
  50. // iOS apps, where fork/stdin/stdout are not available.
  51. enum WireFormat {
  52. UNSPECIFIED = 0;
  53. PROTOBUF = 1;
  54. JSON = 2;
  55. }
  56. enum TestCategory {
  57. UNSPECIFIED_TEST = 0;
  58. BINARY_TEST = 1; // Test binary wire format.
  59. JSON_TEST = 2; // Test json wire format.
  60. // Similar to JSON_TEST. However, during parsing json, testee should ignore
  61. // unknown fields. This feature is optional. Each implementation can descide
  62. // whether to support it. See
  63. // https://developers.google.com/protocol-buffers/docs/proto3#json_options
  64. // for more detail.
  65. JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
  66. }
  67. // Represents a single test case's input. The testee should:
  68. //
  69. // 1. parse this proto (which should always succeed)
  70. // 2. parse the protobuf or JSON payload in "payload" (which may fail)
  71. // 3. if the parse succeeded, serialize the message in the requested format.
  72. message ConformanceRequest {
  73. // The payload (whether protobuf of JSON) is always for a
  74. // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
  75. // src/google/protobuf/proto3_test_messages.proto).
  76. //
  77. // TODO(haberman): if/when we expand the conformance tests to support proto2,
  78. // we will want to include a field that lets the payload/response be a
  79. // protobuf_test_messages.proto2.TestAllTypes message instead.
  80. oneof payload {
  81. bytes protobuf_payload = 1;
  82. string json_payload = 2;
  83. }
  84. // Which format should the testee serialize its message to?
  85. WireFormat requested_output_format = 3;
  86. // The full name for the test message to use; for the moment, either:
  87. // protobuf_test_messages.proto3.TestAllTypesProto3 or
  88. // protobuf_test_messages.proto2.TestAllTypesProto2.
  89. string message_type = 4;
  90. // Each test is given a specific test category. Some category may need
  91. // spedific support in testee programs. Refer to the defintion of TestCategory
  92. // for more information.
  93. TestCategory test_category = 5;
  94. }
  95. // Represents a single test case's output.
  96. message ConformanceResponse {
  97. oneof result {
  98. // This string should be set to indicate parsing failed. The string can
  99. // provide more information about the parse error if it is available.
  100. //
  101. // Setting this string does not necessarily mean the testee failed the
  102. // test. Some of the test cases are intentionally invalid input.
  103. string parse_error = 1;
  104. // If the input was successfully parsed but errors occurred when
  105. // serializing it to the requested output format, set the error message in
  106. // this field.
  107. string serialize_error = 6;
  108. // This should be set if some other error occurred. This will always
  109. // indicate that the test failed. The string can provide more information
  110. // about the failure.
  111. string runtime_error = 2;
  112. // If the input was successfully parsed and the requested output was
  113. // protobuf, serialize it to protobuf and set it in this field.
  114. bytes protobuf_payload = 3;
  115. // If the input was successfully parsed and the requested output was JSON,
  116. // serialize to JSON and set it in this field.
  117. string json_payload = 4;
  118. // For when the testee skipped the test, likely because a certain feature
  119. // wasn't supported, like JSON input/output.
  120. string skipped = 5;
  121. }
  122. }