summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkosak <kosak@google.com>2014-07-29 00:30:10 (GMT)
committerkosak <kosak@google.com>2014-07-29 00:30:10 (GMT)
commit64df8e349f20f0552176e146312c589efe754925 (patch)
tree2246bcfb6dd878ec240a7336184c3f59ba2ae7f9 /src
parentb54098a9abade957ab3c4e94ae5e5225ef0015a4 (diff)
downloadgoogletest-64df8e349f20f0552176e146312c589efe754925.zip
googletest-64df8e349f20f0552176e146312c589efe754925.tar.gz
googletest-64df8e349f20f0552176e146312c589efe754925.tar.bz2
Mock out GetCurrentDir in NaCl.
Diffstat (limited to 'src')
-rw-r--r--src/gtest-filepath.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc
index 219875c..0292dc1 100644
--- a/src/gtest-filepath.cc
+++ b/src/gtest-filepath.cc
@@ -106,7 +106,14 @@ FilePath FilePath::GetCurrentDir() {
return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#else
char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
- return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
+ char* result = getcwd(cwd, sizeof(cwd));
+# if GTEST_OS_NACL
+ // getcwd will likely fail in NaCl due to the sandbox, so return something
+ // reasonable. The user may have provided a shim implementation for getcwd,
+ // however, so fallback only when failure is detected.
+ return FilePath(result == NULL ? kCurrentDirectoryString : cwd);
+# endif // GTEST_OS_NACL
+ return FilePath(result == NULL ? "" : cwd);
#endif // GTEST_OS_WINDOWS_MOBILE
}