Called in the parent process only. Reads the result code of the death test child process via a pipe, interprets it to set the outcome_ member, and closes read_fd_. Outputs diagnostics and terminates in case of unexpected codes.
| 6917 | // member, and closes read_fd_. Outputs diagnostics and terminates in |
| 6918 | // case of unexpected codes. |
| 6919 | void DeathTestImpl::ReadAndInterpretStatusByte() { |
| 6920 | char flag; |
| 6921 | int bytes_read; |
| 6922 | |
| 6923 | // The read() here blocks until data is available (signifying the |
| 6924 | // failure of the death test) or until the pipe is closed (signifying |
| 6925 | // its success), so it's okay to call this in the parent before |
| 6926 | // the child process has exited. |
| 6927 | do { |
| 6928 | bytes_read = posix::Read(read_fd(), &flag, 1); |
| 6929 | } while (bytes_read == -1 && errno == EINTR); |
| 6930 | |
| 6931 | if (bytes_read == 0) { |
| 6932 | set_outcome(DIED); |
| 6933 | } else if (bytes_read == 1) { |
| 6934 | switch (flag) { |
| 6935 | case kDeathTestReturned: |
| 6936 | set_outcome(RETURNED); |
| 6937 | break; |
| 6938 | case kDeathTestThrew: |
| 6939 | set_outcome(THREW); |
| 6940 | break; |
| 6941 | case kDeathTestLived: |
| 6942 | set_outcome(LIVED); |
| 6943 | break; |
| 6944 | case kDeathTestInternalError: |
| 6945 | FailFromInternalError(read_fd()); // Does not return. |
| 6946 | break; |
| 6947 | default: |
| 6948 | GTEST_LOG_(FATAL) << "Death test child process reported " |
| 6949 | << "unexpected status byte (" |
| 6950 | << static_cast<unsigned int>(flag) << ")"; |
| 6951 | } |
| 6952 | } else { |
| 6953 | GTEST_LOG_(FATAL) << "Read from death test child process failed: " |
| 6954 | << GetLastErrnoDescription(); |
| 6955 | } |
| 6956 | GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); |
| 6957 | set_read_fd(-1); |
| 6958 | } |
| 6959 | |
| 6960 | // Signals that the death test code which should have exited, didn't. |
| 6961 | // Should be called only in a death test child process. |
nothing calls this directly
no test coverage detected