Home | History | Annotate | Download | only in platform_GesturesRegressionTest
      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 import sys
      7 from autotest_lib.client.bin import test, utils
      8 
      9 
     10 _PLATFORM_MAPPINGS = {'daisy': 'snow',
     11                       'daisy_spring': 'spring',
     12                       'x86-alex': 'alex',
     13                       'x86-mario': 'mario',
     14                       'x86-zgb': 'zgb'}
     15 
     16 
     17 class platform_GesturesRegressionTest(test.test):
     18     """ Wrapper of regression test of gestures library.
     19 
     20     This test takes advantage of autotest framework to execute the touchtests,
     21     i.e. regression test of gestures library, and store results of the test
     22     per build(as one of BVTs) for us to keep track of patches of gestures
     23     library and regression tests, and their score changes accordingly.
     24     """
     25     version = 1
     26 
     27     def setup(self):
     28         self.job.setup_dep(['touchpad-tests'])
     29 
     30     def run_once(self):
     31         """ Run the regression test and collect the results.
     32         """
     33         board = utils.get_current_board()
     34         platform = _PLATFORM_MAPPINGS.get(board, board)
     35 
     36         # find paths for touchpad tests
     37         root = os.path.join(self.autodir, 'deps', 'touchpad-tests')
     38         framework_dir = os.path.join(root, 'framework')
     39         tests_dir = os.path.join(root, 'tests')
     40 
     41         # create test runner
     42         sys.path.append(framework_dir)
     43         sys.path.append(root)
     44         from test_runner import ParallelTestRunner
     45         runner = ParallelTestRunner(tests_dir)
     46 
     47         # run all tests for this platform and extract results
     48         results = runner.RunAll('%s*/*' % platform, verbose=True)
     49         # TODO(dennisjeffrey): Remove all uses of self.test_results below,
     50         # including the call to self.write_perf_keyval(), once we're ready to
     51         # switch over completely from perf keyvals to output_perf_value().
     52         self.test_results = {}
     53         for key, value in results.items():
     54             score = value['score']
     55             not_integer = isinstance(score, bool) or not isinstance(score, int)
     56             if not_integer and not isinstance(score, float):
     57                 score = 0.0
     58             self.test_results[key.replace('/', '-')] = score
     59             self.output_perf_value(key.replace('/', '-'), score, 'points')
     60 
     61         # write converted test results out
     62         if self.test_results:
     63             self.write_perf_keyval(self.test_results)
     64