| 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 "" \ | 22 DEFINE_string package_file "" \ |
| 23 "File with space-separated list of packages to run unit tests" f | 23 "File with space-separated list of packages to run unit tests" f |
| 24 DEFINE_string packages "" \ | 24 DEFINE_string packages "" \ |
| 25 "Optional space-separated list of packages to run unit tests" p | 25 "Optional space-separated list of packages to run unit tests" p |
| 26 DEFINE_boolean withdebug "${FLAGS_TRUE}" \ |
| 27 "Build debug versions of Chromium-OS-specific packages." |
| 26 | 28 |
| 27 # Total count of packages with unit tests. | 29 # Total count of packages with unit tests. |
| 28 TEST_COUNT=0 | 30 TEST_COUNT=0 |
| 29 # Number of unit test failures. | 31 # Number of unit test failures. |
| 30 TEST_FAILURES=0 | 32 TEST_FAILURES=0 |
| 31 # List of packages with no unit tests. | 33 # List of packages with no unit tests. |
| 32 NO_UNITTESTS="" | 34 NO_UNITTESTS="" |
| 33 # List of packages that have unit test failures. | 35 # List of packages that have unit test failures. |
| 34 FAILED_PACKAGES="" | 36 FAILED_PACKAGES="" |
| 35 | 37 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 [ -n "${FLAGS_packages}" ] && PACKAGE_LIST="${PACKAGE_LIST} ${FLAGS_packages}" | 71 [ -n "${FLAGS_packages}" ] && PACKAGE_LIST="${PACKAGE_LIST} ${FLAGS_packages}" |
| 70 | 72 |
| 71 # If we didn't specify packages, find all packages. | 73 # If we didn't specify packages, find all packages. |
| 72 if [ -z "${FLAGS_package_file}" -a -z "${FLAGS_packages}" ]; then | 74 if [ -z "${FLAGS_package_file}" -a -z "${FLAGS_packages}" ]; then |
| 73 PACKAGE_LIST=$( ./get_package_list chromeos --board="${FLAGS_board}" | | 75 PACKAGE_LIST=$( ./get_package_list chromeos --board="${FLAGS_board}" | |
| 74 egrep '^chromeos-base' ) | 76 egrep '^chromeos-base' ) |
| 75 fi | 77 fi |
| 76 | 78 |
| 77 BLACK_LIST_FILE="$(dirname "$0")/unit_test_black_list.txt" | 79 BLACK_LIST_FILE="$(dirname "$0")/unit_test_black_list.txt" |
| 78 | 80 |
| 81 if [ "${FLAGS_withdebug}" -eq "${FLAGS_FALSE}" ]; then |
| 82 export USE="${USE} -cros-debug" |
| 83 fi |
| 84 |
| 79 for package in ${PACKAGE_LIST}; do | 85 for package in ${PACKAGE_LIST}; do |
| 80 if grep -xq "${package}" "${BLACK_LIST_FILE}"; then | 86 if grep -xq "${package}" "${BLACK_LIST_FILE}"; then |
| 81 warn "Skipping package ${package} since it is blacklisted." | 87 warn "Skipping package ${package} since it is blacklisted." |
| 82 continue | 88 continue |
| 83 fi | 89 fi |
| 84 EBUILD_PATH=$( equery-${FLAGS_board} which ${package} 2> /dev/null ) || \ | 90 EBUILD_PATH=$( equery-${FLAGS_board} which ${package} 2> /dev/null ) || \ |
| 85 warn "${package} not found" | 91 warn "${package} not found" |
| 86 if [ -n "${EBUILD_PATH}" ]; then | 92 if [ -n "${EBUILD_PATH}" ]; then |
| 87 if check_src_test "${EBUILD_PATH}"; then | 93 if check_src_test "${EBUILD_PATH}"; then |
| 88 run_unit_test "${EBUILD_PATH}" || record_test_failure "${package}" | 94 run_unit_test "${EBUILD_PATH}" || record_test_failure "${package}" |
| 89 else | 95 else |
| 90 NO_UNITTESTS="${NO_UNITTESTS} ${package}" | 96 NO_UNITTESTS="${NO_UNITTESTS} ${package}" |
| 91 fi | 97 fi |
| 92 TEST_COUNT=$(( TEST_COUNT + 1 )) | 98 TEST_COUNT=$(( TEST_COUNT + 1 )) |
| 93 fi | 99 fi |
| 94 done | 100 done |
| 95 | 101 |
| 96 if [ -n "${NO_UNITTESTS}" ]; then | 102 if [ -n "${NO_UNITTESTS}" ]; then |
| 97 warn "The following packages have no unit tests:" | 103 warn "The following packages have no unit tests:" |
| 98 warn "${NO_UNITTESTS}" | 104 warn "${NO_UNITTESTS}" |
| 99 fi | 105 fi |
| 100 | 106 |
| 101 if [ ${TEST_FAILURES} -ne 0 ]; then | 107 if [ ${TEST_FAILURES} -ne 0 ]; then |
| 102 error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures." | 108 error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures." |
| 103 error "Following packages had failing tests:" | 109 error "Following packages had failing tests:" |
| 104 die "${FAILED_PACKAGES}" | 110 die "${FAILED_PACKAGES}" |
| 105 else | 111 else |
| 106 info "All unit tests passed." | 112 info "All unit tests passed." |
| 107 fi | 113 fi |
| OLD | NEW |