run revision 9d453f1e8b28983b363b44c49b7cd701a994fd97
205c10066a0acfeac52d1a135671f41d207b8557Automatic Updater# Run continuous integration tests.
0c39b3ed9409ecb277d5e32fa763a4e4d6598df8Automatic Updater# Copyright (C) 2014 Red Hat
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.
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.
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/>.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsdeclare -r CI_DIR=`dirname "\`readlink -f \"\$0\"\`"`
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterdeclare -r COVERAGE_CFLAGS="-g3 -O0 --coverage"
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updaterdeclare -r CPU_NUM=`getconf _NPROCESSORS_ONLN`
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# Minimum percentage of code lines covered by tests
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt# Minimum percentage of code functions covered by tests
2d2dc37599979c83495510f8af8d1756753aa2c5Automatic Updater# Output program usage information.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic UpdaterUsage: `basename "$0"` [OPTION...]
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic UpdaterRun continuous integration tests.
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.
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic UpdaterDefault options: --essential
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Output a file display path: a path relocated from base directory (BASE_DIR)
d7a77415c13bb2fc2d1acb857486d97e4466e3b8Automatic Updater# to base prefix (BASE_PFX).
1a06700908f5a1d9f4a8d51285a0fd971e2f9117Automatic Updater printf "%s" "$BASE_PFX${path:${#BASE_DIR}+1}"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Args: id cmd [arg...]
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...]
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater declare prompt=$'Not a "mock" group member.\n'
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater prompt+="To run mock enter sudo password for $USER: "
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Execute mock_privileged with extra chroot configuration added.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# Args: chroot [mock_arg...]
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater# Input: extra configuration
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"/
19b3dc94bce93fa76bd7e066f9298630dbc9dcb4Automatic Updater touch --reference="/etc/mock/${chroot}.cfg" "${conf_dir}/${chroot}.cfg"
d145b64cacc8d9cda51f9924ec70cd4661c3e2cfAutomatic Updater mock_privileged --configdir="$conf_dir" --root="$chroot" "$@"
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# Execute mock_privileged with dependency package source configuration added.
c243d779731a410f8dc2d2feeed20c15f299b6e3Automatic Updater# Args: chroot [mock_arg...]
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater declare -r config=$(basename $(readlink -f "/etc/mock/${chroot_name}.cfg"))
7f79131f9a8e804b93c57f3c679065cce878b726Automatic Updater elif [[ "$chroot" =~ epel-([0-9]+) ]]; then
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updaterconfig_opts['yum.conf'] += '''
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updatername=Extra SSSD dependencies
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterbaseurl=http://copr-be.cloud.fedoraproject.org/results/lslebodn/sssd-deps/$repo/
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updaterskip_if_unavailable=true
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Run debug build checks.
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
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
cf7e98f59148b559946a7f1ca728471374f1eef3Automatic Updater --trace-children-skip='*/bin/*,*/sbin/*' \
0ce87e5749aabb8eef1e0a37e4bd6e6ffa1d7196Automatic Updater printf -v intgcheck_configure_args " %q" \
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater stage make-intgcheck make -j $CPU_NUM intgcheck \
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
56e7dc0c24b04210dcbffb180a9e35644fb820daAutomatic Updater printf -v distcheck_configure_args " %q" \
ca35524ce2b57e6f1b261d23565d1288a355d12fAutomatic Updater mv "$test_dir_distcheck" ci-test-dir-distcheck
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" \
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater# Run coverage build checks.
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater declare -r coverage_report_dir="ci-report-coverage"
7d12a6b412fe47e6d6582923fd6954ab8cd0baebAutomatic Updater test_dir=`mktemp --directory /dev/shm/ci-test-dir.XXXXXXXX`
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 stage lcov-pre lcov --capture --initial --directory . \
807ffe7aba4095b2f25c75ac1459f9efcd017eebMark Andrews stage make-check make -j $CPU_NUM check || true
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater stage lcov-post lcov --capture --directory . \
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater stage lcov-merge lcov --add-tracefile ci-base.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" \
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews "`disppath \"\$coverage_report_dir/index.html\"`"
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews stage lcov-check eval 'lcov_check "$COVERAGE_MIN_LINES" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington "$COVERAGE_MIN_FUNCS" \
9cd5eb6fe0f26d65724b99216cb31dcdd12e4afdAutomatic Updater# Run a build inside a sub-directory.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Args: id cmd [arg...]
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington printf "%-$((TITLE_WIDTH + RESULT_WIDTH))s%s\n" \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Main routine
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonargs_expr=`getopt --name \`basename "\$0"\` \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington --longoptions essential,moderate,rigorous,full \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonwhile true; do
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington DEPS=false; shift;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington shift; break;;
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonif [ $# != 0 ]; then
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington echo "Positional arguments are not accepted." >&2