From ef997fa343d5fa120d731ec38c1a493201d67252 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Thu, 10 Nov 2016 11:59:08 +0000 Subject: [PATCH 1/2] executor: Fix running non-root on Android devices tmpfs mounts have an SELinux context with "tmpfs" as the type (while other files we create have "shell_data_file"). That prevents non-root users from creating files in tmpfs mounts. For now, just put SELinux in permissive mode to get around that. --- libs/utils/executor.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/utils/executor.py b/libs/utils/executor.py index 4c6eceb0f..563976de2 100644 --- a/libs/utils/executor.py +++ b/libs/utils/executor.py @@ -42,6 +42,8 @@ from conf import JsonConf import wlgen +from devlib import TargetError + Experiment = namedtuple('Experiment', ['wload_name', 'wload', 'conf', 'iteration', 'out_dir']) @@ -157,6 +159,8 @@ class Executor(): for exp_idx, experiment in enumerate(self.experiments): self._wload_run(exp_idx, experiment) + self._target_cleanup(tc) + self._print_section('Executor', 'Experiments execution completed') logging.info('%14s - Results available in:', 'Executor') logging.info('%14s - %s', 'Executor', self.te.res_dir) @@ -212,12 +216,26 @@ class Executor(): logging.debug('%14s - Setup RT-App run folder [%s]...', 'TargetSetup', self.te.run_dir) self.target.execute('[ -d {0} ] || mkdir {0}'\ - .format(self.te.run_dir), as_root=True) + .format(self.te.run_dir)) self.target.execute( 'grep schedtest /proc/mounts || '\ ' mount -t tmpfs -o size=1024m {} {}'\ .format('schedtest', self.te.run_dir), as_root=True) + # tmpfs mounts have an SELinux context with "tmpfs" as the type (while + # other files we create have "shell_data_file"). That prevents non-root + # users from creating files in tmpfs mounts. For now, just put SELinux + # in permissive mode to get around that. + try: + # First, save the old SELinux mode + self._old_selinux_mode = self.target.execute('getenforce') + except TargetError: + # Probably the target doesn't have SELinux. No problem. + self._old_selinux_mode = None + else: + logging.warning('%14s - Setting target SELinux in permissive mode', + 'Executor') + self.target.execute('setenforce 0', as_root=True) def _setup_cpufreq(self, tc): if 'cpufreq' not in tc: @@ -305,6 +323,12 @@ class Executor(): 'TargetConf', tc['tag'], flag, has_flag) return has_flag + def _target_cleanup(self, tc): + if self._old_selinux_mode is not None: + logging.info('%14s - Restoring target SELinux mode: %s', + 'Executor', self._old_selinux_mode) + self.target.execute('setenforce ' + self._old_selinux_mode, + as_root=True) ################################################################################ # Workload Setup and Execution -- GitLab From 96aa861c044b2a5b87d09ebf2f9e3eb57ed47f12 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 22 Nov 2016 15:04:45 +0000 Subject: [PATCH 2/2] executor: Fix running with multiple confs commit 0328c61 (libs/utils/executor: Store metadata about executed experiments) broke the indentation here, so that when you have multiple test configurations the behaviour is wrong. --- libs/utils/executor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/utils/executor.py b/libs/utils/executor.py index 563976de2..367cbfd19 100644 --- a/libs/utils/executor.py +++ b/libs/utils/executor.py @@ -139,6 +139,7 @@ class Executor(): self.experiments = [] # Run all the configured experiments + exp_idx = 0 for tc in self._tests_conf['confs']: # TARGET: configuration if not self._target_configure(tc): @@ -155,10 +156,9 @@ class Executor(): out_dir=os.path.join(test_dir, str(itr_idx))) self.experiments.append(exp) - # WORKLOAD: execution - for exp_idx, experiment in enumerate(self.experiments): - self._wload_run(exp_idx, experiment) - + # WORKLOAD: execution + self._wload_run(exp_idx, exp) + exp_idx += 1 self._target_cleanup(tc) self._print_section('Executor', 'Experiments execution completed') -- GitLab