2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-12-06 22:59:54 +00:00
|
|
|
#
|
|
|
|
# Ceph distributed storage system
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014 Red Hat <contact@redhat.com>
|
|
|
|
#
|
|
|
|
# Author: Loic Dachary <loic@dachary.org>
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Return MAX(1, (number of processors / 2)) by default or NPROC
|
|
|
|
#
|
|
|
|
function get_processors() {
|
|
|
|
if test -n "$NPROC" ; then
|
|
|
|
echo $NPROC
|
|
|
|
else
|
2015-01-29 13:18:18 +00:00
|
|
|
if test $(nproc) -ge 2 ; then
|
|
|
|
expr $(nproc) / 2
|
2014-12-06 22:59:54 +00:00
|
|
|
else
|
|
|
|
echo 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function run() {
|
2015-04-30 07:44:10 +00:00
|
|
|
local install_cmd
|
2017-05-31 22:56:20 +00:00
|
|
|
local which_pkg="which"
|
2018-02-01 14:53:15 +00:00
|
|
|
source /etc/os-release
|
2016-09-16 04:29:15 +00:00
|
|
|
if test -f /etc/redhat-release ; then
|
2016-12-27 11:59:29 +00:00
|
|
|
if ! type bc > /dev/null 2>&1 ; then
|
|
|
|
echo "Please install bc and re-run."
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-09-16 04:29:15 +00:00
|
|
|
if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
|
|
|
|
install_cmd="dnf -y install"
|
|
|
|
else
|
|
|
|
install_cmd="yum install -y"
|
|
|
|
fi
|
2018-02-01 14:53:15 +00:00
|
|
|
elif type zypper > /dev/null 2>&1 ; then
|
|
|
|
install_cmd="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
|
|
|
|
elif type apt-get > /dev/null 2>&1 ; then
|
|
|
|
install_cmd="apt-get install -y"
|
2017-05-31 22:56:20 +00:00
|
|
|
which_pkg="debianutils"
|
2016-09-16 04:29:15 +00:00
|
|
|
fi
|
|
|
|
|
2016-12-27 11:59:29 +00:00
|
|
|
if ! type sudo > /dev/null 2>&1 ; then
|
|
|
|
echo "Please install sudo and re-run. This script assumes it is running"
|
|
|
|
echo "as a normal user with the ability to run commands as root via sudo."
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-04-30 07:44:10 +00:00
|
|
|
if [ -n "$install_cmd" ]; then
|
2017-05-31 22:56:20 +00:00
|
|
|
$DRY_RUN sudo $install_cmd ccache jq $which_pkg
|
2015-04-30 07:44:10 +00:00
|
|
|
else
|
|
|
|
echo "WARNING: Don't know how to install packages" >&2
|
2018-02-01 14:53:15 +00:00
|
|
|
echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2
|
2015-04-30 07:44:10 +00:00
|
|
|
fi
|
2014-12-06 22:59:54 +00:00
|
|
|
|
|
|
|
if test -f ./install-deps.sh ; then
|
2017-12-08 08:34:59 +00:00
|
|
|
$DRY_RUN source ./install-deps.sh || return 1
|
2014-12-06 22:59:54 +00:00
|
|
|
fi
|
2016-12-21 01:14:16 +00:00
|
|
|
|
|
|
|
# Init defaults after deps are installed. get_processors() depends on coreutils nproc.
|
|
|
|
DEFAULT_MAKEOPTS=${DEFAULT_MAKEOPTS:--j$(get_processors)}
|
|
|
|
BUILD_MAKEOPTS=${BUILD_MAKEOPTS:-$DEFAULT_MAKEOPTS}
|
|
|
|
CHECK_MAKEOPTS=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS}
|
|
|
|
|
2016-09-29 16:33:16 +00:00
|
|
|
$DRY_RUN ./do_cmake.sh $@ || return 1
|
|
|
|
$DRY_RUN cd build
|
|
|
|
$DRY_RUN make $BUILD_MAKEOPTS tests || return 1
|
2017-08-30 08:32:49 +00:00
|
|
|
# prevent OSD EMFILE death on tests, make sure large than 1024
|
|
|
|
$DRY_RUN ulimit -n $(ulimit -Hn)
|
|
|
|
if [ $(ulimit -n) -lt 1024 ];then
|
|
|
|
echo "***ulimit -n too small, better bigger than 1024 for test***"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2017-07-20 11:20:04 +00:00
|
|
|
if ! $DRY_RUN ctest $CHECK_MAKEOPTS --output-on-failure; then
|
|
|
|
rm -f ${TMPDIR:-/tmp}/ceph-asok.*
|
|
|
|
return 1
|
|
|
|
fi
|
2014-12-06 22:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2016-12-27 11:59:29 +00:00
|
|
|
if [[ $EUID -eq 0 ]] ; then
|
|
|
|
echo "For best results, run this script as a normal user configured"
|
|
|
|
echo "with the ability to run commands as root via sudo."
|
|
|
|
fi
|
2016-12-03 22:37:08 +00:00
|
|
|
echo -n "Checking hostname sanity... "
|
|
|
|
if hostname --fqdn >/dev/null 2>&1 ; then
|
|
|
|
echo "OK"
|
|
|
|
else
|
|
|
|
echo "NOT OK"
|
|
|
|
echo "Please fix 'hostname --fqdn', otherwise 'make check' will fail"
|
|
|
|
return 1
|
|
|
|
fi
|
2014-12-21 08:47:57 +00:00
|
|
|
if run "$@" ; then
|
2016-05-20 11:19:07 +00:00
|
|
|
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
2016-09-29 16:33:16 +00:00
|
|
|
echo "cmake check: successful run on $(git rev-parse HEAD)"
|
2014-12-06 22:59:54 +00:00
|
|
|
return 0
|
|
|
|
else
|
2016-05-20 11:19:07 +00:00
|
|
|
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
2014-12-06 22:59:54 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-12-21 08:47:57 +00:00
|
|
|
main "$@"
|