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 6 import logging, random, os 7 from autotest_lib.client.bin import test, utils 8 from autotest_lib.client.common_lib import error 9 10 SUSPEND_START = '/tmp/power_state_cycle_begin' 11 SUSPEND_END = '/tmp/power_state_cycle_end' 12 CRYPTOHOMESTRESS_START = '/tmp/cryptohomestress_begin' 13 CRYPTOHOMESTRESS_END = '/tmp/cryptohomestress_end' 14 15 class platform_CryptohomeStress(test.test): 16 """This is a stress test of the file system in Chromium OS. 17 While performing the test, we will cycle through power 18 states, and interrupt disk activity. 19 """ 20 version = 1 21 def initialize(self): 22 for signal_file in [SUSPEND_END]: 23 if os.path.exists(signal_file): 24 logging.warning('removing existing stop file %s', signal_file) 25 os.unlink(signal_file) 26 random.seed() # System time is fine. 27 28 29 def run_once(self, runtime=300): 30 # check that fio has started, waiting for up to TIMEOUT 31 utils.poll_for_condition( 32 lambda: os.path.exists(CRYPTOHOMESTRESS_START), 33 error.TestFail('fiostress not triggered.'), 34 timeout=30, sleep_interval=1) 35 open(SUSPEND_START, 'w').close() 36 # Pad disk stress runtime by 60s for safety. 37 runtime = runtime + 60 38 utils.poll_for_condition( 39 lambda: os.path.exists(CRYPTOHOMESTRESS_END), 40 error.TestFail('fiostress runtime exceeded.'), 41 timeout=runtime, sleep_interval=10) 42 43 def cleanup(self): 44 open(SUSPEND_END, 'w').close() 45