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