Generates a textual description of a given exit code, in the format specified by wait(2).
| 7108 | // Generates a textual description of a given exit code, in the format |
| 7109 | // specified by wait(2). |
| 7110 | static std::string ExitSummary(int exit_code) { |
| 7111 | Message m; |
| 7112 | |
| 7113 | # if GTEST_OS_WINDOWS |
| 7114 | |
| 7115 | m << "Exited with exit status " << exit_code; |
| 7116 | |
| 7117 | # else |
| 7118 | |
| 7119 | if (WIFEXITED(exit_code)) { |
| 7120 | m << "Exited with exit status " << WEXITSTATUS(exit_code); |
| 7121 | } else if (WIFSIGNALED(exit_code)) { |
| 7122 | m << "Terminated by signal " << WTERMSIG(exit_code); |
| 7123 | } |
| 7124 | # ifdef WCOREDUMP |
| 7125 | if (WCOREDUMP(exit_code)) { |
| 7126 | m << " (core dumped)"; |
| 7127 | } |
| 7128 | # endif |
| 7129 | # endif // GTEST_OS_WINDOWS |
| 7130 | |
| 7131 | return m.GetString(); |
| 7132 | } |
| 7133 | |
| 7134 | // Returns true if exit_status describes a process that was terminated |
| 7135 | // by a signal, or exited normally with a nonzero exit code. |