1 import os 2 from autotest_lib.client.bin import test, utils 3 4 5 class linus_stress(test.test): 6 version = 1 7 8 def setup(self): 9 os.mkdir(self.srcdir) 10 os.chdir(self.bindir) 11 utils.system('cp linus_stress.c src/') 12 os.chdir(self.srcdir) 13 utils.system(utils.get_cc() + ' linus_stress.c -D_POSIX_C_SOURCE=200112 -o linus_stress') 14 15 16 def initialize(self): 17 self.job.require_gcc() 18 19 20 def run_the_test(self, iterations): 21 utils.write_one_line('/proc/sys/vm/dirty_ratio', '4') 22 utils.write_one_line('/proc/sys/vm/dirty_background_ratio', '2') 23 24 cmd = os.path.join(self.srcdir, 'linus_stress') 25 args = "%d" % (utils.memtotal() / 32) 26 27 profilers = self.job.profilers 28 if profilers.present(): 29 profilers.start(self) 30 31 for i in range(iterations): 32 utils.system(cmd + ' ' + args) 33 34 if profilers.present(): 35 profilers.stop(self) 36 profilers.report(self) 37 38 39 def execute(self, iterations = 1): 40 dirty_ratio = utils.read_one_line('/proc/sys/vm/dirty_ratio') 41 dirty_background_ratio = utils.read_one_line('/proc/sys/vm/dirty_background_ratio') 42 try: 43 self.run_the_test(iterations) 44 finally: 45 utils.write_one_line('/proc/sys/vm/dirty_ratio', dirty_ratio) 46 utils.write_one_line('/proc/sys/vm/dirty_background_ratio', dirty_background_ratio) 47