Renames the POSIX wrappers (by Zhanyong Wan) and adds more targets to SConscript (by Vlad Losev).
This commit is contained in:
@@ -204,7 +204,7 @@ void DeathTestAbort(const String& message) {
|
||||
const InternalRunDeathTestFlag* const flag =
|
||||
GetUnitTestImpl()->internal_run_death_test_flag();
|
||||
if (flag != NULL) {
|
||||
FILE* parent = posix::fdopen(flag->write_fd(), "w");
|
||||
FILE* parent = posix::FDOpen(flag->write_fd(), "w");
|
||||
fputc(kDeathTestInternalError, parent);
|
||||
fprintf(parent, "%s", message.c_str());
|
||||
fflush(parent);
|
||||
@@ -249,7 +249,7 @@ void DeathTestAbort(const String& message) {
|
||||
|
||||
// Returns the message describing the last system error in errno.
|
||||
String GetLastErrnoDescription() {
|
||||
return String(errno == 0 ? "" : posix::strerror(errno));
|
||||
return String(errno == 0 ? "" : posix::StrError(errno));
|
||||
}
|
||||
|
||||
// This is called from a death test parent process to read a failure
|
||||
@@ -262,7 +262,7 @@ static void FailFromInternalError(int fd) {
|
||||
int num_read;
|
||||
|
||||
do {
|
||||
while ((num_read = posix::read(fd, buffer, 255)) > 0) {
|
||||
while ((num_read = posix::Read(fd, buffer, 255)) > 0) {
|
||||
buffer[num_read] = '\0';
|
||||
error << buffer;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ void DeathTestImpl::ReadAndInterpretStatusByte() {
|
||||
// its success), so it's okay to call this in the parent before
|
||||
// the child process has exited.
|
||||
do {
|
||||
bytes_read = posix::read(read_fd(), &flag, 1);
|
||||
bytes_read = posix::Read(read_fd(), &flag, 1);
|
||||
} while (bytes_read == -1 && errno == EINTR);
|
||||
|
||||
if (bytes_read == 0) {
|
||||
@@ -407,7 +407,7 @@ void DeathTestImpl::ReadAndInterpretStatusByte() {
|
||||
Message() << "Read from death test child process failed: "
|
||||
<< GetLastErrnoDescription());
|
||||
}
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::close(read_fd()));
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
|
||||
set_read_fd(-1);
|
||||
}
|
||||
|
||||
@@ -421,8 +421,8 @@ void DeathTestImpl::Abort(AbortReason reason) {
|
||||
// to the pipe, then exit.
|
||||
const char status_ch =
|
||||
reason == TEST_DID_NOT_DIE ? kDeathTestLived : kDeathTestReturned;
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::write(write_fd(), &status_ch, 1));
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::close(write_fd()));
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(write_fd()));
|
||||
_exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
|
||||
}
|
||||
|
||||
|
||||
@@ -168,8 +168,8 @@ bool FilePath::FileOrDirectoryExists() const {
|
||||
delete [] unicode;
|
||||
return attributes != kInvalidFileAttributes;
|
||||
#else
|
||||
posix::stat_struct file_stat;
|
||||
return posix::stat(pathname_.c_str(), &file_stat) == 0;
|
||||
posix::StatStruct file_stat;
|
||||
return posix::Stat(pathname_.c_str(), &file_stat) == 0;
|
||||
#endif // _WIN32_WCE
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ bool FilePath::DirectoryExists() const {
|
||||
result = true;
|
||||
}
|
||||
#else
|
||||
posix::stat_struct file_stat;
|
||||
result = posix::stat(path.c_str(), &file_stat) == 0 &&
|
||||
posix::StatStruct file_stat;
|
||||
result = posix::Stat(path.c_str(), &file_stat) == 0 &&
|
||||
posix::IsDir(file_stat);
|
||||
#endif // _WIN32_WCE
|
||||
|
||||
|
||||
@@ -539,9 +539,9 @@ void CaptureStderr() {
|
||||
::std::string GetCapturedStderr() {
|
||||
g_captured_stderr->StopCapture();
|
||||
|
||||
FILE* const file = posix::fopen(g_captured_stderr->filename().c_str(), "r");
|
||||
FILE* const file = posix::FOpen(g_captured_stderr->filename().c_str(), "r");
|
||||
const ::std::string content = ReadEntireFile(file);
|
||||
posix::fclose(file);
|
||||
posix::FClose(file);
|
||||
|
||||
delete g_captured_stderr;
|
||||
g_captured_stderr = NULL;
|
||||
@@ -563,7 +563,7 @@ const ::std::vector<String>& GetArgvs() { return g_argvs; }
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
namespace posix {
|
||||
void abort() {
|
||||
void Abort() {
|
||||
DebugBreak();
|
||||
TerminateProcess(GetCurrentProcess(), 1);
|
||||
}
|
||||
@@ -632,7 +632,7 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
|
||||
// The value is considered true iff it's not "0".
|
||||
bool BoolFromGTestEnv(const char* flag, bool default_value) {
|
||||
const String env_var = FlagToEnvVar(flag);
|
||||
const char* const string_value = posix::getenv(env_var.c_str());
|
||||
const char* const string_value = posix::GetEnv(env_var.c_str());
|
||||
return string_value == NULL ?
|
||||
default_value : strcmp(string_value, "0") != 0;
|
||||
}
|
||||
@@ -642,7 +642,7 @@ bool BoolFromGTestEnv(const char* flag, bool default_value) {
|
||||
// doesn't represent a valid 32-bit integer, returns default_value.
|
||||
Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
||||
const String env_var = FlagToEnvVar(flag);
|
||||
const char* const string_value = posix::getenv(env_var.c_str());
|
||||
const char* const string_value = posix::GetEnv(env_var.c_str());
|
||||
if (string_value == NULL) {
|
||||
// The environment variable is not set.
|
||||
return default_value;
|
||||
@@ -664,7 +664,7 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
||||
// the given flag; if it's not set, returns default_value.
|
||||
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
|
||||
const String env_var = FlagToEnvVar(flag);
|
||||
const char* const value = posix::getenv(env_var.c_str());
|
||||
const char* const value = posix::GetEnv(env_var.c_str());
|
||||
return value == NULL ? default_value : value;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void TestPartResultArray::Append(const TestPartResult& result) {
|
||||
const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
|
||||
if (index < 0 || index >= size()) {
|
||||
printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
|
||||
internal::posix::abort();
|
||||
internal::posix::Abort();
|
||||
}
|
||||
|
||||
const internal::ListNode<TestPartResult>* p = list_->Head();
|
||||
|
||||
22
src/gtest.cc
22
src/gtest.cc
@@ -803,7 +803,7 @@ static char* CloneString(const char* str, size_t length) {
|
||||
return NULL;
|
||||
} else {
|
||||
char* const clone = new char[length + 1];
|
||||
posix::strncpy(clone, str, length);
|
||||
posix::StrNCpy(clone, str, length);
|
||||
clone[length] = '\0';
|
||||
return clone;
|
||||
}
|
||||
@@ -1443,7 +1443,7 @@ char* CodePointToUtf8(UInt32 code_point, char* str) {
|
||||
// the terminating nul character). We are asking for 32 character
|
||||
// buffer just in case. This is also enough for strncpy to
|
||||
// null-terminate the destination string.
|
||||
posix::strncpy(
|
||||
posix::StrNCpy(
|
||||
str, String::Format("(Invalid Unicode 0x%X)", code_point).c_str(), 32);
|
||||
str[31] = '\0'; // Makes sure no change in the format to strncpy leaves
|
||||
// the result unterminated.
|
||||
@@ -1586,7 +1586,7 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
|
||||
return rhs == NULL;
|
||||
if (rhs == NULL)
|
||||
return false;
|
||||
return posix::strcasecmp(lhs, rhs) == 0;
|
||||
return posix::StrCaseCmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
// Compares two wide C strings, ignoring case. Returns true iff they
|
||||
@@ -2510,7 +2510,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
||||
return stdout_is_tty;
|
||||
#else
|
||||
// On non-Windows platforms, we rely on the TERM variable.
|
||||
const char* const term = posix::getenv("TERM");
|
||||
const char* const term = posix::GetEnv("TERM");
|
||||
const bool term_supports_color =
|
||||
String::CStringEquals(term, "xterm") ||
|
||||
String::CStringEquals(term, "xterm-color") ||
|
||||
@@ -2540,7 +2540,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
const bool use_color = false;
|
||||
#else
|
||||
static const bool in_color_mode =
|
||||
ShouldUseColor(posix::isatty(posix::fileno(stdout)) != 0);
|
||||
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
|
||||
const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
|
||||
#endif // defined(_WIN32_WCE) || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
|
||||
// The '!= 0' comparison is necessary to satisfy MSVC 7.1.
|
||||
@@ -2622,8 +2622,8 @@ void PrettyUnitTestResultPrinter::OnUnitTestStart(
|
||||
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
|
||||
ColoredPrintf(COLOR_YELLOW,
|
||||
"Note: This is test shard %s of %s.\n",
|
||||
internal::posix::getenv(kTestShardIndex),
|
||||
internal::posix::getenv(kTestTotalShards));
|
||||
internal::posix::GetEnv(kTestShardIndex),
|
||||
internal::posix::GetEnv(kTestTotalShards));
|
||||
}
|
||||
|
||||
const internal::UnitTestImpl* const impl = unit_test->impl();
|
||||
@@ -2941,7 +2941,7 @@ void XmlUnitTestResultPrinter::OnUnitTestEnd(const UnitTest* unit_test) {
|
||||
internal::FilePath output_dir(output_file.RemoveFileName());
|
||||
|
||||
if (output_dir.CreateDirectoriesRecursively()) {
|
||||
xmlout = internal::posix::fopen(output_file_.c_str(), "w");
|
||||
xmlout = internal::posix::FOpen(output_file_.c_str(), "w");
|
||||
}
|
||||
if (xmlout == NULL) {
|
||||
// TODO(wan): report the reason of the failure.
|
||||
@@ -3678,9 +3678,9 @@ int UnitTestImpl::RunAllTests() {
|
||||
// function will write over it. If the variable is present, but the file cannot
|
||||
// be created, prints an error and exits.
|
||||
void WriteToShardStatusFileIfNeeded() {
|
||||
const char* const test_shard_file = posix::getenv(kTestShardStatusFile);
|
||||
const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
|
||||
if (test_shard_file != NULL) {
|
||||
FILE* const file = posix::fopen(test_shard_file, "w");
|
||||
FILE* const file = posix::FOpen(test_shard_file, "w");
|
||||
if (file == NULL) {
|
||||
ColoredPrintf(COLOR_RED,
|
||||
"Could not write to the test shard status file \"%s\" "
|
||||
@@ -3745,7 +3745,7 @@ bool ShouldShard(const char* total_shards_env,
|
||||
// returns default_val. If it is not an Int32, prints an error
|
||||
// and aborts.
|
||||
Int32 Int32FromEnvOrDie(const char* const var, Int32 default_val) {
|
||||
const char* str_val = posix::getenv(var);
|
||||
const char* str_val = posix::GetEnv(var);
|
||||
if (str_val == NULL) {
|
||||
return default_val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user