]> git.ipfire.org Git - thirdparty/util-linux.git/blame - .travis-functions.sh
script: document SIGUSR1
[thirdparty/util-linux.git] / .travis-functions.sh
CommitLineData
dd68764c
RM
1#!/bin/bash
2
3#
4# .travis-functions.sh:
5# - helper functions to be sourced from .travis.yml
6# - designed to respect travis' environment but testing locally is possible
7#
060c4cee
KZ
8# Variables:
9#
10# TS_OPT_<name>_<something>=yes
11# - forces tests/functions.sh:ts_has_option() to return "yes" for
12# variable <something> in test <name>
13#
14# TESTS_OPTIONS=
406fb253 15# TESTS_PARALLEL=
060c4cee
KZ
16# TESTS_COMMAND=
17# - overwrites default from tests/Makemodule.am
18#
19# Do not use TS_* prefix for any travis or build-system stuff. This prefix is
20# exclusively used by tests/ stuff.
21#
dd68764c
RM
22
23if [ ! -f "configure.ac" ]; then
24 echo ".travis-functions.sh must be sourced from source dir" >&2
25 return 1 || exit 1
26fi
27
1091e83e
RM
28## some config settings
29# travis docs say we get 1.5 CPUs
30MAKE="make -j2"
dd68764c
RM
31DUMP_CONFIG_LOG="short"
32
cf76bbae
RM
33# workaround ugly warning on travis OSX,
34# see https://github.com/direnv/direnv/issues/210
35shell_session_update() { :; }
36
1091e83e 37function xconfigure
dd68764c 38{
cf76bbae
RM
39 which "$CC"
40 "$CC" --version
41
668d6d2e 42 ./configure "$@" $OSX_CONFOPTS
dd68764c
RM
43 err=$?
44 if [ "$DUMP_CONFIG_LOG" = "short" ]; then
45 grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
46 elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
47 cat config.log
48 fi
49 return $err
50}
51
d1a7c00e
RM
52# TODO: integrate checkusage into our regular tests and remove this function
53function make_checkusage
54{
55 local tmp
56 if ! tmp=$($MAKE checkusage 2>&1) || test -n "$tmp"; then
57 echo "$tmp"
58 echo "make checkusage failed" >&2
59 return 1
60 fi
61}
62
dd68764c
RM
63function check_nonroot
64{
406fb253 65 local make_opts="$MAKE_CHECK_OPTS --show-diff --parsable"
450016eb 66 local conf_opts="\
dd68764c 67 --disable-use-tty-group \
a65041b5 68 --disable-makeinstall-chown \
450016eb
KZ
69 --enable-all-programs"
70
71 if [ "$TRAVIS_OS_NAME" != "osx" ]; then
72 conf_opts="$conf_opts --enable-asan"
73 make_opts="$make_opts --memcheck-asan"
74 fi
75
76 xconfigure $conf_opts || return
dd68764c 77 $MAKE || return
668d6d2e
RM
78
79 osx_prepare_check
ac543a15 80
060c4cee
KZ
81 # TESTS_* overwrites default from tests/Makemodule.am
82 $MAKE check TESTS_OPTIONS="$make_opts" || return
668d6d2e 83
d1a7c00e
RM
84 make_checkusage || return
85
dd68764c
RM
86 $MAKE install DESTDIR=/tmp/dest || return
87}
88
89function check_root
90{
450016eb
KZ
91 local make_opts="$MAKE_CHECK_OPTS --show-diff"
92 local conf_opts="--enable-all-programs"
266f8562 93
450016eb
KZ
94 if [ "$TRAVIS_OS_NAME" != "osx" ]; then
95 conf_opts="$conf_opts --enable-asan"
96 make_opts="$make_opts --memcheck-asan"
97 fi
98
99 xconfigure $conf_opts || return
dd68764c 100 $MAKE || return
668d6d2e 101
ac543a15
KZ
102 # compile tests only
103 $MAKE check-programs || return
104
105 # Modify environment for OSX
668d6d2e 106 osx_prepare_check
ac543a15 107
060c4cee 108 # TESTS_* overwrites default from tests/Makemodule.am
406fb253 109 sudo -E $MAKE check "TESTS_PARALLEL=''" TESTS_OPTIONS="$make_opts" || return
668d6d2e 110
277d61b9
RM
111 # root on osx has not enough permission for make install ;)
112 [ "$TRAVIS_OS_NAME" = "osx" ] && return
113
cf76bbae
RM
114 # keep PATH to make sure sudo would find $CC
115 sudo env "PATH=$PATH" $MAKE install || return
dd68764c
RM
116}
117
118function check_dist
119{
22174021 120 xconfigure \
dd68764c
RM
121 || return
122 $MAKE distcheck || return
123}
124
5ddcc32a
RM
125function travis_install_script
126{
668d6d2e
RM
127 if [ "$TRAVIS_OS_NAME" = "osx" ]; then
128 osx_install_script
129 return
130 fi
131
cf76bbae
RM
132 # install required packages
133 sudo apt-get -qq update --fix-missing
5ddcc32a
RM
134 sudo apt-get install -qq >/dev/null \
135 bc \
fc412fe4 136 btrfs-tools \
5ddcc32a
RM
137 dnsutils \
138 libcap-ng-dev \
91891979 139 libncursesw5-dev \
5ddcc32a
RM
140 libpam-dev \
141 libudev-dev \
142 gtk-doc-tools \
f81faffa 143 mdadm \
5ddcc32a 144 ntp \
fc412fe4 145 socat \
5ddcc32a 146 || return
432439a4 147
fc412fe4 148 # install only if available (e.g. Ubuntu Trusty)
432439a4 149 sudo apt-get install -qq >/dev/null \
fc412fe4
RM
150 libsystemd-daemon-dev \
151 libsystemd-journal-dev \
152 || true
5ddcc32a
RM
153}
154
668d6d2e
RM
155function osx_install_script
156{
157 brew update >/dev/null
668d6d2e
RM
158
159 brew install gettext ncurses socat xz
160 brew link --force gettext
161 brew link --force ncurses
162
163 OSX_CONFOPTS="
668d6d2e
RM
164 --disable-ipcrm \
165 --disable-ipcs \
668d6d2e 166 "
160eef81
RM
167
168 # workaround: glibtoolize could not find sed
169 export SED="sed"
668d6d2e
RM
170}
171
172function osx_prepare_check
173{
174 [ "$TRAVIS_OS_NAME" = "osx" ] || return 0
175
176 # these ones only need to be gnu for our test-suite
177 brew install coreutils findutils gnu-tar gnu-sed
178
179 # symlink minimally needed gnu commands into PATH
180 mkdir ~/bin
4fb3fe39 181 for cmd in readlink seq timeout truncate find xargs tar sed; do
668d6d2e
RM
182 ln -s /usr/local/bin/g$cmd $HOME/bin/$cmd
183 done
184 hash -r
185
186 export TS_OPT_col_multibyte_known_fail=yes
187 export TS_OPT_colcrt_regressions_known_fail=yes
188 export TS_OPT_column_invalid_multibyte_known_fail=yes
189}
190
dd68764c
RM
191function travis_before_script
192{
dd68764c
RM
193 set -o xtrace
194
195 ./autogen.sh
196 ret=$?
197
dd68764c 198 set +o xtrace
dd68764c
RM
199 return $ret
200}
201
202function travis_script
203{
204 local ret
205 set -o xtrace
206
207 case "$MAKE_CHECK" in
208 nonroot)
209 check_nonroot
210 ;;
211 root)
212 check_root
213 ;;
214 dist)
215 check_dist
216 ;;
217 *)
218 echo "error, check environment (travis.yml)" >&2
219 false
220 ;;
221 esac
222
223 # We exit here with case-switch return value!
224 ret=$?
225 set +o xtrace
226 return $ret
227}
228
229function travis_after_script
230{
231 local diff_dir
232 local tmp
233
234 # find diff dir from check as well as from distcheck
1091e83e 235 diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1)
dd68764c
RM
236 if [ -d "$diff_dir" ]; then
237 tmp=$(find "$diff_dir" -type f | sort)
238 echo -en "dump test diffs:\n${tmp}\n"
1091e83e 239 echo "$tmp" | xargs cat
dd68764c
RM
240 fi
241}