diff --git a/lit.cfg b/lit.cfg --- a/lit.cfg +++ b/lit.cfg @@ -48,3 +48,6 @@ # Find and initialize lit modules. if lit_config.params.get('profile') == 'perf': config.test_modules += ['perf'] + +if lit_config.params.get('profile') == 'hpmcount': + config.test_modules += ['hpmcount'] diff --git a/litsupport/modules/hpmcount.py b/litsupport/modules/hpmcount.py new file mode 100644 --- /dev/null +++ b/litsupport/modules/hpmcount.py @@ -0,0 +1,34 @@ +"""Test Module to perform an extra execution of the benchmark in the AIX +hpmcount tool.""" +from litsupport import shellcommand +from litsupport import testplan +from litsupport.modules import run_under + +import os + + +def _mutateCommandLine(context, commandline): + context.profilefile = context.tmpBase + ".hpmcount_data" + # Storing profile file in context allows other modules to be aware of it. + cmd = shellcommand.parse(commandline) + cmd.wrap('hpmcount', ['-o', context.profilefile]) + if cmd.stdout is None: + cmd.stdout = os.devnull + else: + cmd.stdout += ".hpmcount" + if cmd.stderr is None: + cmd.stderr = os.devnull + else: + cmd.stderr += ".hpmcount" + return cmd.toCommandline() + + +def mutatePlan(context, plan): + script = context.parsed_runscript + if context.config.run_under: + script = testplan.mutateScript(context, script, + run_under.mutateCommandLine) + script = testplan.mutateScript(context, script, _mutateCommandLine) + plan.profilescript += script + plan.metric_collectors.append( + lambda context: {'profile': context.profilefile})