Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cros_run_unit_tests

Issue 2837004: Check in to run unittests that uses src_test to build and run unittests. (Closed) Base URL: ssh://git@chromiumos-git//crosutils.git
Patch Set: Petkov Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # This script builds and runs Chromium OS unit tests. Note that this script
8 # utilizes the src_test stanza in chromeos-base packages. These stanzas
9 # should both build and run the unit tests.
10
11 # This script requires that you run build_packages first.
12
13 . "$(dirname "$0")/common.sh"
14
15 get_default_board
16
17 # Flags
18 DEFINE_string board "${DEFAULT_BOARD}" \
19 "Target board of which tests were built"
20 DEFINE_string build_root "${DEFAULT_BUILD_ROOT}" \
21 "Root of build output"
22 DEFINE_string packages "" \
23 "Optional space-separated list of packages to run unit tests" p
24
25 # Total count of packages with unit tests.
26 TEST_COUNT=0
27 # Number of unit test failures.
28 TEST_FAILURES=0
29 # List of packages with no unit tests.
30 NO_UNITTESTS=""
31 # List of packages that have unit test failures.
32 FAILED_PACKAGES=""
33
34 function check_src_test() {
35 egrep '^src_test()' "${1}" > /dev/null
36 }
37
38 function record_test_failure() {
39 TEST_FAILURES=$(( TEST_FAILURES + 1 ))
40 FAILED_PACKAGES="${FAILED_PACKAGES} ${1}"
41 }
42
43 function run_unit_test() {
44 FEATURES="-buildpkg -digest noauto" \
45 ebuild-${FLAGS_board} "${1}" clean unpack test
46 }
47
48 # Parse command line and die if unexpected paramters given.
49 FLAGS_HELP="usage: ${0} [flags]"
50 FLAGS "${@}" || exit 1
51 eval set -- "${FLAGS_ARGV}"
52 check_flags_only_and_allow_null_arg "${@}" && set --
53
54 set -e
55
56 [ -z "${FLAGS_board}" ] && die "--board required"
57
58 # If no packages are specified we run all unit tests for chromeos-base
59 # packages.
60 if [ -n "${FLAGS_packages}" ]; then
61 PACKAGE_LIST="${FLAGS_packages}"
62 else
63 PACKAGE_LIST=$( ./get_package_list chromeos | egrep '^chromeos-base' )
64 fi
65
66 for package in ${PACKAGE_LIST}; do
67 EBUILD_PATH=$( equery-${FLAGS_board} which ${package} 2> /dev/null )
68 if [ -n "${EBUILD_PATH}" ]; then
69 if check_src_test "${EBUILD_PATH}"; then
70 run_unit_test "${EBUILD_PATH}" || record_test_failure "${package}"
71 else
72 NO_UNITTESTS="${NO_UNITTESTS} ${package}"
73 fi
74 TEST_COUNT=$(( TEST_COUNT + 1 ))
75 fi
76 done
77
78 if [ -n "${NO_UNITTESTS}" ]; then
79 warn "The following packages have no unit tests:"
80 warn "${NO_UNITTESTS}"
81 fi
82
83 if [ ${TEST_FAILURES} -ne 0 ]; then
84 error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures."
85 error "Following packages had failing tests:"
86 die "${FAILED_PACKAGES}"
87 else
88 info "All unit tests passed."
89 fi
OLDNEW
« no previous file with comments | « common.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698