• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import os.path
6import upstart
7from autotest_lib.client.bin import test
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.cros import device_jail_utils
10
11
12class DeviceJailTestBase(test.test):
13    """
14    An abstract base class for device jail tests. This checks to
15    make sure the device jail module is loaded in the kernel and
16    makes it easier to use.
17    """
18
19    def warmup(self):
20        super(DeviceJailTestBase, self).warmup()
21        if not (os.path.exists(device_jail_utils.JAIL_CONTROL_PATH) and
22                os.path.exists(device_jail_utils.JAIL_REQUEST_PATH)):
23            raise error.TestNAError('Device jail is not present')
24        if upstart.is_running('permission_broker'):
25            upstart.stop_job('permission_broker')
26
27
28    def cleanup(self):
29        super(DeviceJailTestBase, self).cleanup()
30        upstart.restart_job('permission_broker')
31