OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script builds and runs Chromium OS unit tests. Note that this script | 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 | 8 # utilizes the src_test stanza in chromeos-base packages. These stanzas |
9 # should both build and run the unit tests. | 9 # should both build and run the unit tests. |
10 | 10 |
11 # This script requires that you run build_packages first. | 11 # This script requires that you run build_packages first. |
12 | 12 |
13 . "$(dirname "$0")/common.sh" | 13 . "$(dirname "$0")/common.sh" |
14 | 14 |
15 get_default_board | 15 get_default_board |
16 | 16 |
17 # Flags | 17 # Flags |
18 DEFINE_string board "${DEFAULT_BOARD}" \ | 18 DEFINE_string board "${DEFAULT_BOARD}" \ |
19 "Target board of which tests were built" | 19 "Target board of which tests were built" |
20 DEFINE_string build_root "${DEFAULT_BUILD_ROOT}" \ | 20 DEFINE_string build_root "${DEFAULT_BUILD_ROOT}" \ |
21 "Root of build output" | 21 "Root of build output" |
22 DEFINE_string package_file "" \ | |
23 "File with space-separated list of packages to run unit tests" f | |
22 DEFINE_string packages "" \ | 24 DEFINE_string packages "" \ |
23 "Optional space-separated list of packages to run unit tests" p | 25 "Optional space-separated list of packages to run unit tests" p |
24 | 26 |
25 # Total count of packages with unit tests. | 27 # Total count of packages with unit tests. |
26 TEST_COUNT=0 | 28 TEST_COUNT=0 |
27 # Number of unit test failures. | 29 # Number of unit test failures. |
28 TEST_FAILURES=0 | 30 TEST_FAILURES=0 |
29 # List of packages with no unit tests. | 31 # List of packages with no unit tests. |
30 NO_UNITTESTS="" | 32 NO_UNITTESTS="" |
31 # List of packages that have unit test failures. | 33 # List of packages that have unit test failures. |
(...skipping 16 matching lines...) Expand all Loading... | |
48 # Parse command line and die if unexpected parameters given. | 50 # Parse command line and die if unexpected parameters given. |
49 FLAGS_HELP="usage: ${0} [flags]" | 51 FLAGS_HELP="usage: ${0} [flags]" |
50 FLAGS "${@}" || exit 1 | 52 FLAGS "${@}" || exit 1 |
51 eval set -- "${FLAGS_ARGV}" | 53 eval set -- "${FLAGS_ARGV}" |
52 check_flags_only_and_allow_null_arg "${@}" && set -- | 54 check_flags_only_and_allow_null_arg "${@}" && set -- |
53 | 55 |
54 set -e | 56 set -e |
55 | 57 |
56 [ -z "${FLAGS_board}" ] && die "--board required" | 58 [ -z "${FLAGS_board}" ] && die "--board required" |
57 | 59 |
58 # If no packages are specified we run all unit tests for chromeos-base | 60 # Create package list from package file and list of packages. |
59 # packages. | 61 [ -n "${FLAGS_package_file}" ] && PACKAGE_LIST="$(cat ${FLAGS_package_file})" |
60 if [ -n "${FLAGS_packages}" ]; then | 62 [ -n "${FLAGS_packages}" ] && PACKAGE_LIST="${PACKAGE_LIST} ${FLAGS_packages}" |
61 PACKAGE_LIST="${FLAGS_packages}" | 63 |
62 else | 64 # If we didn't specify packages, find all packages. |
65 if [ -z "${FLAGS_package_file}" -a -z "${FLAGS_packages}" ]; then | |
petkov
2010/11/22 20:05:23
can't you just -z "${PACKAGE_LIST}" here?
| |
63 PACKAGE_LIST=$( ./get_package_list chromeos --board="${FLAGS_board}" | | 66 PACKAGE_LIST=$( ./get_package_list chromeos --board="${FLAGS_board}" | |
64 egrep '^chromeos-base' ) | 67 egrep '^chromeos-base' ) |
65 fi | 68 fi |
66 | 69 |
67 BLACK_LIST_FILE="$(dirname "$0")/unit_test_black_list.txt" | 70 BLACK_LIST_FILE="$(dirname "$0")/unit_test_black_list.txt" |
68 | 71 |
69 for package in ${PACKAGE_LIST}; do | 72 for package in ${PACKAGE_LIST}; do |
70 if grep -xq "${package}" "${BLACK_LIST_FILE}"; then | 73 if grep -xq "${package}" "${BLACK_LIST_FILE}"; then |
71 warn "Skipping package ${package} since it is blacklisted." | 74 warn "Skipping package ${package} since it is blacklisted." |
72 continue | 75 continue |
(...skipping 14 matching lines...) Expand all Loading... | |
87 warn "${NO_UNITTESTS}" | 90 warn "${NO_UNITTESTS}" |
88 fi | 91 fi |
89 | 92 |
90 if [ ${TEST_FAILURES} -ne 0 ]; then | 93 if [ ${TEST_FAILURES} -ne 0 ]; then |
91 error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures." | 94 error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures." |
92 error "Following packages had failing tests:" | 95 error "Following packages had failing tests:" |
93 die "${FAILED_PACKAGES}" | 96 die "${FAILED_PACKAGES}" |
94 else | 97 else |
95 info "All unit tests passed." | 98 info "All unit tests passed." |
96 fi | 99 fi |
OLD | NEW |