diff options
author | Hal Canary <halcanary@google.com> | 2017-12-11 14:42:58 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-12 18:22:39 +0000 |
commit | 925e31e749fc369ebd2ebd7994693b767e674e97 (patch) | |
tree | 1c667218a5d94e0b2a8d3d35c209a8def119ebec /tests/Test.cpp | |
parent | c896eddc1cf77ffaaa0d0cb68caac7e251cdb727 (diff) |
dm: require tmpDir, reasonable defaults
Change-Id: I9d84ce1ebbe417160a29ca2221b1df04901238e3
Reviewed-on: https://skia-review.googlesource.com/83541
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tests/Test.cpp')
-rw-r--r-- | tests/Test.cpp | 22 |
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()) {} |