aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2012-09-11 17:15:52 -0700
committerStephen Hines <srhines@google.com>2012-09-11 17:56:30 -0700
commit344e5f3db17615cc853073a02968a603efd39109 (patch)
tree03506e8c8dc05264d3a8a382cbb9b8f6497f0187
parent85030ffa1dd68c0cc05e9115430f28627996e019 (diff)
downloadgtest-jb-mr1.1-dev.tar.gz
The multi-user changes affect apps launched from the shell (like gtest), so we need to grab the appropriate location dynamically, rather than continuing to hard-code it. Bug: 7121917 Change-Id: I51a58379eff713e63d34a507dc318a138faccb53
-rw-r--r--src/gtest-port.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index f4a8def..01c5e1e 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -507,9 +507,20 @@ class CapturedStream {
filename_ = temp_file_path;
// ANDROID
#elif GTEST_OS_LINUX_ANDROID
- char name_template[] = "/sdcard/captured_stderr.XXXXXX";
+ // Get $EXTERNAL_STORAGE from the environment, since this can change
+ // for shell users (fallback is still /sdcard, but this probably will
+ // never work properly again).
+ ::std::string external_storage = "/sdcard";
+ char *sdcard_path = getenv("EXTERNAL_STORAGE");
+ if (sdcard_path) {
+ external_storage = sdcard_path;
+ }
+ external_storage += "/captured_stderr.XXXXXX";
+ char *name_template = strdup(external_storage.c_str());
const int captured_fd = mkstemp(name_template);
filename_ = name_template;
+ free(name_template);
+ name_template = NULL;
// END ANDROID
# else
// There's no guarantee that a test has write access to the