57 #include <sys/types.h>
65 #include <google/protobuf/stubs/stringprintf.h>
66 #include "conformance.pb.h"
69 using conformance::ConformanceResponse;
74 #define STRINGIFY(x) #x
75 #define TOSTRING(x) STRINGIFY(x)
76 #define GOOGLE_CHECK_SYSCALL(call) \
78 perror(#call " " __FILE__ ":" TOSTRING(__LINE__)); \
86 conformance::FailureSet *failure_list) {
89 if (!infile.is_open()) {
90 fprintf(
stderr,
"Couldn't open failure list file: %s\n",
filename);
94 for (
string line; getline(infile,
line);) {
96 line.erase(std::remove_if(
line.begin(),
line.end(), ::isspace),
103 failure_list->add_failure(
line);
110 "Usage: conformance-test-runner [options] <test-program>\n");
112 fprintf(
stderr,
"Options:\n");
114 " --failure_list <filename> Use to specify list of tests\n");
116 " that are expected to fail. File\n");
118 " should contain one test name per\n");
120 " line. Use '#' for comments.\n");
122 " --text_format_failure_list <filename> Use to specify list \n");
124 " of tests that are expected to \n");
128 " text_format_conformance_suite. \n");
130 " File should contain one test name \n");
132 " per line. Use '#' for comments.\n");
135 " --enforce_recommended Enforce that recommended test\n");
137 " cases are also passing. Specify\n");
139 " this flag if you want to be\n");
141 " strictly conforming to protobuf\n");
171 "child exited, status=%d", WEXITSTATUS(
status));
172 }
else if (WIFSIGNALED(
status)) {
174 "child killed by signal %d", WTERMSIG(
status));
179 conformance::ConformanceResponse response_obj;
180 response_obj.set_runtime_error(error_msg);
181 response_obj.SerializeToString(
response);
190 int argc,
char *argv[],
const std::vector<ConformanceTestSuite*>& suites) {
191 if (suites.empty()) {
192 fprintf(
stderr,
"No test suites found.\n");
198 std::vector<string> program_args;
199 string failure_list_filename;
200 conformance::FailureSet failure_list;
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 program += argv[
arg];
226 program_args.push_back(argv[
arg]);
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 std::vector<const char *> argv;
299 argv.push_back(executable.get());
303 argv.push_back(
nullptr);
312 <<
": error writing to test program: " << strerror(errno);
326 <<
": error reading from test program: " << strerror(errno);
340 <<
": error reading from test program: " << strerror(errno);