run revision 6ad1f2da4055e2cfe9bf8c79b79e408dba171691
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#!/bin/bash
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run continuous integration tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Copyright (C) 2014 Red Hat
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#
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#
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#
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 Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyset -o nounset -o pipefail -o errexit
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyexport PATH=$CI_DIR:$PATH
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyexport LC_ALL=C
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny. deps.sh
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny. distro.sh
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny. configure.sh
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny. misc.sh
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r DEBUG_CFLAGS="-g3 -O2"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r ARCH=`uname -m`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r TITLE_WIDTH=24
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r RESULT_WIDTH=18
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Minimum percentage of code lines covered by tests
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r COVERAGE_MIN_LINES=15
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Minimum percentage of code functions covered by tests
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare -r COVERAGE_MIN_FUNCS=0
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare BASE_PFX=""
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare DEPS=true
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare BASE_DIR=`pwd`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenydeclare MODERATE=false
684d1b48b5582a1bf7812b8c3c663592dc6dfed9Pavel Březinadeclare RIGOROUS=false
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Output program usage information.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction usage()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny cat <<EOF
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyUsage: `basename "$0"` [OPTION...]
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyRun continuous integration tests.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyOptions:
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 Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyDefault options: --essential
f26c954658dfd7461f290f0b5d924951a6db219aJan ZelenyEOF
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Output a file display path: a path relocated from base directory (BASE_DIR)
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# to base prefix (BASE_PFX).
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: path
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction disppath()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r path=`readlink -f "$1"`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run a stage.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: id cmd [arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction stage()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r id="$1"; shift
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r log="ci-$id.log"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare status
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare start
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare end
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare duration
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "%-${TITLE_WIDTH}s" "$id:"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny {
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "Start: "
684d1b48b5582a1bf7812b8c3c663592dc6dfed9Pavel Březina start=`date +%s`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny date --date="@$start"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny set +o errexit
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny (
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny set -o errexit -o xtrace
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "$@"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny )
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny status=$?
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny set -o errexit
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "End: "
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny end=`date +%s`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny date --date="@$end"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny } &> "$log"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny duration=$((end - start))
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny if [ "$status" == 0 ]; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf 'success '
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny else
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf 'failure '
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "%02u:%02u:%02u " \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny $((duration / (60 * 60))) \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny $((duration / 60 % 60)) \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny $((duration % 60))
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny disppath "$log"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "\n"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny return "$status"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
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 Zelenyfunction mock_privileged()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny if memberof mock; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mock "$@"
684d1b48b5582a1bf7812b8c3c663592dc6dfed9Pavel Březina else
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare prompt=$'Not a "mock" group member.\n'
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny prompt+="To run mock enter sudo password for $USER: "
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny sudo -p "$prompt" mock "$@"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Execute mock_privileged with extra chroot configuration added.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: chroot [mock_arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Input: extra configuration
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction mock_privileged_conf()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r chroot="$1"; shift
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare conf_dir
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny trap 'trap - RETURN; rm -R "$conf_dir";' RETURN
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Preserve timestamps to avoid unnecessary cache rebuilds
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny cp -r --preserve=timestamps /etc/mock/* "$conf_dir"/
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny cat >> "${conf_dir}/${chroot}.cfg"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Execute mock_privileged with dependency package source configuration added.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: chroot [mock_arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction mock_privileged_deps()
e30d02c04efad31f97c35165a92105852c805d34Jakub Hrozek{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r chroot_name="$1"; shift
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r chroot="${config%.cfg}"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare repo
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny if [[ "$chroot" == fedora-* ]]; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny repo='fedora-$releasever-$basearch'
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny repo="epel-${BASH_REMATCH[1]}-\$basearch"
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek else
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny echo "Unknown chroot config: $chroot" >&2
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny exit 1
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mock_privileged_conf "$chroot" "$@" <<<"
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozekconfig_opts['yum.conf'] += '''
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek[sssd-deps]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyname=Extra SSSD dependencies
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenybaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyskip_if_unavailable=true
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenygpgcheck=0
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyenabled=1
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny'''
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run debug build checks.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction build_debug()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Extended glob pattern matching tests to run under Valgrind.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # NOTE: The particular pattern below is inverted
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r valgrind_test_pattern="\
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny !(*.py|*/dlopen-tests|*/whitespace_test|*/double_semicolon_test)"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny export CFLAGS="$DEBUG_CFLAGS"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare test_dir
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare test_dir_distcheck
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare intgcheck_configure_args
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare distcheck_configure_args
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare status
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage configure "$BASE_DIR/configure" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "${CONFIGURE_ARG_LIST[@]}" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --with-test-dir="$test_dir" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny SHELL=/bin/sh
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
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
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek status=0
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek CK_FORK=no \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage make-check-valgrind \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek make -j $CPU_NUM check \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek LOG_COMPILER=libtool \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny LOG_FLAGS="--mode=execute \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny valgrind-condense 99 \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny \"$valgrind_test_pattern\" -- \
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 --verbose" ||
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny status=$?
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mv "$test_dir" ci-test-dir
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny ((status == 0))
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny if "$MODERATE"; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny if "$DEPS_INTGCHECK_SATISFIED"; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf -v intgcheck_configure_args " %q" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "${CONFIGURE_ARG_LIST[@]}"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage make-intgcheck make -j $CPU_NUM intgcheck \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny INTGCHECK_CONFIGURE_FLAGS=" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny $intgcheck_configure_args"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
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 status=0
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek printf -v distcheck_configure_args " %q" \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek "${CONFIGURE_ARG_LIST[@]}" \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek "--with-test-dir=$test_dir_distcheck"
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage make-distcheck make distcheck \
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek AUX_DISTCHECK_CONFIGURE_FLAGS=" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny $distcheck_configure_args" ||
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny status=$?
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek mv "$test_dir_distcheck" ci-test-dir-distcheck
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek ((status == 0))
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage make-srpm env -u CFLAGS -- make srpm
88ab259f993956b6cd0b1a07d3d88d105e368a8cJakub Hrozek stage mock-build mock_privileged_deps "default" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --resultdir ci-mock-result \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny rpmbuild/SRPMS/*.src.rpm
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny fi
9091fdea936f7d21584682b7f3d58f49b1e7b013Jan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny unset CFLAGS
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run coverage build checks.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction build_coverage()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher declare -r coverage_report_dir="ci-report-coverage"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare extra_CFLAGS=""
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher declare test_dir
9fcfe80902655f495b7258218fc8114aa5d2c023Stephen Gallagher declare status
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher if [[ "$DISTRO_BRANCH" == -redhat-redhatenterprise*-6.*- ||
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "$DISTRO_BRANCH" == -redhat-centos-6.*- ]]; then
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
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # 138bc75d-0d04-0410-961f-82ee72b054a4
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher extra_CFLAGS=" -O1"
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher fi
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny export CFLAGS="$COVERAGE_CFLAGS $extra_CFLAGS"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage configure "$BASE_DIR/configure" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "${CONFIGURE_ARG_LIST[@]}" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --with-test-dir="$test_dir"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Build everything, including tests
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
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage lcov-pre lcov --capture --initial --directory . \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --base-directory "$BASE_DIR" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --output-file ci-base.info
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny # Run tests
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny status=$?
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage make-check make -j $CPU_NUM check || status=$?
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mv "$test_dir" ci-test-dir
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny ((status == 0))
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage lcov-post lcov --capture --directory . \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --base-directory "$BASE_DIR" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --output-file ci-check.info
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage lcov-merge lcov --add-tracefile ci-base.info \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher --add-tracefile ci-check.info \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher --output-file ci-dirty.info
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage lcov-clean lcov --remove ci-dirty.info \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher "/usr/*" "src/tests/*" "/tmp/*" \
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher --output-file ci.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 ci.info |& tee ci-genhtml.out'
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher "coverage report:" \
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher "`disppath \"\$coverage_report_dir/index.html\"`"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "$COVERAGE_MIN_FUNCS" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny < ci-genhtml.out'
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny unset CFLAGS
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Run a build inside a sub-directory.
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Args: id cmd [arg...]
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyfunction run_build()
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny{
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r id="$1"; shift
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny declare -r dir="ci-build-$id"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny mkdir "$dir"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "${id^^} BUILD:" "`disppath \"\$dir\"`"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher cd "$dir"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny "$@"
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny cd ..
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny}
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny# Main routine
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny#
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherdeclare args_expr
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyargs_expr=`getopt --name \`basename "\$0"\` \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --options hp:nemrf \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --longoptions help,prefix:,no-deps \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny --longoptions essential,moderate,rigorous,full \
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny -- "$@"`
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallaghereval set -- "$args_expr"
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagher
169fa5bd3edd34aa0db35681832bd7406e423c1bStephen Gallagherwhile true; do
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher case "$1" in
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -h|--help)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher usage; exit 0;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -p|--prefix)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher BASE_PFX="$2"; shift 2;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -n|--no-deps)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher DEPS=false; shift;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -e|--essential)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher MODERATE=false; RIGOROUS=false; shift;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -m|--moderate)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher MODERATE=true; RIGOROUS=false; shift;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher -r|--rigorous|-f|--full)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher MODERATE=true; RIGOROUS=true; shift;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher --)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher shift; break;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher *)
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher echo "Unknown option: $1" >&2
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher exit 1;;
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher esac
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherdone
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherif [ $# != 0 ]; then
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher echo "Positional arguments are not accepted." >&2
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher usage >&2
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher exit 1
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherfi
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallaghertrap 'echo FAILURE' EXIT
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherrm_rf_ro ci-*
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherexport V=1
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherif "$DEPS"; then
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagher stage install-deps deps_install
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherfi
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherstage autoreconf autoreconf --install --force
2f3ee3f49019f5b60adbe073070f31e6e2d7c7abStephen Gallagherrun_build debug build_debug
2f3ee3f49019f5b60adbe073070f31e6e2d7c7abStephen Gallagherif "$RIGOROUS"; then
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny run_build coverage build_coverage
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallagherfi
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyunset V
38e1ee5d65ade946f1322efa96f69c05e041c57fStephen Gallaghertrap - EXIT
f26c954658dfd7461f290f0b5d924951a6db219aJan Zelenyecho SUCCESS
f26c954658dfd7461f290f0b5d924951a6db219aJan Zeleny