|
|
|
@ -1,33 +1,9 @@ |
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
|
|
// This file defines a protocol for running the conformance test suite
|
|
|
|
|
// in-process. In other words, the suite itself will run in the same process as
|
|
|
|
@ -76,8 +52,7 @@ class ConformanceTestRunner { |
|
|
|
|
//
|
|
|
|
|
// If there is any error in running the test itself, set "runtime_error" in
|
|
|
|
|
// the response.
|
|
|
|
|
virtual void RunTest(const std::string& test_name, |
|
|
|
|
const std::string& input, |
|
|
|
|
virtual void RunTest(const std::string& test_name, const std::string& input, |
|
|
|
|
std::string* output) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -86,7 +61,7 @@ class ConformanceTestRunner { |
|
|
|
|
class ForkPipeRunner : public ConformanceTestRunner { |
|
|
|
|
public: |
|
|
|
|
// Note: Run() doesn't take ownership of the pointers inside suites.
|
|
|
|
|
static int Run(int argc, char *argv[], |
|
|
|
|
static int Run(int argc, char* argv[], |
|
|
|
|
const std::vector<ConformanceTestSuite*>& suites); |
|
|
|
|
|
|
|
|
|
ForkPipeRunner(const std::string& executable, |
|
|
|
@ -102,16 +77,15 @@ class ForkPipeRunner : public ConformanceTestRunner { |
|
|
|
|
|
|
|
|
|
virtual ~ForkPipeRunner() {} |
|
|
|
|
|
|
|
|
|
void RunTest(const std::string& test_name, |
|
|
|
|
const std::string& request, |
|
|
|
|
void RunTest(const std::string& test_name, const std::string& request, |
|
|
|
|
std::string* response); |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
void SpawnTestProgram(); |
|
|
|
|
|
|
|
|
|
void CheckedWrite(int fd, const void *buf, size_t len); |
|
|
|
|
bool TryRead(int fd, void *buf, size_t len); |
|
|
|
|
void CheckedRead(int fd, void *buf, size_t len); |
|
|
|
|
void CheckedWrite(int fd, const void* buf, size_t len); |
|
|
|
|
bool TryRead(int fd, void* buf, size_t len); |
|
|
|
|
void CheckedRead(int fd, void* buf, size_t len); |
|
|
|
|
|
|
|
|
|
int write_fd_; |
|
|
|
|
int read_fd_; |
|
|
|
@ -169,9 +143,7 @@ class ConformanceTestSuite { |
|
|
|
|
// can enable this if it wants to be strictly conforming to protobuf spec.
|
|
|
|
|
// See the comments about ConformanceLevel below to learn more about the
|
|
|
|
|
// difference between REQUIRED and RECOMMENDED test cases.
|
|
|
|
|
void SetEnforceRecommended(bool value) { |
|
|
|
|
enforce_recommended_ = value; |
|
|
|
|
} |
|
|
|
|
void SetEnforceRecommended(bool value) { enforce_recommended_ = value; } |
|
|
|
|
|
|
|
|
|
// Gets the flag name to the failure list file.
|
|
|
|
|
// By default, this would return --failure_list
|
|
|
|
@ -182,9 +154,7 @@ class ConformanceTestSuite { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Sets the path of the output directory.
|
|
|
|
|
void SetOutputDir(const char* output_dir) { |
|
|
|
|
output_dir_ = output_dir; |
|
|
|
|
} |
|
|
|
|
void SetOutputDir(const char* output_dir) { output_dir_ = output_dir; } |
|
|
|
|
|
|
|
|
|
// Run all the conformance tests against the given test runner.
|
|
|
|
|
// Test output will be stored in "output".
|
|
|
|
@ -234,9 +204,7 @@ class ConformanceTestSuite { |
|
|
|
|
return request_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const ConformanceLevel GetLevel() const { |
|
|
|
|
return level_; |
|
|
|
|
} |
|
|
|
|
const ConformanceLevel GetLevel() const { return level_; } |
|
|
|
|
|
|
|
|
|
std::string ConformanceLevelToString(ConformanceLevel level) const; |
|
|
|
|
|
|
|
|
@ -267,10 +235,9 @@ class ConformanceTestSuite { |
|
|
|
|
|
|
|
|
|
// Parse payload in the response to the given message. Returns true on
|
|
|
|
|
// success.
|
|
|
|
|
virtual bool ParseResponse( |
|
|
|
|
const conformance::ConformanceResponse& response, |
|
|
|
|
const ConformanceRequestSetting& setting, |
|
|
|
|
Message* test_message) = 0; |
|
|
|
|
virtual bool ParseResponse(const conformance::ConformanceResponse& response, |
|
|
|
|
const ConformanceRequestSetting& setting, |
|
|
|
|
Message* test_message) = 0; |
|
|
|
|
|
|
|
|
|
void VerifyResponse(const ConformanceRequestSetting& setting, |
|
|
|
|
const std::string& equivalent_wire_format, |
|
|
|
|