run revision 3ce85a5f5264e7118beb6524e120fd8b53a13da4
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#!/bin/bash
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Run continuous integration tests.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Copyright (C) 2014 Red Hat
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# This program is free software; you can redistribute it and/or modify
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# it under the terms of the GNU General Public License as published by
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# the Free Software Foundation; either version 3 of the License, or
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# (at your option) any later version.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# This program is distributed in the hope that it will be useful,
0662ed52e814f8f08ef0e09956413a792584eddffuankg# but WITHOUT ANY WARRANTY; without even the implied warranty of
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# GNU General Public License for more details.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# You should have received a copy of the GNU General Public License
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# along with this program. If not, see <http://www.gnu.org/licenses/>.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesset -o nounset -o pipefail -o errexit
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesexport PATH=`dirname "\`readlink -f \"\$0\"\`"`:$PATH
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesexport LC_ALL=C
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes. deps.sh
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes. distro.sh
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes. configure.sh
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes. misc.sh
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r DEBUG_CFLAGS="-g3 -O2"
cfb941e9ad5276eef7bc8f3eedcd270f30cfec35fuankgdeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r ARCH=`uname -m`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r TITLE_WIDTH=24
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r RESULT_WIDTH=18
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Minimum percentage of code lines covered by tests
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r COVERAGE_MIN_LINES=15
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Minimum percentage of code functions covered by tests
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare -r COVERAGE_MIN_FUNCS=0
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare BASE_PFX=""
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare DEPS=true
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare BASE_DIR=`pwd`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare MODERATE=false
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdeclare RIGOROUS=false
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Output program usage information.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction usage()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cat <<EOF
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesUsage: `basename "$0"` [OPTION...]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesRun continuous integration tests.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesOptions:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -h, --help Output this help message and exit.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -p, --prefix=STRING Use STRING as the prefix to prepend to file and
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes directory paths in output.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -n, --no-deps Don't attempt to install dependencies.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -e, --essential Run the essential subset of tests.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -m, --moderate Run the moderate subset of tests.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -r, --rigorous,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -f, --full Run the rigorous (full) set of tests.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesDefault options: --essential
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesEOF
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg# Output a file display path: a path relocated from base directory (BASE_DIR)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# to base prefix (BASE_PFX).
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Args: path
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction disppath()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r path=`readlink -f "$1"`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Run a stage.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Args: id cmd [arg...]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction stage()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r id="$1"; shift
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg declare -r log="ci-$id.log"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare status
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare start
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare end
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare duration
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "%-${TITLE_WIDTH}s" "$id:"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "Start: "
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes start=`date +%s`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes date --date="@$start"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes set +o errexit
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes (
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes set -o errexit -o xtrace
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "$@"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes )
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes status=$?
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes set -o errexit
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "End: "
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes end=`date +%s`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes date --date="@$end"
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg } &> "$log"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes duration=$((end - start))
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if [ "$status" == 0 ]; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf 'success '
0a39e7683f6611d66c55712f50bb240428d832a1bnicholes else
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf 'failure '
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes fi
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "%02u:%02u:%02u " \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes $((duration / (60 * 60))) \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes $((duration / 60 % 60)) \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes $((duration % 60))
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes disppath "$log"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf "\n"
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg
0662ed52e814f8f08ef0e09956413a792584eddffuankg return "$status"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Execute mock as is, or, if the user is not in the "mock" group, under sudo,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# which has password prompt/input on the console, instead of stderr/stdin.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Args: [mock_arg...]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction mock_privileged()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg if memberof mock; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes mock "$@"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes else
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare prompt=$'Not a "mock" group member.\n'
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes prompt+="To run mock enter sudo password for $USER: "
0662ed52e814f8f08ef0e09956413a792584eddffuankg sudo -p "$prompt" mock "$@"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes fi
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Execute mock_privileged with extra chroot configuration added.
0662ed52e814f8f08ef0e09956413a792584eddffuankg# Args: chroot [mock_arg...]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Input: extra configuration
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction mock_privileged_conf()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r chroot="$1"; shift
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare conf_dir
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes trap 'trap - RETURN; rm -R "$conf_dir";' RETURN
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cp -r /etc/mock/* "$conf_dir"/
0662ed52e814f8f08ef0e09956413a792584eddffuankg cat >> "${conf_dir}/${chroot}.cfg"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Execute mock_privileged with dependency package source configuration added.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Args: chroot [mock_arg...]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction mock_privileged_deps()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r chroot="$1"; shift
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare repo
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if [[ "$chroot" == fedora-* ]]; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes repo='fedora-$releasever-$basearch'
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes repo="epel-${BASH_REMATCH[1]}-\$basearch"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes else
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes echo "Unknown chroot config: $chroot" >&2
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes exit 1
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes fi
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes mock_privileged_conf "$chroot" "$@" <<<"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesconfig_opts['yum.conf'] += '''
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes[sssd-deps]
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesname=Extra SSSD dependencies
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesbaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesskip_if_unavailable=true
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesgpgcheck=0
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesenabled=1
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes'''
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Run debug build checks.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfunction build_debug()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes export CFLAGS="$DEBUG_CFLAGS"
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg declare test_dir
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare test_dir_distcheck
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare distcheck_configure_args
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare status
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage configure "$BASE_DIR/configure" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "${CONFIGURE_ARG_LIST[@]}" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --with-test-dir="$test_dir"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
9046ab142ed19505e034af0afb8c15be512b8526bnicholes # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage make-tests make-check-wrap -j $CPU_NUM check -- true
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes # Ignored until issues found by Valgrind are fixed
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes status=0
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes CK_FORK=no \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage make-check-valgrind \
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg make-check-wrap -j $CPU_NUM check -- \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes libtool --mode=execute \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes valgrind-condense 99 '!(*.py)' -- \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --vgdb=no \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --trace-children=yes \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --trace-children-skip='*/bin/*,*/sbin/*' \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --leak-check=full ||
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes status=$?
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes mv "$test_dir" ci-test-dir
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if "$MODERATE"; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes test_dir_distcheck=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes # Single thread due to https://fedorahosted.org/sssd/ticket/2354
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes status=0
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes printf -v distcheck_configure_args " %q" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "${CONFIGURE_ARG_LIST[@]}" \
8ffac2c334103c0336602aaede650cb578611151fuankg "--with-test-dir=$test_dir_distcheck"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage make-distcheck make distcheck \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes AUX_DISTCHECK_CONFIGURE_FLAGS=" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes $distcheck_configure_args" ||
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg status=$?
609ef720afd62ca63391c9fdb415cd2faf29aa46bnicholes mv "$test_dir_distcheck" ci-test-dir-distcheck
609ef720afd62ca63391c9fdb415cd2faf29aa46bnicholes ((status == 0))
609ef720afd62ca63391c9fdb415cd2faf29aa46bnicholes
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
609ef720afd62ca63391c9fdb415cd2faf29aa46bnicholes stage make-srpm env -u CFLAGS -- make srpm
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg stage mock-epel6 mock_privileged_deps "epel-6-$ARCH" \
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg --resultdir ci-mock-result-epel6 \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes rpmbuild/SRPMS/*.src.rpm
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage mock-fedora20 mock_privileged_deps "fedora-20-$ARCH" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --resultdir ci-mock-result-fedora20 \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes rpmbuild/SRPMS/*.src.rpm
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes fi
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg fi
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes unset CFLAGS
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Run coverage build checks.
ac7985784d08a3655291f24f711812b4d8b1cbcffuankgfunction build_coverage()
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r scan_report_dir="ci-report-scan"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare -r coverage_report_dir="ci-report-coverage"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes declare test_dir
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes export CFLAGS="$COVERAGE_CFLAGS"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage configure scan-build "$BASE_DIR/configure" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "${CONFIGURE_ARG_LIST[@]}" \
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg --with-test-dir="$test_dir"
0662ed52e814f8f08ef0e09956413a792584eddffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes # Build everything, including tests
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
f2f3f241c00a7a4bd597e57a19023940e072918abnicholes stage scan-make-tests scan_build_single \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "$scan_report_dir" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes -plist-html \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --html-title="sssd - scan-build report" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes make-check-wrap -j $CPU_NUM check -- true
8410c53aaf5e0372a19d5f4d2bc696b9c609ce3cbnicholes printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "scan report:" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "`disppath \"\$scan_report_dir/index.html\"`"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes # Ignored until issues found by the scanner are fixed
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes stage scan-check scan_check "$scan_report_dir" ||
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes true
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
0662ed52e814f8f08ef0e09956413a792584eddffuankg stage lcov-pre lcov --capture --initial --directory . \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --base-directory "$BASE_DIR" \
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes --output-file ci-base.info
# Run tests
stage make-check scan-build make -j $CPU_NUM check || true
mv "$test_dir" ci-test-dir
stage lcov-post lcov --capture --directory . \
--base-directory "$BASE_DIR" \
--output-file ci-check.info
stage lcov-merge lcov --add-tracefile ci-base.info \
--add-tracefile ci-check.info \
--output-file ci-dirty.info
stage lcov-clean lcov --remove ci-dirty.info \
"/usr/*" "src/tests/*" \
--output-file ci.info
stage genhtml eval 'genhtml --output-directory \
"$coverage_report_dir" \
--title "sssd" --show-details \
--legend --prefix "$BASE_DIR" \
ci.info |& tee ci-genhtml.out'
printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
"coverage report:" \
"`disppath \"\$coverage_report_dir/index.html\"`"
# If dependencies for all tests are satisfied
# and so all the tests should have been built and ran.
if "$DEPS_TESTS_SATISFIED"; then
stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
"$COVERAGE_MIN_FUNCS" \
< ci-genhtml.out'
fi
unset CFLAGS
}
# Run a build inside a sub-directory.
# Args: id cmd [arg...]
function run_build()
{
declare -r id="$1"; shift
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