run revision 9d453f1e8b28983b363b44c49b7cd701a994fd97
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#!/bin/bash
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Run continuous integration tests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Copyright (C) 2014 Red Hat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This program is free software; you can redistribute it and/or modify
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# it under the terms of the GNU General Public License as published by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# the Free Software Foundation; either version 3 of the License, or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# (at your option) any later version.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This program is distributed in the hope that it will be useful,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# but WITHOUT ANY WARRANTY; without even the implied warranty of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# GNU General Public License for more details.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You should have received a copy of the GNU General Public License
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# along with this program. If not, see <http://www.gnu.org/licenses/>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteset -o nounset -o pipefail -o errexit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalliexport PATH=$CI_DIR:$PATH
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexport LC_ALL=C
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte. deps.sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte. distro.sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte. configure.sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte. misc.sh
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r DEBUG_CFLAGS="-g3 -O2"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r ARCH=`uname -m`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r TITLE_WIDTH=24
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r RESULT_WIDTH=18
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Minimum percentage of code lines covered by tests
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r COVERAGE_MIN_LINES=15
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Minimum percentage of code functions covered by tests
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare -r COVERAGE_MIN_FUNCS=0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare BASE_PFX=""
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare DEPS=true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare BASE_DIR=`pwd`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare MODERATE=false
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedeclare RIGOROUS=false
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Output program usage information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction usage()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cat <<EOF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUsage: `basename "$0"` [OPTION...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRun continuous integration tests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOptions:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -h, --help Output this help message and exit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -p, --prefix=STRING Use STRING as the prefix to prepend to file and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte directory paths in output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -n, --no-deps Don't attempt to install dependencies.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -e, --essential Run the essential subset of tests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -m, --moderate Run the moderate subset of tests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -r, --rigorous,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte -f, --full Run the rigorous (full) set of tests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDefault options: --essential
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEOF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Output a file display path: a path relocated from base directory (BASE_DIR)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# to base prefix (BASE_PFX).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction disppath()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r path=`readlink -f "$1"`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Run a stage.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: id cmd [arg...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction stage()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r id="$1"; shift
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r log="ci-$id.log"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare duration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "%-${TITLE_WIDTH}s" "$id:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "Start: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte start=`date +%s`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte date --date="@$start"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set +o errexit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set -o errexit -o xtrace
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "$@"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte )
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status=$?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set -o errexit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "End: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte end=`date +%s`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte date --date="@$end"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } &> "$log"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte duration=$((end - start))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ "$status" == 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf 'success '
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf 'failure '
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "%02u:%02u:%02u " \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $((duration / (60 * 60))) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $((duration / 60 % 60)) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $((duration % 60))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte disppath "$log"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return "$status"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Execute mock as is, or, if the user is not in the "mock" group, under sudo,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# which has password prompt/input on the console, instead of stderr/stdin.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: [mock_arg...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction mock_privileged()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if memberof mock; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mock "$@"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare prompt=$'Not a "mock" group member.\n'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prompt+="To run mock enter sudo password for $USER: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sudo -p "$prompt" mock "$@"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Execute mock_privileged with extra chroot configuration added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: chroot [mock_arg...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Input: extra configuration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction mock_privileged_conf()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r chroot="$1"; shift
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare conf_dir
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte trap 'trap - RETURN; rm -R "$conf_dir";' RETURN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Preserve timestamps to avoid unnecessary cache rebuilds
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp -r --preserve=timestamps /etc/mock/* "$conf_dir"/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cat >> "${conf_dir}/${chroot}.cfg"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Execute mock_privileged with dependency package source configuration added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: chroot [mock_arg...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction mock_privileged_deps()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r chroot_name="$1"; shift
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r chroot="${config%.cfg}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare repo
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [[ "$chroot" == fedora-* ]]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte repo='fedora-$releasever-$basearch'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte repo="epel-${BASH_REMATCH[1]}-\$basearch"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill echo "Unknown chroot config: $chroot" >&2
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill exit 1
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill fi
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill mock_privileged_conf "$chroot" "$@" <<<"
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gillconfig_opts['yum.conf'] += '''
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill[sssd-deps]
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gillname=Extra SSSD dependencies
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gillbaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gillskip_if_unavailable=true
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gillgpgcheck=0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenabled=1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte'''
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Run debug build checks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction build_debug()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte export CFLAGS="$DEBUG_CFLAGS"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare test_dir
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare test_dir_distcheck
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare intgcheck_configure_args
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare distcheck_configure_args
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage configure "$BASE_DIR/configure" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "${CONFIGURE_ARG_LIST[@]}" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --with-test-dir="$test_dir"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-tests make-check-wrap -j $CPU_NUM check -- true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status=0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CK_FORK=no \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-check-valgrind \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte make-check-wrap -j $CPU_NUM check -- \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libtool --mode=execute \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valgrind-condense 99 \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '!(*.py|*dlopen-tests)' -- \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --trace-children=yes \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --trace-children-skip='*/bin/*,*/sbin/*' \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --leak-check=full \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --gen-suppressions=all \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --suppressions="$CI_DIR/sssd.supp" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --verbose ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status=$?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mv "$test_dir" ci-test-dir
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status == 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if "$MODERATE"; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if "$DEPS_INTGCHECK_SATISFIED"; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf -v intgcheck_configure_args " %q" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "${CONFIGURE_ARG_LIST[@]}"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-intgcheck make -j $CPU_NUM intgcheck \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte INTGCHECK_CONFIGURE_FLAGS=" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $intgcheck_configure_args"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte test_dir_distcheck=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Single thread due to https://fedorahosted.org/sssd/ticket/2354
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status=0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf -v distcheck_configure_args " %q" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "${CONFIGURE_ARG_LIST[@]}" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "--with-test-dir=$test_dir_distcheck"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-distcheck make distcheck \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AUX_DISTCHECK_CONFIGURE_FLAGS=" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte $distcheck_configure_args" ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status=$?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mv "$test_dir_distcheck" ci-test-dir-distcheck
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((status == 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-srpm env -u CFLAGS -- make srpm
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage mock-build mock_privileged_deps "default" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --resultdir ci-mock-result \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rpmbuild/SRPMS/*.src.rpm
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fi
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unset CFLAGS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Run coverage build checks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction build_coverage()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r coverage_report_dir="ci-report-coverage"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare test_dir
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte export CFLAGS="$COVERAGE_CFLAGS"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage configure "$BASE_DIR/configure" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "${CONFIGURE_ARG_LIST[@]}" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --with-test-dir="$test_dir"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Build everything, including tests
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-tests make-check-wrap -j $CPU_NUM check -- true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage lcov-pre lcov --capture --initial --directory . \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --base-directory "$BASE_DIR" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --output-file ci-base.info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte # Run tests
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage make-check make -j $CPU_NUM check || true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mv "$test_dir" ci-test-dir
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage lcov-post lcov --capture --directory . \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --base-directory "$BASE_DIR" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --output-file ci-check.info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage lcov-merge lcov --add-tracefile ci-base.info \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --add-tracefile ci-check.info \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --output-file ci-dirty.info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage lcov-clean lcov --remove ci-dirty.info \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "/usr/*" "src/tests/*" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --output-file ci.info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage genhtml eval 'genhtml --output-directory \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "$coverage_report_dir" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --title "sssd" --show-details \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte --legend --prefix "$BASE_DIR" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ci.info |& tee ci-genhtml.out'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "coverage report:" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "`disppath \"\$coverage_report_dir/index.html\"`"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "$COVERAGE_MIN_FUNCS" \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte < ci-genhtml.out'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unset CFLAGS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Run a build inside a sub-directory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Args: id cmd [arg...]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunction run_build()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r id="$1"; shift
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte declare -r dir="ci-build-$id"
mkdir "$dir"
printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
"${id^^} BUILD:" "`disppath \"\$dir\"`"
cd "$dir"
"$@"
cd ..
}
#
# Main routine
#
declare args_expr
args_expr=`getopt --name \`basename "\$0"\` \
--options hp:nemrf \
--longoptions help,prefix:,no-deps \
--longoptions essential,moderate,rigorous,full \
-- "$@"`
eval set -- "$args_expr"
while true; do
case "$1" in
-h|--help)
usage; exit 0;;
-p|--prefix)
BASE_PFX="$2"; shift 2;;
-n|--no-deps)
DEPS=false; shift;;
-e|--essential)
MODERATE=false; RIGOROUS=false; shift;;
-m|--moderate)
MODERATE=true; RIGOROUS=false; shift;;
-r|--rigorous|-f|--full)
MODERATE=true; RIGOROUS=true; shift;;
--)
shift; break;;
*)
echo "Unknown option: $1" >&2
exit 1;;
esac
done
if [ $# != 0 ]; then
echo "Positional arguments are not accepted." >&2
usage >&2
exit 1
fi
trap 'echo FAILURE' EXIT
rm_rf_ro ci-*
export V=1
if "$DEPS"; then
stage install-deps deps_install
fi
stage autoreconf autoreconf --install --force
run_build debug build_debug
if "$RIGOROUS"; then
run_build coverage build_coverage
fi
unset V
trap - EXIT
echo SUCCESS