Home | History | Annotate | Download | only in telemetry_UnitTests
      1 # Copyright (c) 2013 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.
      4 
      5 import os
      6 from autotest_lib.client.bin import test
      7 from autotest_lib.client.common_lib import error
      8 from telemetry.testing import run_chromeos_tests
      9 
     10 
     11 class telemetry_UnitTests(test.test):
     12     """This is a client side wrapper for the Telemetry unit tests."""
     13     version = 1
     14 
     15 
     16     def run_once(self, browser_type, unit_tests, perf_tests):
     17         """Runs telemetry/perf unit tests.
     18 
     19         @param browser_type: The string type of browser to use, e.g., 'system'.
     20         @param unit_tests: list of unit tests to run, [''] is all tests,
     21                            [] is no tests.
     22         @param perf_tests: list of perf unit tests to run, [''] is all tests,
     23                            [] is no tests.
     24         """
     25         tests_to_run = []
     26         tools_dir = '/usr/local/telemetry/src/tools/'
     27         if unit_tests:
     28             tests_to_run.append((os.path.join(tools_dir, 'telemetry'),
     29                                  unit_tests))
     30         if perf_tests:
     31             tests_to_run.append((os.path.join(tools_dir, 'perf'),
     32                                  perf_tests))
     33         error_str = run_chromeos_tests.RunChromeOSTests(browser_type,
     34                                                         tests_to_run)
     35         if error_str:
     36             raise error.TestFail(error_str)
     37