diff options
author | Stephen Hines <srhines@google.com> | 2012-09-11 17:15:52 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2012-09-11 17:56:30 -0700 |
commit | 344e5f3db17615cc853073a02968a603efd39109 (patch) | |
tree | 03506e8c8dc05264d3a8a382cbb9b8f6497f0187 | |
parent | 85030ffa1dd68c0cc05e9115430f28627996e019 (diff) | |
download | gtest-344e5f3db17615cc853073a02968a603efd39109.tar.gz |
Use $EXTERNAL_STORAGE instead of /sdcard.android-sdk-support_r11android-cts-4.2_r2android-cts-4.2_r1android-4.2_r1android-4.2.2_r1.2android-4.2.2_r1.1android-4.2.2_r1android-4.2.1_r1.2android-4.2.1_r1.1android-4.2.1_r1jb-mr1.1-releasejb-mr1.1-devjb-mr1-releasejb-mr1-dev-plus-aospjb-mr1-dev
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.cc | 13 |
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 |