Explicitly require rooted device in `mojo_test`. We need root to get the stdout produced by the shell. Fixes #385. R=etiennej@chromium.org Review URL: https://codereview.chromium.org/1302493002 . Cr-Mirrored-From: https://github.com/domokit/mojo Cr-Mirrored-Commit: 2a14271a627481156afc8aa66da05da828f5d4d1
diff --git a/devtoolslib/android_shell.py b/devtoolslib/android_shell.py index c3bed33..a4a7d16 100644 --- a/devtoolslib/android_shell.py +++ b/devtoolslib/android_shell.py
@@ -199,7 +199,7 @@ return len(subprocess.check_output(self._adb_command([ 'shell', 'pm', 'list', 'packages', _MOJO_SHELL_PACKAGE_NAME]))) > 0 - def check_device(self): + def check_device(self, require_root=False): """Verifies if the device configuration allows adb to run. If a target device was indicated in the constructor, it checks that the @@ -234,6 +234,9 @@ if not device_list[0].endswith('device'): return False, 'Connected device is not available.' + if require_root and not self._run_adb_as_root(): + return False, 'Cannot run on an unrooted device.' + return True, None def install_apk(self, shell_apk_path):
diff --git a/devtoolslib/shell_arguments.py b/devtoolslib/shell_arguments.py index 20f512e..f479248 100644 --- a/devtoolslib/shell_arguments.py +++ b/devtoolslib/shell_arguments.py
@@ -190,7 +190,8 @@ logcat_tags=shell_config.logcat_tags, verbose_pipe=verbose_pipe) - device_status, error = shell.check_device() + device_status, error = shell.check_device( + require_root=shell_config.require_root) if not device_status: raise ShellConfigurationException('Device check failed: ' + error) if shell_config.shell_path:
diff --git a/devtoolslib/shell_config.py b/devtoolslib/shell_config.py index 20d2e23..227b979 100644 --- a/devtoolslib/shell_config.py +++ b/devtoolslib/shell_config.py
@@ -36,6 +36,7 @@ self.adb_path = None self.target_device = None self.logcat_tags = None + self.require_root = False # Desktop-only. self.use_osmesa = None
diff --git a/mojo_test b/mojo_test index 2cf84b9..45cdb0d 100755 --- a/mojo_test +++ b/mojo_test
@@ -62,6 +62,9 @@ try: config = shell_config.get_shell_config(script_args) + if script_args.android: + # We need root to have the stdout of the shell available on the host. + config.require_root = True shell, common_shell_args = shell_arguments.get_shell(config, shell_args) except shell_config.ShellConfigurationException as e: print e