summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-08-06 13:12:26 -0700
committerAndreas Gampe <agampe@google.com>2014-08-06 20:27:47 +0000
commit5a79fdecffbea657ebecd4cf19078925239eb1c3 (patch)
treec35ab30420657b309144f99ee0aa3e8ee879514a
parent1b192268f167f603fc372f02f9067f3ce5d82daf (diff)
downloadart-5a79fdecffbea657ebecd4cf19078925239eb1c3.zip
art-5a79fdecffbea657ebecd4cf19078925239eb1c3.tar.gz
art-5a79fdecffbea657ebecd4cf19078925239eb1c3.tar.bz2
ART: Use TMPDIR for test directories
Bug: 16499668 Change-Id: I0d3db4697ef7b1706807e7daa5e000bb89df14e0
-rw-r--r--Android.mk5
-rw-r--r--runtime/common_runtime_test.cc12
-rwxr-xr-xtest/run-test6
3 files changed, 21 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk
index 451edf1..15e8308 100644
--- a/Android.mk
+++ b/Android.mk
@@ -67,8 +67,13 @@ ifdef TARGET_2ND_ARCH
rm -f $(2ND_TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.odex
rm -f $(2ND_TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.odex
endif
+ifneq ($(TMPDIR),)
+ rm -rf $(TMPDIR)/$(USER)/test-*/dalvik-cache/*
+ rm -rf $(TMPDIR)/android-data/dalvik-cache/*
+else
rm -rf /tmp/$(USER)/test-*/dalvik-cache/*
rm -rf /tmp/android-data/dalvik-cache/*
+endif
.PHONY: clean-oat-target
clean-oat-target:
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 6cf5619..9972362 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -137,7 +137,17 @@ void CommonRuntimeTest::SetEnvironmentVariables(std::string& android_data) {
}
// On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of dalvik-cache
- android_data = (IsHost() ? "/tmp/art-data-XXXXXX" : "/data/dalvik-cache/art-data-XXXXXX");
+ if (IsHost()) {
+ const char* tmpdir = getenv("TMPDIR");
+ if (tmpdir != nullptr && tmpdir[0] != 0) {
+ android_data = tmpdir;
+ } else {
+ android_data = "/tmp";
+ }
+ } else {
+ android_data = "/data/dalvik-cache";
+ }
+ android_data += "/art-data-XXXXXX";
if (mkdtemp(&android_data[0]) == nullptr) {
PLOG(FATAL) << "mkdtemp(\"" << &android_data[0] << "\") failed";
}
diff --git a/test/run-test b/test/run-test
index aef7c52..ca7e68c 100755
--- a/test/run-test
+++ b/test/run-test
@@ -33,7 +33,11 @@ cd "${progdir}"
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
test_dir="test-$$"
-tmp_dir="/tmp/$USER/${test_dir}"
+if [ -z "$TMPDIR" ]; then
+ tmp_dir="/tmp/$USER/${test_dir}"
+else
+ tmp_dir="${TMPDIR}/$USER/${test_dir}"
+fi
export JAVA="java"
export JAVAC="javac -g"