Set atest result dir using gettempdir()

Instead of hard coding the result directory to /tmp/atest_result,
use python built in mechanism to lookup temporary path.

This makes it possible set a custom output path by setting an
environment variable, such as TMPDIR.
If TMPDIR is set, then create atest results in $TMPDIR/atest_result.
If not set, fallback to /tmp/atest_result.

On a system with multiple users, such as a shared build computer, the
default atest temporary directory (/tmp/atest_result) is created by the
first user running atest
The directory permissions may prevent other uses from accessing the
directory.

Bug: 313948300
Test: atest-dev hello_world_test
    confirm output folder
    export TMPDIR=/tmp/myfolder
    atest-dev hello_world_test
    confirm output folder
Change-Id: I93fa6106679eb2d995915fa9eb42eb89155ab764
diff --git a/atest/constants_default.py b/atest/constants_default.py
index 4da0e8f..a81fbb4 100644
--- a/atest/constants_default.py
+++ b/atest/constants_default.py
@@ -20,7 +20,9 @@
 
 import os
 import re
+import tempfile
 from collections import namedtuple
+from pathlib import Path
 
 MODE = 'DEFAULT'
 
@@ -265,7 +267,7 @@
 PACKAGE_OUTPUT_RE = re.compile(r'(?P<java_dir>/.*/).*[.](java|kt)[:]\s*package\s+'
                                r'(?P<package>[^(;|\s)]+)\s*')
 
-ATEST_RESULT_ROOT = '/tmp/atest_result'
+ATEST_RESULT_ROOT = Path(tempfile.gettempdir(), 'atest_result')
 ATEST_TEST_RECORD_PROTO = 'test_record.proto'
 LATEST_RESULT_FILE = os.path.join(ATEST_RESULT_ROOT, 'LATEST', 'test_result')