run revision 6ad1f2da4055e2cfe9bf8c79b79e408dba171691
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run continuous integration tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Copyright (C) 2014 Red Hat
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# This program is free software; you can redistribute it and/or modify
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# it under the terms of the GNU General Public License as published by
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# the Free Software Foundation; either version 3 of the License, or
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# (at your option) any later version.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# This program is distributed in the hope that it will be useful,
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# but WITHOUT ANY WARRANTY; without even the implied warranty of
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# GNU General Public License for more details.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# You should have received a copy of the GNU General Public License
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# along with this program. If not, see <http://www.gnu.org/licenses/>.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Minimum percentage of code lines covered by tests
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Minimum percentage of code functions covered by tests
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Output program usage information.
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyUsage: `basename "$0"` [OPTION...]
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyRun continuous integration tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -h, --help Output this help message and exit.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -p, --prefix=STRING Use STRING as the prefix to prepend to file and
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny directory paths in output.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -n, --no-deps Don't attempt to install dependencies.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -e, --essential Run the essential subset of tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -m, --moderate Run the moderate subset of tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -r, --rigorous,
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -f, --full Run the rigorous (full) set of tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyDefault options: --essential
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Output a file display path: a path relocated from base directory (BASE_DIR)
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# to base prefix (BASE_PFX).
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run a stage.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: id cmd [arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Execute mock as is, or, if the user is not in the "mock" group, under sudo,
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# which has password prompt/input on the console, instead of stderr/stdin.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: [mock_arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny prompt+="To run mock enter sudo password for $USER: "
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Execute mock_privileged with extra chroot configuration added.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: chroot [mock_arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Input: extra configuration
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Preserve timestamps to avoid unnecessary cache rebuilds
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny cp -r --preserve=timestamps /etc/mock/* "$conf_dir"/
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Execute mock_privileged with dependency package source configuration added.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: chroot [mock_arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozekconfig_opts['yum.conf'] += '''
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyname=Extra SSSD dependencies
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenybaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyskip_if_unavailable=true
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run debug build checks.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Extended glob pattern matching tests to run under Valgrind.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny !(*.py|*/dlopen-tests|*/whitespace_test|*/double_semicolon_test)"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage make-tests make -j $CPU_NUM check LOG_COMPILER=true
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny valgrind-condense 99 \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek --trace-children=yes \
ac3a1f3da772cf101101c31675c63dc3549b21b5Jakub Hrozek --trace-children-skip='*/bin/*,*/sbin/*' \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --leak-check=full \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --gen-suppressions=all \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --suppressions=\"$CI_DIR/sssd.supp\" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage make-intgcheck make -j $CPU_NUM intgcheck \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny test_dir_distcheck=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek # Single thread due to https://fedorahosted.org/sssd/ticket/2354
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage mock-build mock_privileged_deps "default" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run coverage build checks.
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher declare -r coverage_report_dir="ci-report-coverage"
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher if [[ "$DISTRO_BRANCH" == -redhat-redhatenterprise*-6.*- ||
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # enable optimisation to avoid bug in gcc < 4.6.0
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # gcc commit 7959b7e646b493f48a2ea7228fbf1c43f84bedea
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162384
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage make-tests make -j $CPU_NUM check LOG_COMPILER=true
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage lcov-pre lcov --capture --initial --directory . \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage make-check make -j $CPU_NUM check || status=$?
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage lcov-merge lcov --add-tracefile ci-base.info \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage lcov-clean lcov --remove ci-dirty.info \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage genhtml eval 'genhtml --output-directory \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher "$coverage_report_dir" \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher --title "sssd" --show-details \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher --legend --prefix "$BASE_DIR" \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher "`disppath \"\$coverage_report_dir/index.html\"`"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "$COVERAGE_MIN_FUNCS" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run a build inside a sub-directory.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: id cmd [arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Main routine
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher DEPS=false; shift;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher shift; break;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherif [ $# != 0 ]; then
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher echo "Positional arguments are not accepted." >&2