59 #include <sys/types.h>
66 #include "conformance.pb.h"
69 using conformance::ConformanceResponse;
75 #define STRINGIFY(x) #x
76 #define TOSTRING(x) STRINGIFY(x)
77 #define CHECK_SYSCALL(call) \
79 perror(#call " " __FILE__ ":" TOSTRING(__LINE__)); \
87 conformance::FailureSet *failure_list) {
88 std::ifstream infile(filename);
90 if (!infile.is_open()) {
91 fprintf(stderr,
"Couldn't open failure list file: %s\n", filename);
95 for (
string line; getline(infile, line);) {
97 line.erase(std::remove_if(line.begin(), line.end(), ::isspace),
101 line = line.substr(0, line.find(
"#"));
104 failure_list->add_failure(line);
111 "Usage: conformance-test-runner [options] <test-program>\n");
112 fprintf(stderr,
"\n");
113 fprintf(stderr,
"Options:\n");
115 " --failure_list <filename> Use to specify list of tests\n");
117 " that are expected to fail. File\n");
119 " should contain one test name per\n");
121 " line. Use '#' for comments.\n");
123 " --text_format_failure_list <filename> Use to specify list \n");
125 " of tests that are expected to \n");
129 " text_format_conformance_suite. \n");
131 " File should contain one test name \n");
133 " per line. Use '#' for comments.\n");
136 " --enforce_recommended Enforce that recommended test\n");
138 " cases are also passing. Specify\n");
140 " this flag if you want to be\n");
142 " strictly conforming to protobuf\n");
158 uint32_t
len = request.size();
170 if (WIFEXITED(status)) {
172 "child exited, status=%d", WEXITSTATUS(status));
173 }
else if (WIFSIGNALED(status)) {
175 "child killed by signal %d", WTERMSIG(status));
180 conformance::ConformanceResponse response_obj;
181 response_obj.set_runtime_error(error_msg);
182 response_obj.SerializeToString(
response);
191 int argc,
char *argv[],
const std::vector<ConformanceTestSuite*>& suites) {
192 if (suites.empty()) {
193 fprintf(stderr,
"No test suites found.\n");
199 string failure_list_filename;
200 conformance::FailureSet failure_list;
202 for (
int arg = 1; arg < argc; ++arg) {
203 if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
205 failure_list_filename = argv[arg];
207 }
else if (strcmp(argv[arg],
"--verbose") == 0) {
208 suite->SetVerbose(
true);
209 }
else if (strcmp(argv[arg],
"--enforce_recommended") == 0) {
210 suite->SetEnforceRecommended(
true);
211 }
else if (argv[arg][0] ==
'-') {
212 bool recognized_flag =
false;
214 if (strcmp(argv[arg], suite->GetFailureListFlagName().c_str()) == 0) {
216 recognized_flag =
true;
219 if (!recognized_flag) {
220 fprintf(stderr,
"Unknown option: %s\n", argv[arg]);
224 if (arg != argc - 1) {
225 fprintf(stderr,
"Too many arguments.\n");
236 suite->RunSuite(&runner, &
output, failure_list_filename, &failure_list);
240 return all_ok ? EXIT_SUCCESS : EXIT_FAILURE;
262 int toproc_pipe_fd[2];
263 int fromproc_pipe_fd[2];
264 if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {
294 std::unique_ptr<char[]> executable(
new char[
executable_.size() + 1]);
298 char *
const argv[] = {executable.get(),
NULL};
306 <<
": error writing to test program: "
314 ssize_t bytes_read = read(fd, (
char*)
buf + ofs,
len);
316 if (bytes_read == 0) {
318 <<
": unexpected EOF from test program";
320 }
else if (bytes_read < 0) {
322 <<
": error reading from test program: "
337 <<
": error reading from test program: "