aboutsummaryrefslogtreecommitdiffhomepage
path: root/conformance/conformance_test_runner.cc
diff options
context:
space:
mode:
Diffstat (limited to 'conformance/conformance_test_runner.cc')
-rw-r--r--conformance/conformance_test_runner.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/conformance/conformance_test_runner.cc b/conformance/conformance_test_runner.cc
index c3b3db22..f2b0dabf 100644
--- a/conformance/conformance_test_runner.cc
+++ b/conformance/conformance_test_runner.cc
@@ -53,6 +53,7 @@
// 3. testee sends 4-byte length M (little endian)
// 4. testee sends M bytes representing a ConformanceResponse proto
+#include <algorithm>
#include <errno.h>
#include <unistd.h>
#include <fstream>
@@ -80,13 +81,19 @@ using std::vector;
class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
public:
ForkPipeRunner(const std::string &executable)
- : executable_(executable), running_(false) {}
+ : running_(false), executable_(executable) {}
- void RunTest(const std::string& request, std::string* response) {
+ virtual ~ForkPipeRunner() {}
+
+ void RunTest(const std::string& test_name,
+ const std::string& request,
+ std::string* response) {
if (!running_) {
SpawnTestProgram();
}
+ current_test_name_ = test_name;
+
uint32_t len = request.size();
CheckedWrite(write_fd_, &len, sizeof(uint32_t));
CheckedWrite(write_fd_, request.c_str(), request.size());
@@ -158,7 +165,9 @@ class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
void CheckedWrite(int fd, const void *buf, size_t len) {
if (write(fd, buf, len) != len) {
- GOOGLE_LOG(FATAL) << "Error writing to test program: " << strerror(errno);
+ GOOGLE_LOG(FATAL) << current_test_name_
+ << ": error writing to test program: "
+ << strerror(errno);
}
}
@@ -168,9 +177,12 @@ class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
if (bytes_read == 0) {
- GOOGLE_LOG(FATAL) << "Unexpected EOF from test program";
+ GOOGLE_LOG(FATAL) << current_test_name_
+ << ": unexpected EOF from test program";
} else if (bytes_read < 0) {
- GOOGLE_LOG(FATAL) << "Error reading from test program: " << strerror(errno);
+ GOOGLE_LOG(FATAL) << current_test_name_
+ << ": error reading from test program: "
+ << strerror(errno);
}
len -= bytes_read;
@@ -182,6 +194,7 @@ class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
int read_fd_;
bool running_;
std::string executable_;
+ std::string current_test_name_;
};
void UsageError() {
@@ -223,7 +236,6 @@ void ParseFailureList(const char *filename, vector<string>* failure_list) {
}
int main(int argc, char *argv[]) {
- int arg = 1;
char *program;
google::protobuf::ConformanceTestSuite suite;