Chromium Code Reviews| Index: client/site_tests/platform_CryptohomeFio/platform_CryptohomeFio.py |
| diff --git a/client/site_tests/platform_CryptohomeFio/platform_CryptohomeFio.py b/client/site_tests/platform_CryptohomeFio/platform_CryptohomeFio.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4510c5d16958675d2ee4b2cf6ce83ff44aeac8ce |
| --- /dev/null |
| +++ b/client/site_tests/platform_CryptohomeFio/platform_CryptohomeFio.py |
| @@ -0,0 +1,81 @@ |
| +# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import logging, os, shutil, tempfile, utils |
| +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
|
| +from autotest_lib.client.bin import site_login, test |
| +from autotest_lib.client.common_lib import error |
| + |
| +CRYPTOHOMESTRESS_START = '/tmp/cryptohomestress_begin' |
| +CRYPTOHOMESTRESS_END = '/tmp/cryptohomestress_end' |
| +TEST_USER = 'test@chromium.org' |
| +TEST_PASSWORD = 'test' |
| + |
| +class platform_CryptohomeFio(test.test): |
| + version = 1 |
| + |
| + def setup(self): |
| + if not os.path.exists(self.srcdir): |
| + os.mkdir(self.srcdir) |
| + # Currently, it seems impossible for a client dep to specify deps. |
| + self.job.setup_dep(['fio']) |
| + |
| + |
| + def initialize(self): |
| + # Is it necessary to check for a previously bad state? |
| + if site_login.logged_in(): |
| + site_login.attempt_logout() |
| + |
| + # Copy the binary deps to the client host. |
| + deps = ['libaio', 'fio'] |
| + for dep in deps: |
| + dep_dir = os.path.join(self.autodir, 'deps', dep) |
| + self.job.install_pkg(dep, 'dep', dep_dir) |
| + # Cleanup/touch marker files. |
| + if os.path.exists(CRYPTOHOMESTRESS_END): |
| + os.unlink(CRYPTOHOMESTRESS_END) |
| + open(CRYPTOHOMESTRESS_START, 'w').close() |
| + |
| + |
| + def run_once(self, runtime, mount_cryptohome=True, tmpfs=False, |
| + script=None): |
| + # Mount a test cryptohome vault. |
| + self.__mount_cryptohome = mount_cryptohome |
| + if mount_cryptohome: |
| + site_cryptohome.mount_vault(TEST_USER, TEST_PASSWORD, create=True) |
| + tmpdir = chromeos_constants.CRYPTOHOME_MOUNT_PT |
| + else: |
| + if tmpfs: |
| + tmpdir = None |
| + else: |
| + tmpdir = self.tmpdir |
| + self.__work_dir = tempfile.mkdtemp(dir=tmpdir) |
| + self.__script = script |
| + # TODO make these parameters to run_once & check target disk for space. |
| + self.__filesize = '150m' |
| + self.__runtime = str(runtime) |
| + env_vars = ' '.join( |
| + ['FILENAME=' + os.path.join(self.__work_dir, self.__script), |
| + 'FILESIZE=' + self.__filesize, |
| + 'RUN_TIME=' + self.__runtime, |
| + 'LD_LIBRARY_PATH=' + os.path.join(self.autodir, 'deps/libaio/lib') |
| + ]) |
| + fio_bin = os.path.join(self.autodir, 'deps/fio/src/fio') |
| + fio_opts = '' |
| + fio = ' '.join([env_vars, fio_bin, fio_opts, |
| + os.path.join(self.bindir, self.__script)]) |
| + #TODO: Call fio and collect / parse logs. See hardware_storageFio. |
| + status = utils.run(fio) |
| + logging.info(status.stdout) |
| + |
| + |
| + def cleanup(self): |
| + logging.info('Finished with FS stress, cleaning up.') |
| + if self.__mount_cryptohome: |
| + site_cryptohome.unmount_vault() |
| + site_cryptohome.remove_vault(TEST_USER) |
| + else: |
| + shutil.rmtree(self.__work_dir) |
| + open(CRYPTOHOMESTRESS_END, 'w').close() |
| + os.unlink(CRYPTOHOMESTRESS_START) |