Routine for aborting the program which is safe to call from an exec-style death test child process, in which case the error message is propagated back to the parent process. Otherwise, the message is simply printed to stderr. In either case, the program then exits with status 1.
| 7880 | // message is simply printed to stderr. In either case, the program |
| 7881 | // then exits with status 1. |
| 7882 | static void DeathTestAbort(const std::string& message) { |
| 7883 | // On a POSIX system, this function may be called from a threadsafe-style |
| 7884 | // death test child process, which operates on a very small stack. Use |
| 7885 | // the heap for any additional non-minuscule memory requirements. |
| 7886 | const InternalRunDeathTestFlag* const flag = |
| 7887 | GetUnitTestImpl()->internal_run_death_test_flag(); |
| 7888 | if (flag != nullptr) { |
| 7889 | FILE* parent = posix::FDOpen(flag->write_fd(), "w"); |
| 7890 | fputc(kDeathTestInternalError, parent); |
| 7891 | fprintf(parent, "%s", message.c_str()); |
| 7892 | fflush(parent); |
| 7893 | _exit(1); |
| 7894 | } else { |
| 7895 | fprintf(stderr, "%s", message.c_str()); |
| 7896 | fflush(stderr); |
| 7897 | posix::Abort(); |
| 7898 | } |
| 7899 | } |
| 7900 | |
| 7901 | // A replacement for CHECK that calls DeathTestAbort if the assertion |
| 7902 | // fails. |
no test coverage detected