1# Copyright (c) 2014 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 5import logging, os 6 7from autotest_lib.client.bin import test, utils 8from autotest_lib.client.common_lib import error 9 10class hardware_Memtester(test.test): 11 """ 12 This test uses memtester to find memory subsystem faults. Amount of memory 13 to test is all of the free memory plus buffer and cache region with 30 MB 14 reserved for OS use. 15 """ 16 17 version = 1 18 19 def run_once(self, size=0, loop=10): 20 """ 21 Executes the test and logs the output. 22 23 @param size: size to test in KB. 0 means all usable 24 @param loop: number of iteration to test memory 25 """ 26 if size == 0: 27 size = utils.usable_memtotal() 28 elif size > utils.memtotal(): 29 raise error.TestFail('Specified size is more than total memory.') 30 31 if size <= 0: 32 raise error.TestFail('Size must be more than zero.') 33 34 35 logging.info('Memory test size: %dK', size) 36 37 cmd = 'memtester %dK %d' % (size, loop) 38 logging.info('cmd: %s', cmd) 39 40 with open(os.path.join(self.resultsdir, 'memtester_stdout'), 'w') as f: 41 utils.run(cmd, stdout_tee=f) 42