Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import logging, os, shutil, tempfile, utils | |
| 6 from autotest_lib.client.bin import chromeos_constants, site_cryptohome | |
|
DaleCurtis
2011/01/31 23:10:03
These paths are wrong, should be:
from autotest_l
| |
| 7 from autotest_lib.client.bin import site_login, test | |
| 8 from autotest_lib.client.common_lib import error | |
| 9 | |
| 10 CRYPTOHOMESTRESS_START = '/tmp/cryptohomestress_begin' | |
| 11 CRYPTOHOMESTRESS_END = '/tmp/cryptohomestress_end' | |
| 12 TEST_USER = 'test@chromium.org' | |
| 13 TEST_PASSWORD = 'test' | |
| 14 | |
| 15 class platform_CryptohomeFio(test.test): | |
| 16 version = 1 | |
| 17 | |
| 18 def setup(self): | |
| 19 if not os.path.exists(self.srcdir): | |
| 20 os.mkdir(self.srcdir) | |
| 21 # Currently, it seems impossible for a client dep to specify deps. | |
| 22 self.job.setup_dep(['fio']) | |
| 23 | |
| 24 | |
| 25 def initialize(self): | |
| 26 # Is it necessary to check for a previously bad state? | |
| 27 if site_login.logged_in(): | |
| 28 site_login.attempt_logout() | |
| 29 | |
| 30 # Copy the binary deps to the client host. | |
| 31 deps = ['libaio', 'fio'] | |
| 32 for dep in deps: | |
| 33 dep_dir = os.path.join(self.autodir, 'deps', dep) | |
| 34 self.job.install_pkg(dep, 'dep', dep_dir) | |
| 35 # Cleanup/touch marker files. | |
| 36 if os.path.exists(CRYPTOHOMESTRESS_END): | |
| 37 os.unlink(CRYPTOHOMESTRESS_END) | |
| 38 open(CRYPTOHOMESTRESS_START, 'w').close() | |
| 39 | |
| 40 | |
| 41 def run_once(self, runtime, mount_cryptohome=True, tmpfs=False, | |
| 42 script=None): | |
| 43 # Mount a test cryptohome vault. | |
| 44 self.__mount_cryptohome = mount_cryptohome | |
| 45 if mount_cryptohome: | |
| 46 site_cryptohome.mount_vault(TEST_USER, TEST_PASSWORD, create=True) | |
| 47 tmpdir = chromeos_constants.CRYPTOHOME_MOUNT_PT | |
| 48 else: | |
| 49 if tmpfs: | |
| 50 tmpdir = None | |
| 51 else: | |
| 52 tmpdir = self.tmpdir | |
| 53 self.__work_dir = tempfile.mkdtemp(dir=tmpdir) | |
| 54 self.__script = script | |
| 55 # TODO make these parameters to run_once & check target disk for space. | |
| 56 self.__filesize = '150m' | |
| 57 self.__runtime = str(runtime) | |
| 58 env_vars = ' '.join( | |
| 59 ['FILENAME=' + os.path.join(self.__work_dir, self.__script), | |
| 60 'FILESIZE=' + self.__filesize, | |
| 61 'RUN_TIME=' + self.__runtime, | |
| 62 'LD_LIBRARY_PATH=' + os.path.join(self.autodir, 'deps/libaio/lib') | |
| 63 ]) | |
| 64 fio_bin = os.path.join(self.autodir, 'deps/fio/src/fio') | |
| 65 fio_opts = '' | |
| 66 fio = ' '.join([env_vars, fio_bin, fio_opts, | |
| 67 os.path.join(self.bindir, self.__script)]) | |
| 68 #TODO: Call fio and collect / parse logs. See hardware_storageFio. | |
| 69 status = utils.run(fio) | |
| 70 logging.info(status.stdout) | |
| 71 | |
| 72 | |
| 73 def cleanup(self): | |
| 74 logging.info('Finished with FS stress, cleaning up.') | |
| 75 if self.__mount_cryptohome: | |
| 76 site_cryptohome.unmount_vault() | |
| 77 site_cryptohome.remove_vault(TEST_USER) | |
| 78 else: | |
| 79 shutil.rmtree(self.__work_dir) | |
| 80 open(CRYPTOHOMESTRESS_END, 'w').close() | |
| 81 os.unlink(CRYPTOHOMESTRESS_START) | |
| OLD | NEW |