mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-27 00:21:44 +02:00
Check in to run unittests that uses src_test to build and run unittests.
TEST=Ran unittests with 2 test failures (powerd and update engine). Will check with authors to fix these before moving the default over to this. Review URL: http://codereview.chromium.org/2837004
This commit is contained in:
parent
07eac9ef47
commit
d97985240a
@ -303,9 +303,14 @@ function check_flags_only_and_allow_null_arg {
|
|||||||
|
|
||||||
V_RED="\e[31m"
|
V_RED="\e[31m"
|
||||||
V_YELLOW="\e[33m"
|
V_YELLOW="\e[33m"
|
||||||
|
V_BOLD_GREEN="\e[1;32m"
|
||||||
V_BOLD_RED="\e[1;31m"
|
V_BOLD_RED="\e[1;31m"
|
||||||
V_BOLD_YELLOW="\e[1;33m"
|
V_BOLD_YELLOW="\e[1;33m"
|
||||||
|
|
||||||
|
function info {
|
||||||
|
echo -e "${V_BOLD_GREEN}INFO : $1${V_VIDOFF}"
|
||||||
|
}
|
||||||
|
|
||||||
function warn {
|
function warn {
|
||||||
echo -e "${V_BOLD_YELLOW}WARNING: $1${V_VIDOFF}"
|
echo -e "${V_BOLD_YELLOW}WARNING: $1${V_VIDOFF}"
|
||||||
}
|
}
|
||||||
|
89
cros_run_unit_tests
Executable file
89
cros_run_unit_tests
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
# This script builds and runs Chromium OS unit tests. Note that this script
|
||||||
|
# utilizes the src_test stanza in chromeos-base packages. These stanzas
|
||||||
|
# should both build and run the unit tests.
|
||||||
|
|
||||||
|
# This script requires that you run build_packages first.
|
||||||
|
|
||||||
|
. "$(dirname "$0")/common.sh"
|
||||||
|
|
||||||
|
get_default_board
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
DEFINE_string board "${DEFAULT_BOARD}" \
|
||||||
|
"Target board of which tests were built"
|
||||||
|
DEFINE_string build_root "${DEFAULT_BUILD_ROOT}" \
|
||||||
|
"Root of build output"
|
||||||
|
DEFINE_string packages "" \
|
||||||
|
"Optional space-separated list of packages to run unit tests" p
|
||||||
|
|
||||||
|
# Total count of packages with unit tests.
|
||||||
|
TEST_COUNT=0
|
||||||
|
# Number of unit test failures.
|
||||||
|
TEST_FAILURES=0
|
||||||
|
# List of packages with no unit tests.
|
||||||
|
NO_UNITTESTS=""
|
||||||
|
# List of packages that have unit test failures.
|
||||||
|
FAILED_PACKAGES=""
|
||||||
|
|
||||||
|
function check_src_test() {
|
||||||
|
egrep '^src_test()' "${1}" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function record_test_failure() {
|
||||||
|
TEST_FAILURES=$(( TEST_FAILURES + 1 ))
|
||||||
|
FAILED_PACKAGES="${FAILED_PACKAGES} ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_unit_test() {
|
||||||
|
FEATURES="-buildpkg -digest noauto" \
|
||||||
|
ebuild-${FLAGS_board} "${1}" clean unpack test
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command line and die if unexpected paramters given.
|
||||||
|
FLAGS_HELP="usage: ${0} [flags]"
|
||||||
|
FLAGS "${@}" || exit 1
|
||||||
|
eval set -- "${FLAGS_ARGV}"
|
||||||
|
check_flags_only_and_allow_null_arg "${@}" && set --
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
[ -z "${FLAGS_board}" ] && die "--board required"
|
||||||
|
|
||||||
|
# If no packages are specified we run all unit tests for chromeos-base
|
||||||
|
# packages.
|
||||||
|
if [ -n "${FLAGS_packages}" ]; then
|
||||||
|
PACKAGE_LIST="${FLAGS_packages}"
|
||||||
|
else
|
||||||
|
PACKAGE_LIST=$( ./get_package_list chromeos | egrep '^chromeos-base' )
|
||||||
|
fi
|
||||||
|
|
||||||
|
for package in ${PACKAGE_LIST}; do
|
||||||
|
EBUILD_PATH=$( equery-${FLAGS_board} which ${package} 2> /dev/null )
|
||||||
|
if [ -n "${EBUILD_PATH}" ]; then
|
||||||
|
if check_src_test "${EBUILD_PATH}"; then
|
||||||
|
run_unit_test "${EBUILD_PATH}" || record_test_failure "${package}"
|
||||||
|
else
|
||||||
|
NO_UNITTESTS="${NO_UNITTESTS} ${package}"
|
||||||
|
fi
|
||||||
|
TEST_COUNT=$(( TEST_COUNT + 1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "${NO_UNITTESTS}" ]; then
|
||||||
|
warn "The following packages have no unit tests:"
|
||||||
|
warn "${NO_UNITTESTS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${TEST_FAILURES} -ne 0 ]; then
|
||||||
|
error "Run completed with ${TEST_FAILURES}/${TEST_COUNT} test failures."
|
||||||
|
error "Following packages had failing tests:"
|
||||||
|
die "${FAILED_PACKAGES}"
|
||||||
|
else
|
||||||
|
info "All unit tests passed."
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user