| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 from autotest_lib.client.bin import test | 9 from autotest_lib.client.bin import test |
| 10 from autotest_lib.client.common_lib import error, utils | 10 from autotest_lib.client.common_lib import error, utils |
| 11 | 11 |
| 12 class platform_MiniJailCmdLine(test.test): | 12 class platform_MiniJailCmdLine(test.test): |
| 13 version = 1 | 13 version = 1 |
| 14 preserve_srcdir = True | 14 preserve_srcdir = True |
| 15 | 15 |
| 16 def setup(self): | 16 def setup(self): |
| 17 os.chdir(self.srcdir) | 17 os.chdir(self.srcdir) |
| 18 utils.system('make clean') | 18 utils.make('clean') |
| 19 utils.system('make all') | 19 utils.make('all') |
| 20 | 20 |
| 21 | 21 |
| 22 def __run_cmd(self, cmd): | 22 def __run_cmd(self, cmd): |
| 23 result = utils.system_output(cmd, retain_output=True, | 23 result = utils.system_output(cmd, retain_output=True, |
| 24 ignore_status=True) | 24 ignore_status=True) |
| 25 return result | 25 return result |
| 26 | 26 |
| 27 | 27 |
| 28 def run_once(self): | 28 def run_once(self): |
| 29 # Check that -- [cmd] works | 29 # Check that -- [cmd] works |
| 30 check_cmd = (os.path.join(self.bindir, 'platform_MiniJailCmdLine') + | 30 check_cmd = (os.path.join(self.bindir, 'platform_MiniJailCmdLine') + |
| 31 ' --echoCmdLine') | 31 ' --echoCmdLine') |
| 32 cmd = ('/sbin/minijail -- ' + check_cmd) | 32 cmd = ('/sbin/minijail -- ' + check_cmd) |
| 33 result = self.__run_cmd(cmd) | 33 result = self.__run_cmd(cmd) |
| 34 check_pattern = re.compile(r"__CMD_LINE__\n(.+)\n__CMD_LINE__", | 34 check_pattern = re.compile(r"__CMD_LINE__\n(.+)\n__CMD_LINE__", |
| 35 re.MULTILINE) | 35 re.MULTILINE) |
| 36 m = check_pattern.search(result); | 36 m = check_pattern.search(result); |
| 37 if m: | 37 if m: |
| 38 if (m.group(1).strip() != check_cmd): | 38 if (m.group(1).strip() != check_cmd): |
| 39 raise error.TestFail('The command line did not match what was ' + | 39 raise error.TestFail('The command line did not match what was ' + |
| 40 'passed to minijail') | 40 'passed to minijail') |
| 41 else: | 41 else: |
| 42 raise error.TestFail('The command line did not match what was ' + | 42 raise error.TestFail('The command line did not match what was ' + |
| 43 'passed to minijail') | 43 'passed to minijail') |
| OLD | NEW |