• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Lint as: python2, python3
2# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import os
7import sys
8from autotest_lib.client.bin import test, utils
9
10
11_PLATFORM_MAPPINGS = {'daisy': 'snow',
12                      'daisy_spring': 'spring',
13                      'x86-alex': 'alex',
14                      'x86-mario': 'mario',
15                      'x86-zgb': 'zgb'}
16
17
18class platform_GesturesRegressionTest(test.test):
19    """ Wrapper of regression test of gestures library.
20
21    This test takes advantage of autotest framework to execute the touchtests,
22    i.e. regression test of gestures library, and store results of the test
23    per build(as one of BVTs) for us to keep track of patches of gestures
24    library and regression tests, and their score changes accordingly.
25    """
26    version = 1
27
28    def setup(self):
29        self.job.setup_dep(['touchpad-tests'])
30
31    def run_once(self):
32        """ Run the regression test and collect the results.
33        """
34        board = utils.get_current_board()
35        platform = _PLATFORM_MAPPINGS.get(board, board)
36
37        # find paths for touchpad tests
38        root = os.path.join(self.autodir, 'deps', 'touchpad-tests')
39        framework_dir = os.path.join(root, 'framework')
40        tests_dir = os.path.join(root, 'tests')
41        touch_firmware_test_dir = os.path.join(root, 'touch_firmware_test')
42
43        # create test runner
44        sys.path.append(framework_dir)
45        sys.path.append(touch_firmware_test_dir)
46        sys.path.append(root)
47        from test_runner import ParallelTestRunner
48        runner = ParallelTestRunner(tests_dir)
49
50        # run all tests for this platform and extract results
51        results = runner.RunAll('%s*/*' % platform, verbose=True)
52        # TODO(dennisjeffrey): Remove all uses of self.test_results below,
53        # including the call to self.write_perf_keyval(), once we're ready to
54        # switch over completely from perf keyvals to output_perf_value().
55        self.test_results = {}
56        for key, value in results.items():
57            score = value['score']
58            not_integer = isinstance(score, bool) or not isinstance(score, int)
59            if not_integer and not isinstance(score, float):
60                score = 0.0
61            self.test_results[key.replace('/', '-')] = score
62            self.output_perf_value(key.replace('/', '-'), score, 'points')
63
64        # write converted test results out
65        if self.test_results:
66            self.write_perf_keyval(self.test_results)
67