39using ::testing::InitGoogleTest;
41using ::testing::internal::posix::GetEnv;
42using ::testing::internal::posix::Stat;
43using ::testing::internal::posix::StatStruct;
47class PrematureExitTest :
public Test {
50 static bool FileExists(
const char* filepath) {
52 return Stat(filepath, &stat) == 0;
57 premature_exit_file_path_ =
GetEnv(
"TEST_PREMATURE_EXIT_FILE");
60 if (premature_exit_file_path_ == NULL) {
61 premature_exit_file_path_ =
"";
66 bool PrematureExitFileExists()
const {
67 return FileExists(premature_exit_file_path_);
70 const char* premature_exit_file_path_;
73typedef PrematureExitTest PrematureExitDeathTest;
80TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
81 if (*premature_exit_file_path_ ==
'\0') {
90 if (PrematureExitFileExists()) {
98TEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {
99 if (*premature_exit_file_path_ ==
'\0') {
104 <<
" file " << premature_exit_file_path_
105 <<
" should exist during test execution, but doesn't.";
111 InitGoogleTest(&argc,
argv);
116 const char*
const filepath = GetEnv(
"TEST_PREMATURE_EXIT_FILE");
117 if (filepath != NULL && *filepath !=
'\0') {
118 if (PrematureExitTest::FileExists(filepath)) {
120 "File %s shouldn't exist after the test program finishes, but does.",
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
#define TEST_F(test_fixture, test_name)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
#define EXPECT_TRUE(condition)
int Stat(const char *path, StatStruct *buf)
const char * GetEnv(const char *name)