From 37d5f9b4e56814ee66973c4ccbeebae1c3ad456a Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 28 Nov 2016 10:45:00 -0800 Subject: Add debug logging for process termination state. --- test/cpp/qps/json_run_localhost.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'test/cpp') diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index 74e40fbf1a..b36dbcec2f 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -50,6 +50,18 @@ std::string as_string(const T& val) { return out.str(); } +static void LogStatus(int status) { + if (WIFEXITED(status)) { + gpr_log(GPR_INFO, "subprocess exited with status %d", + WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + gpr_log(GPR_INFO, "subprocess terminated with signal %d", + WTERMSIG(status)); + } else { + gpr_log(GPR_INFO, "unknown subprocess status: %d", status); + } +} + int main(int argc, char** argv) { typedef std::unique_ptr SubProcessPtr; std::vector jobs; @@ -75,12 +87,21 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { args.push_back(argv[i]); } - GPR_ASSERT(SubProcess(args).Join() == 0); +gpr_log(GPR_INFO, "calling Join() on driver"); + int status = SubProcess(args).Join(); + if (status != 0) { + LogStatus(status); + GPR_ASSERT(status == 0); + } for (auto it = jobs.begin(); it != jobs.end(); ++it) { (*it)->Interrupt(); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { - (*it)->Join(); +gpr_log(GPR_INFO, "calling Join() on job"); + status = (*it)->Join(); + if (status != 0) { + LogStatus(status); + } } } -- cgit v1.2.3 From c56d3ebd7eadca14322230d97fdddedd9579f41a Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 29 Nov 2016 07:32:39 -0800 Subject: Improve logging. --- test/cpp/qps/json_run_localhost.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'test/cpp') diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index b36dbcec2f..106509ab83 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -50,15 +50,15 @@ std::string as_string(const T& val) { return out.str(); } -static void LogStatus(int status) { +static void LogStatus(int status, const char* label) { if (WIFEXITED(status)) { - gpr_log(GPR_INFO, "subprocess exited with status %d", + gpr_log(GPR_INFO, "%s: subprocess exited with status %d", label, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - gpr_log(GPR_INFO, "subprocess terminated with signal %d", + gpr_log(GPR_INFO, "%s: subprocess terminated with signal %d", label, WTERMSIG(status)); } else { - gpr_log(GPR_INFO, "unknown subprocess status: %d", status); + gpr_log(GPR_INFO, "%s: unknown subprocess status: %d", label, status); } } @@ -87,21 +87,18 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { args.push_back(argv[i]); } -gpr_log(GPR_INFO, "calling Join() on driver"); int status = SubProcess(args).Join(); if (status != 0) { - LogStatus(status); - GPR_ASSERT(status == 0); + LogStatus(status, "driver"); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { (*it)->Interrupt(); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { -gpr_log(GPR_INFO, "calling Join() on job"); status = (*it)->Join(); if (status != 0) { - LogStatus(status); + LogStatus(status, "worker"); } } } -- cgit v1.2.3