• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright 2012 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Script to run the gesture regression test and check if there is any
8# regression for each submit.
9
10# Set current directory to the project one and load the common script.
11pushd . >/dev/null
12cd "$(dirname "$(readlink -f "$0")")/.."
13. "../../scripts/common.sh" || exit 1
14
15update_chroot_library() {
16  library=$1
17  version=$2
18  project=$3
19  info "Check chroot $library version ${version}..."
20
21  if ! grep -q ${version} /usr/lib/${library} ; then
22    info "Update the library ${library} under chroot.."
23    sudo emerge -q ${project}
24    info grep ${version} /usr/lib/${library}
25    if ! grep -q ${version} /usr/lib/${library} ; then
26      die_notrace "Can not install ${library} successfully"
27    fi
28  fi
29}
30
31install_regression_test_suite() {
32  info "Install regression test suite first..."
33  sudo emerge -q gestures chromeos-base/libevdev utouch-evemu -j3
34  pushd ~/trunk/src/platform/touchpad-tests >/dev/null
35  make -j${NUM_JOBS} -s all
36  sudo make -s local-install
37  popd >/dev/null
38}
39
40run_regression_tests() {
41  info "Running regression tests..."
42  if ! type touchtests > /dev/null; then
43    die_notrace \
44      "The touchtests aren't installed in your chroot. Please install them: "\
45      "https://chromium.googlesource.com/chromiumos/platform/touchpad-tests/+/HEAD/README.md#Setting-up"
46  fi
47  if ! touchtests --presubmit --ref tools/touchtests-report.json; then
48    die_notrace "Regression tests failed."
49  fi
50}
51
52check_test_setup() {
53  if [[ ! -e  /usr/lib/libgestures.so ]]; then
54    install_regression_test_suite
55  else
56    update_chroot_library libgestures.so ${libgestures_head_hash} gestures
57    update_chroot_library libevdev-cros.so ${libevdev_head_hash} \
58      chromeos-base/libevdev
59  fi
60}
61
62libevdev_head_hash=`cd ../libevdev; git rev-parse HEAD`
63libgestures_head_hash=`git rev-parse HEAD`
64if [[ ${INSIDE_CHROOT} -ne 1 ]]; then
65  if [[ "${PRESUBMIT_COMMIT}" == "${libgestures_head_hash}" ]]; then
66    popd >/dev/null
67    restart_in_chroot_if_needed "$@"
68  fi
69else
70  cros_workon --host start gestures chromeos-base/libevdev
71  check_test_setup
72  run_regression_tests
73  popd >/dev/null
74fi
75exit 0
76