40 using ::testing::Test;
49 const bool kTestPrematureExitFileEnvVarShouldBeSet =
false;
51 class PrematureExitTest :
public Test {
54 static bool FileExists(
const char* filepath) {
56 return Stat(filepath, &stat) == 0;
61 premature_exit_file_path_ =
GetEnv(
"TEST_PREMATURE_EXIT_FILE");
64 if (premature_exit_file_path_ == NULL) {
65 premature_exit_file_path_ =
"";
70 bool PrematureExitFileExists()
const {
71 return FileExists(premature_exit_file_path_);
74 const char* premature_exit_file_path_;
77 typedef PrematureExitTest PrematureExitDeathTest;
84 TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
85 if (*premature_exit_file_path_ ==
'\0') {
94 if (PrematureExitFileExists()) {
102 TEST_F(PrematureExitTest, TestPrematureExitFileEnvVarIsSet) {
104 if (kTestPrematureExitFileEnvVarShouldBeSet) {
106 const
char* const filepath =
GetEnv("TEST_PREMATURE_EXIT_FILE");
114 TEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {
115 if (*premature_exit_file_path_ ==
'\0') {
120 <<
" file " << premature_exit_file_path_
121 <<
" should exist during test execution, but doesn't.";
126 int main(
int argc,
char **argv) {
132 const char*
const filepath =
GetEnv(
"TEST_PREMATURE_EXIT_FILE");
133 if (filepath != NULL && *filepath !=
'\0') {
134 if (PrematureExitTest::FileExists(filepath)) {
136 "File %s shouldn't exist after the test program finishes, but does.",
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
int stat(const char *path, struct stat *buffer)
#define GTEST_INTENTIONAL_CONST_COND_PUSH_()
int main(int argc, char **argv)
#define ASSERT_NE(val1, val2)
#define TEST_F(test_fixture, test_name)
int Stat(const char *path, StatStruct *buf)
if(strcmp(arg,"1305")!=0)
static char * GetEnv(const char *variable)
#define ASSERT_TRUE(condition)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
#define EXPECT_TRUE(condition)
#define GTEST_INTENTIONAL_CONST_COND_POP_()