diff options
author | Christopher Ferris <cferris@google.com> | 2013-10-24 14:38:45 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2013-10-24 16:47:01 -0700 |
commit | 5ad2a0ee80be8d3d14a5fb3ef838b7ae7efb65f1 (patch) | |
tree | 938f25cf9afeece1b66e9c72315ee1b4ef8de8f3 | |
parent | 0f1ce3dd0b880b6ae0cf7f5413702b8ef542efb2 (diff) | |
download | gtest-5ad2a0ee80be8d3d14a5fb3ef838b7ae7efb65f1.tar.gz |
Modify where gtest captured data is stored.
Stop using $EXTERNAL_STORAGE for the temporary directory, use
$ANDROID_DATA/local/tmp instead.
If $ANDROID_DATA is not set, use /tmp (which happens when running a host
based gtest).
Bug: 11234772
Change-Id: I6c12ea9e6eb281317b48eb672e9a8d294cb1caed
-rw-r--r-- | src/gtest-port.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc index f914dbc..d78d47e 100644 --- a/src/gtest-port.cc +++ b/src/gtest-port.cc @@ -507,21 +507,18 @@ class CapturedStream { filename_ = temp_file_path; // ANDROID #elif GTEST_OS_LINUX_ANDROID - // Get $EXTERNAL_STORAGE from the environment, since this can change - // for shell users (fallback is /data/nativetest, for emulator users). - ::std::string external_storage = "/data/nativetest"; - char *sdcard_path = getenv("EXTERNAL_STORAGE"); - if (sdcard_path != NULL) { - // Check that $EXTERNAL_STORAGE exists and is writable before trying to use it. - struct stat sb; - if (stat(sdcard_path, &sb) != -1) { - if ((sb.st_mode & S_IWUSR) != 0) { - external_storage = sdcard_path; - } - } + // Attempt to create the temporary file in this directory: + // $ANDROID_DATA/local/tmp + ::std::string str_template; + const char* android_data = getenv("ANDROID_DATA"); + if (android_data == NULL) { + // If $ANDROID_DATA is not set, then fallback to /tmp. + str_template = "/tmp"; + } else { + str_template = ::std::string(android_data) + "/local/tmp"; } - external_storage += "/captured_stderr.XXXXXX"; - char *name_template = strdup(external_storage.c_str()); + str_template += "/captured_stderr.XXXXXX"; + char* name_template = strdup(str_template.c_str()); const int captured_fd = mkstemp(name_template); GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file " << name_template; |