1# Copyright (c) 2012 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. 4import time 5from autotest_lib.client.bin import test 6from autotest_lib.client.common_lib import error 7from autotest_lib.client.cros.graphics import graphics_utils 8 9 10class graphics_KernelMemory(test.test): 11 """ 12 Reads from sysfs to determine kernel gem objects and memory info. 13 """ 14 version = 1 15 GSC = None 16 17 def initialize(self): 18 self.GSC = graphics_utils.GraphicsStateChecker() 19 20 def run_once(self): 21 # TODO(ihf): We want to give this test something well-defined to 22 # measure. For now that will be the CrOS login-screen memory use. 23 # We could also log into the machine using telemetry, but that is 24 # still flaky. So for now we, lame as we are, just sleep a bit. 25 time.sleep(10.0) 26 27 keyvals = self.GSC.get_memory_keyvals() 28 for key, val in keyvals.iteritems(): 29 self.output_perf_value( 30 description=key, 31 value=val, 32 units='bytes', 33 higher_is_better=False) 34 self.GSC.finalize() 35 self.write_perf_keyval(keyvals) 36 # We should still be in the login screen and memory use > 0. 37 if self.GSC.get_memory_access_errors() > 0: 38 raise error.TestFail('Failed: Detected %d errors accessing graphics' 39 ' memory.' % self.GKM.num_errors) 40