aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Test.cpp')
-rw-r--r--tests/Test.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 37515ddf42..96bbbad9b9 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -7,6 +7,8 @@
#include "Test.h"
+#include <stdlib.h>
+
#include "SkCommandLineFlags.h"
#include "SkString.h"
#include "SkTime.h"
@@ -32,8 +34,24 @@ SkString skiatest::Failure::toString() const {
}
SkString skiatest::GetTmpDir() {
- const char* tmpDir = FLAGS_tmpDir.isEmpty() ? nullptr : FLAGS_tmpDir[0];
- return SkString(tmpDir);
+ if (!FLAGS_tmpDir.isEmpty()) {
+ return SkString(FLAGS_tmpDir[0]);
+ }
+#ifdef SK_BUILD_FOR_ANDROID
+ const char* environmentVariable = "TMPDIR";
+ const char* defaultValue = "/data/local/tmp";
+#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
+ const char* environmentVariable = "TMPDIR";
+ const char* defaultValue = "/tmp";
+#elif defined(SK_BUILD_FOR_WIN32)
+ const char* environmentVariable = "TEMP";
+ const char* defaultValue = nullptr;
+#else
+ const char* environmentVariable = nullptr;
+ const char* defaultValue = nullptr;
+#endif
+ const char* tmpdir = environmentVariable ? getenv(environmentVariable) : nullptr;
+ return SkString(tmpdir ? tmpdir : defaultValue);
}
skiatest::Timer::Timer() : fStartNanos(SkTime::GetNSecs()) {}