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