MCPcopy Create free account
hub / github.com/apache/singa / Abort

Method Abort

test/gtest/gtest-all.cc:6964–6982  ·  view source on GitHub ↗

Signals that the death test code which should have exited, didn't. Should be called only in a death test child process. Writes a status byte to the child's status file descriptor, then calls _exit(1).

Source from the content-addressed store, hash-verified

6962// Writes a status byte to the child's status file descriptor, then
6963// calls _exit(1).
6964void DeathTestImpl::Abort(AbortReason reason) {
6965 // The parent process considers the death test to be a failure if
6966 // it finds any data in our pipe. So, here we write a single flag byte
6967 // to the pipe, then exit.
6968 const char status_ch =
6969 reason == TEST_DID_NOT_DIE ? kDeathTestLived :
6970 reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;
6971
6972 GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
6973 // We are leaking the descriptor here because on some platforms (i.e.,
6974 // when built as Windows DLL), destructors of global objects will still
6975 // run after calling _exit(). On such systems, write_fd_ will be
6976 // indirectly closed from the destructor of UnitTestImpl, causing double
6977 // close if it is also closed here. On debug configurations, double close
6978 // may assert. As there are no in-process buffers to flush here, we are
6979 // relying on the OS to close the descriptor after the process terminates
6980 // when the destructors are not run.
6981 _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
6982}
6983
6984// Returns an indented copy of stderr output for a death test.
6985// This makes distinguishing death test output lines from regular log lines

Callers 1

~ReturnSentinelMethod · 0.80

Calls 1

WriteFunction · 0.85

Tested by

no test coverage detected