conformance.proto 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. // Represents a single test case's input. The testee should:
  57. //
  58. // 1. parse this proto (which should always succeed)
  59. // 2. parse the protobuf or JSON payload in "payload" (which may fail)
  60. // 3. if the parse succeeded, serialize the message in the requested format.
  61. message ConformanceRequest {
  62. // The payload (whether protobuf of JSON) is always for a
  63. // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
  64. // src/google/protobuf/proto3_test_messages.proto).
  65. //
  66. // TODO(haberman): if/when we expand the conformance tests to support proto2,
  67. // we will want to include a field that lets the payload/response be a
  68. // protobuf_test_messages.proto2.TestAllTypes message instead.
  69. oneof payload {
  70. bytes protobuf_payload = 1;
  71. string json_payload = 2;
  72. }
  73. // Which format should the testee serialize its message to?
  74. WireFormat requested_output_format = 3;
  75. // The full name for the test message to use; for the moment, either:
  76. // protobuf_test_messages.proto3.TestAllTypesProto3 or
  77. // protobuf_test_messages.proto2.TestAllTypesProto2.
  78. string message_type = 4;
  79. }
  80. // Represents a single test case's output.
  81. message ConformanceResponse {
  82. oneof result {
  83. // This string should be set to indicate parsing failed. The string can
  84. // provide more information about the parse error if it is available.
  85. //
  86. // Setting this string does not necessarily mean the testee failed the
  87. // test. Some of the test cases are intentionally invalid input.
  88. string parse_error = 1;
  89. // If the input was successfully parsed but errors occurred when
  90. // serializing it to the requested output format, set the error message in
  91. // this field.
  92. string serialize_error = 6;
  93. // This should be set if some other error occurred. This will always
  94. // indicate that the test failed. The string can provide more information
  95. // about the failure.
  96. string runtime_error = 2;
  97. // If the input was successfully parsed and the requested output was
  98. // protobuf, serialize it to protobuf and set it in this field.
  99. bytes protobuf_payload = 3;
  100. // If the input was successfully parsed and the requested output was JSON,
  101. // serialize to JSON and set it in this field.
  102. string json_payload = 4;
  103. // For when the testee skipped the test, likely because a certain feature
  104. // wasn't supported, like JSON input/output.
  105. string skipped = 5;
  106. }
  107. }