run revision 9d453f1e8b28983b363b44c49b7cd701a994fd97
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews#!/bin/bash
205c10066a0acfeac52d1a135671f41d207b8557Automatic Updater#
205c10066a0acfeac52d1a135671f41d207b8557Automatic Updater# Run continuous integration tests.
1167fc7904c5f0a472f8df207ac46dd52c7f1ec8Automatic Updater#
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater# Copyright (C) 2014 Red Hat
46da3117812814a29432a8d9a9ccf8acdbfdadceAutomatic Updater#
2bb3422dc683c013db7042f5736240de6b86f182Automatic Updater# This program is free software; you can redistribute it and/or modify
cd0aa2d941d1438fabb5337f1f38c49478edf71dAutomatic Updater# it under the terms of the GNU General Public License as published by
2ec4ab21838e218863d052ebfa3e106e04f50820Evan Hunt# the Free Software Foundation; either version 3 of the License, or
ea854b585041ad19f70f7af15e08144ef2c2bd1bMark Andrews# (at your option) any later version.
78cb74fab4665da2e2641ba909c6f59f74cc4193Automatic Updater#
cd0aa2d941d1438fabb5337f1f38c49478edf71dAutomatic Updater# This program is distributed in the hope that it will be useful,
90ff38a0d8deaf5f9c2aa5916d99b2e572d28738Automatic Updater# but WITHOUT ANY WARRANTY; without even the implied warranty of
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# GNU General Public License for more details.
6c6a121295b30772cbf3dd75a51fb9d883051a0eAutomatic Updater#
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# You should have received a copy of the GNU General Public License
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater# along with this program. If not, see <http://www.gnu.org/licenses/>.
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater
56874aef380a64a2c183b7c282c3e7a361d67fa1Automatic Updaterset -o nounset -o pipefail -o errexit
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsdeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
58be84825d7f5de30e50eb7206b37227ecd8055bAutomatic Updaterexport PATH=$CI_DIR:$PATH
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updaterexport LC_ALL=C
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews. deps.sh
96713299d08c0735c18ebe8772dd2cc1ecd4356aAutomatic Updater. distro.sh
831f79c4310a7d38fc3475ccfff531b2b2535641Automatic Updater. configure.sh
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews. misc.sh
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrewsdeclare -r DEBUG_CFLAGS="-g3 -O2"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterdeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssondeclare -r ARCH=`uname -m`
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterdeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterdeclare -r TITLE_WIDTH=24
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssondeclare -r RESULT_WIDTH=18
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# Minimum percentage of code lines covered by tests
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterdeclare -r COVERAGE_MIN_LINES=15
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# Minimum percentage of code functions covered by tests
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterdeclare -r COVERAGE_MIN_FUNCS=0
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Huntdeclare BASE_PFX=""
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterdeclare DEPS=true
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterdeclare BASE_DIR=`pwd`
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterdeclare MODERATE=false
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Huntdeclare RIGOROUS=false
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater# Output program usage information.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Huntfunction usage()
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater{
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater cat <<EOF
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic UpdaterUsage: `basename "$0"` [OPTION...]
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic UpdaterRun continuous integration tests.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic UpdaterOptions:
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater -h, --help Output this help message and exit.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater -p, --prefix=STRING Use STRING as the prefix to prepend to file and
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater directory paths in output.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater -n, --no-deps Don't attempt to install dependencies.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater -e, --essential Run the essential subset of tests.
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews -m, --moderate Run the moderate subset of tests.
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews -r, --rigorous,
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews -f, --full Run the rigorous (full) set of tests.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic UpdaterDefault options: --essential
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsEOF
129090f0f6f91753b4a085ab635e28549fd018adAutomatic Updater}
129090f0f6f91753b4a085ab635e28549fd018adAutomatic Updater
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Output a file display path: a path relocated from base directory (BASE_DIR)
d7a77415c13bb2fc2d1acb857486d97e4466e3b8Automatic Updater# to base prefix (BASE_PFX).
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Args: path
db5b7e2cdf150c46e8242d3e2e3ad3f5c7300258Automatic Updaterfunction disppath()
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater{
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews declare -r path=`readlink -f "$1"`
1a06700908f5a1d9f4a8d51285a0fd971e2f9117Automatic Updater printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews}
db5b7e2cdf150c46e8242d3e2e3ad3f5c7300258Automatic Updater
693c4232dfdffaff672197d4b9fea944c64cf80aAutomatic Updater# Run a stage.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Args: id cmd [arg...]
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterfunction stage()
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson{
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater declare -r id="$1"; shift
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater declare -r log="ci-$id.log"
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews declare status
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater declare start
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson declare end
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater declare duration
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson printf "%-${TITLE_WIDTH}s" "$id:"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater {
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater printf "Start: "
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater start=`date +%s`
b1265b5a06df36d490d4bdf54284fb133a1f5a84Automatic Updater date --date="@$start"
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater set +o errexit
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater (
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont set -o errexit -o xtrace
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater "$@"
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater )
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont status=$?
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews set -o errexit
f9119ad8f6114b2255e7545bf5cd187f4db0a89bAutomatic Updater printf "End: "
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater end=`date +%s`
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews date --date="@$end"
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater } &> "$log"
08e3b6797706a13054bad749dea04e94b514b8e7Automatic Updater
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater duration=$((end - start))
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater
995eaa289ba9709c64ef89b3776e53c36adc0010Automatic Updater if [ "$status" == 0 ]; then
b29e5c56eb74a6de1a84c29879afc90ffc6b1436Automatic Updater printf 'success '
418cc932318b1d67f88a36904d88d8a5a0a2ba09Automatic Updater else
995eaa289ba9709c64ef89b3776e53c36adc0010Automatic Updater printf 'failure '
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews fi
0977f3f39ef6728516be7976452b9122c8f5607aAutomatic Updater printf "%02u:%02u:%02u " \
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater $((duration / (60 * 60))) \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $((duration / 60 % 60)) \
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater $((duration % 60))
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater disppath "$log"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater printf "\n"
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater return "$status"
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater}
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Execute mock as is, or, if the user is not in the "mock" group, under sudo,
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater# which has password prompt/input on the console, instead of stderr/stdin.
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Args: [mock_arg...]
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterfunction mock_privileged()
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson{
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater if memberof mock; then
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews mock "$@"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson else
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater declare prompt=$'Not a "mock" group member.\n'
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater prompt+="To run mock enter sudo password for $USER: "
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater sudo -p "$prompt" mock "$@"
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater fi
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater}
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Execute mock_privileged with extra chroot configuration added.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# Args: chroot [mock_arg...]
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Input: extra configuration
4104e236f71eb5108fcfda6711878a97f6f4a8e7Automatic Updaterfunction mock_privileged_conf()
0df8ead472f207020f8da22a185fe4b945248ab8Automatic Updater{
e8c7dc2a5ce48f11c07a67c9923eeb8f419ff19fEvan Hunt declare -r chroot="$1"; shift
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater declare conf_dir
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater
0df8ead472f207020f8da22a185fe4b945248ab8Automatic Updater conf_dir=`mktemp --tmpdir --directory mock-config.XXXXXXXX`
2bb3422dc683c013db7042f5736240de6b86f182Automatic Updater trap 'trap - RETURN; rm -R "$conf_dir";' RETURN
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater # Preserve timestamps to avoid unnecessary cache rebuilds
c453a50776145e9c1c3fc9c846cfa11f42505081Automatic Updater cp -r --preserve=timestamps /etc/mock/* "$conf_dir"/
3b6e4c84a525b0b3fc9e8affd8bb9fa5c000345fAutomatic Updater cat >> "${conf_dir}/${chroot}.cfg"
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
d145b64cacc8d9cda51f9924ec70cd4661c3e2cfAutomatic Updater mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater}
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# Execute mock_privileged with dependency package source configuration added.
c243d779731a410f8dc2d2feeed20c15f299b6e3Automatic Updater# Args: chroot [mock_arg...]
0df8ead472f207020f8da22a185fe4b945248ab8Automatic Updaterfunction mock_privileged_deps()
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater{
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater declare -r chroot_name="$1"; shift
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater declare -r chroot="${config%.cfg}"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater declare repo
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater if [[ "$chroot" == fedora-* ]]; then
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater repo='fedora-$releasever-$basearch'
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater repo="epel-${BASH_REMATCH[1]}-\$basearch"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater else
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater echo "Unknown chroot config: $chroot" >&2
c453a50776145e9c1c3fc9c846cfa11f42505081Automatic Updater exit 1
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater fi
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater mock_privileged_conf "$chroot" "$@" <<<"
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterconfig_opts['yum.conf'] += '''
7f94d9a8162c9a96b56e66176702b66e79d8e1a2Automatic Updater[sssd-deps]
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updatername=Extra SSSD dependencies
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterbaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterskip_if_unavailable=true
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updatergpgcheck=0
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterenabled=1
71bd43eebd9d6e42dbcae62b730f5b6508d5acd8Automatic Updater'''
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater"
7262eb86f2b465822206122921e2f357218f0cfdAutomatic Updater}
96ea71632887c58a9d00f47eb318bf76b35903c3Mark Andrews
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Run debug build checks.
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updaterfunction build_debug()
bbb069be941f649228760edcc241122933c066d2Automatic Updater{
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater export CFLAGS="$DEBUG_CFLAGS"
4cda4fd158d6ded5586bacea8c388445d99611eaAutomatic Updater declare test_dir
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews declare test_dir_distcheck
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater declare intgcheck_configure_args
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater declare distcheck_configure_args
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews declare status
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews stage configure "$BASE_DIR/configure" \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews "${CONFIGURE_ARG_LIST[@]}" \
c453a50776145e9c1c3fc9c846cfa11f42505081Automatic Updater --with-test-dir="$test_dir"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
f7c88d61cc1ad2435b0b7cfaedfc9d5248c0be25Automatic Updater # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews stage make-tests make-check-wrap -j $CPU_NUM check -- true
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater
957a8884fb712885cdd8ef0474f5ff95ddc46b20Automatic Updater status=0
b109432c3a939bff66a463be86c371bd88efe3aaAutomatic Updater CK_FORK=no \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater stage make-check-valgrind \
995eaa289ba9709c64ef89b3776e53c36adc0010Automatic Updater make-check-wrap -j $CPU_NUM check -- \
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater libtool --mode=execute \
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater valgrind-condense 99 \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington '!(*.py|*dlopen-tests)' -- \
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater --trace-children=yes \
cf7e98f59148b559946a7f1ca728471374f1eef3Automatic Updater --trace-children-skip='*/bin/*,*/sbin/*' \
96713299d08c0735c18ebe8772dd2cc1ecd4356aAutomatic Updater --leak-check=full \
bf9b61c7904437745aeeb0f7d5036b35dad2a8a5Automatic Updater --gen-suppressions=all \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater --suppressions="$CI_DIR/sssd.supp" \
cf7e98f59148b559946a7f1ca728471374f1eef3Automatic Updater --verbose ||
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater status=$?
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson mv "$test_dir" ci-test-dir
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater ((status == 0))
361bec4bdec45042897fb479b7071cd05bbd56b9Automatic Updater
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater if "$MODERATE"; then
71bd43eebd9d6e42dbcae62b730f5b6508d5acd8Automatic Updater if "$DEPS_INTGCHECK_SATISFIED"; then
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater printf -v intgcheck_configure_args " %q" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington "${CONFIGURE_ARG_LIST[@]}"
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater stage make-intgcheck make -j $CPU_NUM intgcheck \
3857cb6fcabeb79d85de4b3e3e4ab99912b701f8Mark Andrews INTGCHECK_CONFIGURE_FLAGS=" \
129090f0f6f91753b4a085ab635e28549fd018adAutomatic Updater $intgcheck_configure_args"
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater fi
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater test_dir_distcheck=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # Single thread due to https://fedorahosted.org/sssd/ticket/2354
e2caa7536302de34de6cc04025abcd53dc3a499aAutomatic Updater status=0
56e7dc0c24b04210dcbffb180a9e35644fb820daAutomatic Updater printf -v distcheck_configure_args " %q" \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater "${CONFIGURE_ARG_LIST[@]}" \
8292deab031e7599cd7622aa7675fbe139ca6095Mark Andrews "--with-test-dir=$test_dir_distcheck"
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater stage make-distcheck make distcheck \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater AUX_DISTCHECK_CONFIGURE_FLAGS=" \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater $distcheck_configure_args" ||
699487d8026a2b931bdce8ce3ae6bc1025d639fbMark Andrews status=$?
ca35524ce2b57e6f1b261d23565d1288a355d12fAutomatic Updater mv "$test_dir_distcheck" ci-test-dir-distcheck
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater ((status == 0))
b109432c3a939bff66a463be86c371bd88efe3aaAutomatic Updater
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater if [[ "$DISTRO_BRANCH" == -redhat-* ]]; then
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater stage make-srpm env -u CFLAGS -- make srpm
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater stage mock-build mock_privileged_deps "default" \
3351ccbd5c1961404044f8273d54dad405f53960Mark Andrews --resultdir ci-mock-result \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater rpmbuild/SRPMS/*.src.rpm
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater fi
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater fi
3351ccbd5c1961404044f8273d54dad405f53960Mark Andrews
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater unset CFLAGS
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater}
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater# Run coverage build checks.
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updaterfunction build_coverage()
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater{
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater declare -r coverage_report_dir="ci-report-coverage"
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater declare test_dir
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater export CFLAGS="$COVERAGE_CFLAGS"
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater stage configure "$BASE_DIR/configure" \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater "${CONFIGURE_ARG_LIST[@]}" \
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater --with-test-dir="$test_dir"
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater # Build everything, including tests
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater # Not building "tests" due to https://fedorahosted.org/sssd/ticket/2350
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater stage make-tests make-check-wrap -j $CPU_NUM check -- true
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater stage lcov-pre lcov --capture --initial --directory . \
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater --base-directory "$BASE_DIR" \
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater --output-file ci-base.info
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater # Run tests
807ffe7aba4095b2f25c75ac1459f9efcd017eebMark Andrews stage make-check make -j $CPU_NUM check || true
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater mv "$test_dir" ci-test-dir
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater stage lcov-post lcov --capture --directory . \
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater --base-directory "$BASE_DIR" \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews --output-file ci-check.info
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater stage lcov-merge lcov --add-tracefile ci-base.info \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater --add-tracefile ci-check.info \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews --output-file ci-dirty.info
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews stage lcov-clean lcov --remove ci-dirty.info \
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews "/usr/*" "src/tests/*" \
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews --output-file ci.info
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews stage genhtml eval 'genhtml --output-directory \
06f5acb11f1c32228d93eefd1eb841dbfb1c7f4dAutomatic Updater "$coverage_report_dir" \
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater --title "sssd" --show-details \
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater --legend --prefix "$BASE_DIR" \
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater ci.info |& tee ci-genhtml.out'
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater "coverage report:" \
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews "`disppath \"\$coverage_report_dir/index.html\"`"
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington "$COVERAGE_MIN_FUNCS" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington < ci-genhtml.out'
b109432c3a939bff66a463be86c371bd88efe3aaAutomatic Updater
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater unset CFLAGS
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater}
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater# Run a build inside a sub-directory.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Args: id cmd [arg...]
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updaterfunction run_build()
b1265b5a06df36d490d4bdf54284fb133a1f5a84Automatic Updater{
bc0a4c01beede169df81a3ee5b614ed9e82339dbAutomatic Updater declare -r id="$1"; shift
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington declare -r dir="ci-build-$id"
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington mkdir "$dir"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington "${id^^} BUILD:" "`disppath \"\$dir\"`"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cd "$dir"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington "$@"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington cd ..
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington}
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington#
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Main routine
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington#
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtondeclare args_expr
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonargs_expr=`getopt --name \`basename "\$0"\` \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington --options hp:nemrf \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington --longoptions help,prefix:,no-deps \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington --longoptions essential,moderate,rigorous,full \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -- "$@"`
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtoneval set -- "$args_expr"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonwhile true; do
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington case "$1" in
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -h|--help)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington usage; exit 0;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -p|--prefix)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington BASE_PFX="$2"; shift 2;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -n|--no-deps)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington DEPS=false; shift;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -e|--essential)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington MODERATE=false; RIGOROUS=false; shift;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -m|--moderate)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington MODERATE=true; RIGOROUS=false; shift;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington -r|--rigorous|-f|--full)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington MODERATE=true; RIGOROUS=true; shift;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington --)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington shift; break;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington *)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington echo "Unknown option: $1" >&2
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington exit 1;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington esac
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtondone
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonif [ $# != 0 ]; then
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington echo "Positional arguments are not accepted." >&2
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington usage >&2
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington exit 1
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonfi
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtontrap 'echo FAILURE' EXIT
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonrm_rf_ro ci-*
a26b22914b7bf25f065afb8cdef983766dcd672bAutomatic Updaterexport V=1
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updaterif "$DEPS"; then
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater stage install-deps deps_install
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterfi
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterstage autoreconf autoreconf --install --force
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterrun_build debug build_debug
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterif "$RIGOROUS"; then
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater run_build coverage build_coverage
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterfi
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterunset V
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updatertrap - EXIT
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updaterecho SUCCESS
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater