Gtest doesn't use TMPDIR if it's set
ZijunZhaoCCK opened this issue · comments
Describe the bug
TMPDIR isn't used if it is set.
googletest/googletest/src/gtest-port.cc
Line 1078 in bf66935
googletest/googletest/src/gtest.cc
Line 6765 in bf66935
TMPDIR is not set on most versions of Android.
The only way for apps to find their temp dir pre S (or maybe even T) is with a Java API.
Gtest doesn't read TMPDIR. It's hard coded to use /data/local/tmp, which is not accessible to apps.
googletest/googletest/src/gtest-port.cc
Lines 1135 to 1139 in bf66935
Does the bug persist in the most recent commit?
Yes.
What operating system and version are you using?
Debian GNU/Linux rodete
On Android, the environment variable is called TEST_TMPDIR
, not TMPDIR
:
googletest/googletest/src/gtest.cc
Line 6763 in bf66935
this must also be changed in gtest-port.cc
name_template = TempDir();
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 994fabd4..53cae875 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1060,7 +1060,7 @@ class CapturedStream {
// The location /data/local/tmp is directly accessible from native code.
// '/sdcard' and other variants cannot be relied on, as they are not
// guaranteed to be mounted, or may have a delay in mounting.
- name_template = "/data/local/tmp/";
+ name_template = TempDir();
#elif defined(GTEST_OS_IOS)
char user_temp_dir[PATH_MAX + 1];