40 using ::testing::Test;
47 class 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_;
73 typedef PrematureExitTest PrematureExitDeathTest;
80 TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
81 if (*premature_exit_file_path_ ==
'\0') {
90 if (PrematureExitFileExists()) {
98 TEST_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.";
110 int main(
int argc,
char **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.",