blob: 8ac1c37689caa78234c9096fec8bcdca3f559b4d [file] [log] [blame]
import profiler, shutil
from autotest_lib.client.common_lib import utils
from autotest_lib.client.bin import autotest_utils
class readprofile(profiler.profiler):
version = 1
# http://www.kernel.org/pub/linux/utils/util-linux/util-linux-2.12r.tar.bz2
def setup(self, tarball = 'util-linux-2.12r.tar.bz2'):
self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
autotest_utils.extract_tarball_to_dir(self.tarball, self.srcdir)
os.chdir(self.srcdir)
utils.system('./configure')
os.chdir('sys-utils')
utils.system('make readprofile')
def initialize(self):
try:
utils.system('grep -iq " profile=" /proc/cmdline')
except CmdError:
raise AutotestError('readprofile not enabled')
self.cmd = self.srcdir + '/sys-utils/readprofile'
def start(self, test):
utils.system(self.cmd + ' -r')
def stop(self, test):
# There's no real way to stop readprofile, so we stash the
# raw data at this point instead. BAD EXAMPLE TO COPY! ;-)
self.rawprofile = test.profdir + '/profile.raw'
print "STOP"
shutil.copyfile('/proc/profile', self.rawprofile)
def report(self, test):
args = ' -n'
args += ' -m ' + get_systemmap()
args += ' -p ' + self.rawprofile
cmd = self.cmd + ' ' + args
txtprofile = test.profdir + '/profile.text'
utils.system(cmd + ' | sort -nr > ' + txtprofile)
utils.system('bzip2 ' + self.rawprofile)