summaryrefslogtreecommitdiff
path: root/tools/regression_test.sh
blob: f97118ac2854045e5e94cf382a1da4f08fb5fe75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

# Copyright 2012 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Script to run the gesture regression test and check if there is any
# regression for each submit.

# Set current directory to the project one and load the common script.
pushd . >/dev/null
cd "$(dirname "$(readlink -f "$0")")/.."
. "../../scripts/common.sh" || exit 1

update_chroot_library() {
  library=$1
  version=$2
  project=$3
  info "Check chroot $library version ${version}..."

  if ! grep -q ${version} /usr/lib/${library} ; then
    info "Update the library ${library} under chroot.."
    sudo emerge -q ${project}
    info grep ${version} /usr/lib/${library}
    if ! grep -q ${version} /usr/lib/${library} ; then
      die_notrace "Can not install ${library} successfully"
    fi
  fi
}

install_regression_test_suite() {
  info "Install regression test suite first..."
  sudo emerge -q gestures chromeos-base/libevdev utouch-evemu -j3
  pushd ~/trunk/src/platform/touchpad-tests >/dev/null
  make -j${NUM_JOBS} -s all
  sudo make -s local-install
  popd >/dev/null
}

run_regression_tests() {
  info "Running regression tests..."
  if ! type touchtests > /dev/null; then
    die_notrace \
      "The touchtests aren't installed in your chroot. Please install them: "\
      "https://chromium.googlesource.com/chromiumos/platform/touchpad-tests/+/HEAD/README.md#Setting-up"
  fi
  if ! touchtests --presubmit --ref tools/touchtests-report.json; then
    die_notrace "Regression tests failed."
  fi
}

check_test_setup() {
  if [[ ! -e  /usr/lib/libgestures.so ]]; then
    install_regression_test_suite
  else
    update_chroot_library libgestures.so ${libgestures_head_hash} gestures
    update_chroot_library libevdev-cros.so ${libevdev_head_hash} \
      chromeos-base/libevdev
  fi
}

libevdev_head_hash=`cd ../libevdev; git rev-parse HEAD`
libgestures_head_hash=`git rev-parse HEAD`
if [[ ${INSIDE_CHROOT} -ne 1 ]]; then
  if [[ "${PRESUBMIT_COMMIT}" == "${libgestures_head_hash}" ]]; then
    popd >/dev/null
    restart_in_chroot_if_needed "$@"
  fi
else
  cros_workon --host start gestures chromeos-base/libevdev
  check_test_setup
  run_regression_tests
  popd >/dev/null
fi
exit 0