|
64 | 64 | #include "mysqlrouter/rest_client.h"
|
65 | 65 | #include "mysqlrouter/utils.h"
|
66 | 66 | #include "process_launcher.h"
|
| 67 | +#include "process_wrapper.h" |
67 | 68 | #include "random_generator.h"
|
68 | 69 |
|
69 | 70 | #ifdef USE_STD_REGEX
|
@@ -648,22 +649,31 @@ void ProcessManager::terminate_all_still_alive() {
|
648 | 649 | }
|
649 | 650 | }
|
650 | 651 |
|
| 652 | +std::string ProcessManager::dump(ProcessWrapper &proc) { |
| 653 | + std::stringstream ss; |
| 654 | + |
| 655 | + ss << "# Process: (pid=" << proc.get_pid() << ")\n" |
| 656 | + << proc.get_command_line() << "\n\n"; |
| 657 | + |
| 658 | + auto output = proc.get_current_output(); |
| 659 | + if (!output.empty()) { |
| 660 | + ss << "## Console output:\n\n" << output << "\n"; |
| 661 | + } |
| 662 | + |
| 663 | + auto log_content = proc.get_logfile_content("", "", 500); |
| 664 | + if (!log_content.empty()) { |
| 665 | + ss << "## Log content:\n\n" << log_content << "\n"; |
| 666 | + } |
| 667 | + |
| 668 | + return ss.str(); |
| 669 | +} |
| 670 | + |
651 | 671 | void ProcessManager::dump_all() {
|
652 | 672 | std::stringstream ss;
|
653 | 673 | for (const auto &proc_and_exit_code : processes_) {
|
654 | 674 | const auto &proc = std::get<0>(proc_and_exit_code);
|
655 |
| - ss << "# Process: (pid=" << proc->get_pid() << ")\n" |
656 |
| - << proc->get_command_line() << "\n\n"; |
657 | 675 |
|
658 |
| - auto output = proc->get_current_output(); |
659 |
| - if (!output.empty()) { |
660 |
| - ss << "## Console output:\n\n" << output << "\n"; |
661 |
| - } |
662 |
| - |
663 |
| - auto log_content = proc->get_logfile_content("", "", 500); |
664 |
| - if (!log_content.empty()) { |
665 |
| - ss << "## Log content:\n\n" << log_content << "\n"; |
666 |
| - } |
| 676 | + ss << dump(*proc); |
667 | 677 | }
|
668 | 678 |
|
669 | 679 | FAIL() << ss.str();
|
@@ -736,7 +746,9 @@ void ProcessManager::check_exit_code(ProcessWrapper &process,
|
736 | 746 | if (dump_res) std::cerr << *dump_res;
|
737 | 747 |
|
738 | 748 | ASSERT_EQ(expected_exit_status, result)
|
739 |
| - << "Process " << process.get_pid() << " terminated with " << result; |
| 749 | + << "Process " << process.get_pid() << " terminated with " << result |
| 750 | + << "\n" |
| 751 | + << dump(process); |
740 | 752 | } else if (auto sig = result.stopped()) {
|
741 | 753 | ASSERT_EQ(expected_exit_status, result)
|
742 | 754 | << "Process " << process.get_pid() << " stopped with " << result;
|
|
0 commit comments