summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2018-12-14 14:59:57 -0800
committerDan Albert <danalbert@google.com>2019-01-09 22:17:50 -0800
commit35cb7a0541337a71c113f7836b3a12f572398d05 (patch)
tree4fb053e0742c567c44880eb0191bd815a799af2c
parenta319cc895c76a86959f33f7fa34b868326d9ada5 (diff)
downloadlibcxx-35cb7a0541337a71c113f7836b3a12f572398d05.tar.gz
Run device tests as the shell user.
A handful of the std::filesystem tests assume non-root (such as checking readability of a file that has mode 000). We probably shouldn't be running as root for these tests anyway. Test: ./run_tests.py --bitness 32 Test: ./run_tests.py --bitness 64 Bug: None Change-Id: Ifc661bd245c3d802d8816d1c098b0e47d011c4fa
-rwxr-xr-xrun_tests.py11
-rw-r--r--utils/libcxx/android/executors.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/run_tests.py b/run_tests.py
index f510c41bc..ebbce0586 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -142,6 +142,14 @@ def get_build_cmds(bitness, host):
return extract_build_cmds(commands, os.path.basename(target))
+def setup_test_directory():
+ """Prepares a device test directory for use by the shell user."""
+ device_dir = '/data/local/tmp/libcxx'
+ check_call(['adb', 'shell', 'rm', '-rf', device_dir])
+ check_call(['adb', 'shell', 'mkdir', '-p', device_dir])
+ check_call(['adb', 'shell', 'chown', '-R', 'shell:shell', device_dir])
+
+
def main():
"""Program entry point."""
logging.basicConfig(level=logging.INFO)
@@ -176,6 +184,9 @@ def main():
have_filter_args = True
break # No need to keep scanning.
+ if not args.host:
+ setup_test_directory()
+
lit_args = [
'-sv', android_mode_arg, cxx_under_test_arg, cxx_template_arg,
link_template_arg, libcxx_site_cfg_arg, libcxxabi_site_cfg_arg
diff --git a/utils/libcxx/android/executors.py b/utils/libcxx/android/executors.py
index 7bf3413d1..d3c5d6875 100644
--- a/utils/libcxx/android/executors.py
+++ b/utils/libcxx/android/executors.py
@@ -16,7 +16,7 @@ class AdbExecutor(libcxx.test.executor.RemoteExecutor):
def _remote_temp(self, is_dir):
dir_arg = '-d' if is_dir else ''
- cmd = 'mktemp -q {} /data/local/tmp/libcxx.XXXXXXXXXX'.format(dir_arg)
+ cmd = 'mktemp -q {} /data/local/tmp/libcxx/temp.XXXXXX'.format(dir_arg)
_, temp_path, err, exitCode = self._execute_command_remote([cmd])
temp_path = temp_path.strip()
if exitCode != 0:
@@ -32,7 +32,7 @@ class AdbExecutor(libcxx.test.executor.RemoteExecutor):
adb_cmd.extend(['-s', self.serial])
delimiter = 'x'
- probe_cmd = ' '.join(cmd) + '; echo {}$?'.format(delimiter)
+ probe_cmd = 'su shell {}; echo {}$?'.format(' '.join(cmd), delimiter)
env_cmd = []
if env is not None: