39 using ::testing::Test;
46 class PrematureExitTest :
public Test {
49 static bool FileExists(
const char* filepath) {
51 return Stat(filepath, &stat) == 0;
56 premature_exit_file_path_ =
GetEnv(
"TEST_PREMATURE_EXIT_FILE");
59 if (premature_exit_file_path_ ==
nullptr) {
60 premature_exit_file_path_ =
"";
65 bool PrematureExitFileExists()
const {
66 return FileExists(premature_exit_file_path_);
69 const char* premature_exit_file_path_;
72 typedef PrematureExitTest PrematureExitDeathTest;
79 TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
80 if (*premature_exit_file_path_ ==
'\0') {
89 if (PrematureExitFileExists()) {
97 TEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {
98 if (*premature_exit_file_path_ ==
'\0') {
103 <<
" file " << premature_exit_file_path_
104 <<
" should exist during test execution, but doesn't.";
109 int main(
int argc,
char **argv) {
115 const char*
const filepath =
GetEnv(
"TEST_PREMATURE_EXIT_FILE");
116 if (filepath !=
nullptr && *filepath !=
'\0') {
117 if (PrematureExitTest::FileExists(filepath)) {
119 "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 Stat(const char *path, StatStruct *buf)
const char * GetEnv(const char *name)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
#define EXPECT_TRUE(condition)