----- "Lucas Meneghel Rodrigues" <[email protected]> wrote:

> Add kvm_stat profiling to the helper function
> run_tests, so every kvm test run through this
> function but build will present kvm_stat data
> on the profiling directory.
> 
> Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
> ---
>  client/profilers/kvm_stat/kvm_stat.py |   10 ++++++----
>  client/tests/kvm/kvm_utils.py         |   23 ++++++++++++++++++++---
>  2 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/client/profilers/kvm_stat/kvm_stat.py
> b/client/profilers/kvm_stat/kvm_stat.py
> index b2c0b32..8180868 100644
> --- a/client/profilers/kvm_stat/kvm_stat.py
> +++ b/client/profilers/kvm_stat/kvm_stat.py
> @@ -8,6 +8,7 @@ will try to mount it so it's possible to proceed.
>  """
>  import time, os, subprocess, commands
>  from autotest_lib.client.bin import utils, profiler, os_dep
> +from autotest_lib.client.common_lib import error
>  
>  
>  class kvm_stat(profiler.profiler):
> @@ -21,13 +22,14 @@ class kvm_stat(profiler.profiler):
>          Gets path of kvm_stat and verifies if debugfs needs to be
> mounted.
>          """
>          self.stat_path = os_dep.command('kvm_stat')
> -        (ret, output) = commands.getstatusoutput("%s --batch" %
> self.stat_path)
> -        if ret != 0:
> -            if 'debugfs' in output:
> +        try:
> +            utils.system_output("%s --batch" % self.stat_path)
> +        except error.CmdError, e:
> +            if 'debugfs' in e:
>                  utils.system('mount -t debugfs debugfs
> /sys/kernel/debug')
>              else:
>                  raise error.AutotestError('kvm_stat failed due to an
> '
> -                                          'unknown reason: %s' %
> output)
> +                                          'unknown reason: %s' % e)
>  
>  
>      def start(self, test):
> diff --git a/client/tests/kvm/kvm_utils.py
> b/client/tests/kvm/kvm_utils.py
> index 2bbbe22..7152816 100644
> --- a/client/tests/kvm/kvm_utils.py
> +++ b/client/tests/kvm/kvm_utils.py
> @@ -902,9 +902,26 @@ def run_tests(test_list, job):
>                      break
>          if dependencies_satisfied:
>              test_iterations = int(dict.get("iterations", 1))
> -            current_status = job.run_test("kvm", params=dict,
> -                                          tag=dict.get("shortname"),
> -                                         
> iterations=test_iterations)
> +            test_tag = dict.get("shortname")
> +            # Setting up kvm_stat profiling during test execution.
> +            # We don't need kvm_stat profiling on the build tests.
> +            if "build" in test_tag:

It might be cleaner to use a new parameter, such as 'run_kvm_stat' or
'with_kvm_stat' instead of checking the test tag, because 'build' can
appear in other tests as well (e.g. 'Fedora.11.32.autotest.kernelbuild').

> +                # None because it's the default value on the
> base_test class
> +                # and the value None is specifically checked there.
> +                profile = None
> +            else:
> +                profile = True
> +
> +            if profile:
> +                job.profilers.add('kvm_stat')
> +            # We need only one execution, profiled, hence we're
> passing
> +            # the profile_only parameter to job.run_test().
> +            current_status = job.run_test("kvm", params=dict,
> tag=test_tag,
> +                                         
> iterations=test_iterations,
> +                                          profile_only=profile)
> +            if profile:
> +                job.profilers.delete('kvm_stat')
> +
>              if not current_status:
>                  failed = True
>          else:
> -- 
> 1.6.5.2
> 
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to