3 # Ceph distributed storage system
5 # Copyright (C) 2014 Red Hat <contact@redhat.com>
7 # Author: Loic Dachary <loic@dachary.org>
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
16 # To just look at what this script will do, run it like this:
18 # $ DRY_RUN=echo ./run-make-check.sh
23 trap clean_up_after_myself EXIT
25 ORIGINAL_CCACHE_CONF
="$HOME/.ccache/ccache.conf"
26 SAVED_CCACHE_CONF
="$HOME/.run-make-check-saved-ccache-conf"
28 function save_ccache_conf
() {
29 test -f $ORIGINAL_CCACHE_CONF && cp $ORIGINAL_CCACHE_CONF $SAVED_CCACHE_CONF || true
32 function restore_ccache_conf
() {
33 test -f $SAVED_CCACHE_CONF && mv $SAVED_CCACHE_CONF $ORIGINAL_CCACHE_CONF || true
36 function clean_up_after_myself
() {
37 rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv
*
41 function get_processors
() {
42 if test -n "$NPROC" ; then
45 if test $
(nproc
) -ge 2 ; then
55 local which_pkg
="which"
56 source /etc
/os-release
57 if test -f /etc
/redhat-release
; then
58 if ! type bc > /dev
/null
2>&1 ; then
59 echo "Please install bc and re-run."
62 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
63 install_cmd
="dnf -y install"
65 install_cmd
="yum install -y"
67 elif type zypper
> /dev
/null
2>&1 ; then
68 install_cmd
="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
69 elif type apt-get
> /dev
/null
2>&1 ; then
70 install_cmd
="apt-get install -y"
71 which_pkg
="debianutils"
74 if ! type sudo
> /dev
/null
2>&1 ; then
75 echo "Please install sudo and re-run. This script assumes it is running"
76 echo "as a normal user with the ability to run commands as root via sudo."
79 if [ -n "$install_cmd" ]; then
80 $DRY_RUN sudo
$install_cmd ccache
$which_pkg
82 echo "WARNING: Don't know how to install packages" >&2
83 echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2
86 if ! type ccache
> /dev
/null
2>&1 ; then
87 echo "ERROR: ccache could not be installed"
91 if test -f .
/install-deps.sh
; then
92 $DRY_RUN .
/install-deps.sh ||
return 1
93 trap clean_up_after_myself EXIT
96 # Init defaults after deps are installed. get_processors() depends on coreutils nproc.
97 DEFAULT_MAKEOPTS
=${DEFAULT_MAKEOPTS:--j$(get_processors)}
98 BUILD_MAKEOPTS
=${BUILD_MAKEOPTS:-$DEFAULT_MAKEOPTS}
99 test "$BUILD_MAKEOPTS" && echo "make will run with option(s) $BUILD_MAKEOPTS"
100 CHECK_MAKEOPTS
=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS}
102 if type python2
> /dev
/null
2>&1 ; then
103 # gtest-parallel requires Python 2
104 CMAKE_PYTHON_OPTS
="-DWITH_GTEST_PARALLEL=ON"
106 CMAKE_PYTHON_OPTS
="-DWITH_PYTHON2=OFF -DWITH_PYTHON3=ON -DMGR_PYTHON_VERSION=3 -DWITH_GTEST_PARALLEL=OFF"
112 Note that the binaries produced by this script do not contain correct time
113 and git version information, which may make them unsuitable for debugging
117 # remove the entropy generated by the date/time embedded in the build
118 CMAKE_BUILD_OPTS
="$CMAKE_BUILD_OPTS -DENABLE_GIT_VERSION=OFF"
119 $DRY_RUN export SOURCE_DATE_EPOCH
="946684800"
120 $DRY_RUN ccache
-o sloppiness
=time_macros
121 $DRY_RUN ccache
-o run_second_cpp
=true
122 if [ -n "$JENKINS_HOME" ]; then
123 # Build host has plenty of space available, let's use it to keep
124 # various versions of the built objects. This could increase the cache hit
125 # if the same or similar PRs are running several times
126 $DRY_RUN ccache
-o max_size
=100G
128 echo "Current ccache max_size setting:"
129 ccache
-p |
grep max_size
131 $DRY_RUN ccache
-z # Reset the ccache statistics
133 $DRY_RUN .
/do_cmake.sh
$CMAKE_BUILD_OPTS $CMAKE_PYTHON_OPTS $@ ||
return 1
135 $DRY_RUN make $BUILD_MAKEOPTS tests ||
return 1
137 $DRY_RUN ccache
-s # print the ccache statistics to evaluate the efficiency
139 # to prevent OSD EMFILE death on tests, make sure ulimit >= 1024
140 $DRY_RUN ulimit -n $
(ulimit -Hn)
141 if [ $
(ulimit -n) -lt 1024 ];then
142 echo "***ulimit -n too small, better bigger than 1024 for test***"
146 if ! $DRY_RUN ctest
$CHECK_MAKEOPTS --output-on-failure; then
147 rm -f ${TMPDIR:-/tmp}/ceph-asok.
*
153 if [[ $EUID -eq 0 ]] ; then
154 echo "For best results, run this script as a normal user configured"
155 echo "with the ability to run commands as root via sudo."
157 echo -n "Checking hostname sanity... "
158 if $DRY_RUN hostname
--fqdn >/dev
/null
2>&1 ; then
162 echo "Please fix 'hostname --fqdn', otherwise 'make check' will fail"
165 run
"$@" && echo "make check: successful run on $(git rev-parse HEAD)"