]>
Commit | Line | Data |
---|---|---|
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 | # | |
8 | ||
9 | if [ ! -f "configure.ac" ]; then | |
10 | echo ".travis-functions.sh must be sourced from source dir" >&2 | |
11 | return 1 || exit 1 | |
12 | fi | |
13 | ||
14 | ## some config settings | |
15 | # travis docs say we get 1.5 CPUs | |
16 | MAKE="make -j2" | |
17 | DUMP_CONFIG_LOG="short" | |
18 | export TS_OPT_parsable="yes" | |
19 | ||
20 | # workaround ugly warning on travis OSX, | |
21 | # see https://github.com/direnv/direnv/issues/210 | |
22 | shell_session_update() { :; } | |
23 | ||
24 | function xconfigure | |
25 | { | |
26 | which "$CC" | |
27 | "$CC" --version | |
28 | ||
29 | ./configure "$@" $OSX_CONFOPTS | |
30 | err=$? | |
31 | if [ "$DUMP_CONFIG_LOG" = "short" ]; then | |
32 | grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE=" | |
33 | elif [ "$DUMP_CONFIG_LOG" = "full" ]; then | |
34 | cat config.log | |
35 | fi | |
36 | return $err | |
37 | } | |
38 | ||
39 | # TODO: integrate checkusage into our regular tests and remove this function | |
40 | function make_checkusage | |
41 | { | |
42 | local tmp | |
43 | if ! tmp=$($MAKE checkusage 2>&1) || test -n "$tmp"; then | |
44 | echo "$tmp" | |
45 | echo "make checkusage failed" >&2 | |
46 | return 1 | |
47 | fi | |
48 | } | |
49 | ||
50 | function check_nonroot | |
51 | { | |
52 | local opts="$MAKE_CHECK_OPTS --show-diff" | |
53 | ||
54 | xconfigure \ | |
55 | --disable-use-tty-group \ | |
56 | --disable-makeinstall-chown \ | |
57 | --enable-all-programs \ | |
58 | || return | |
59 | $MAKE || return | |
60 | ||
61 | osx_prepare_check | |
62 | $MAKE check TS_OPTS="$opts" || return | |
63 | ||
64 | make_checkusage || return | |
65 | ||
66 | $MAKE install DESTDIR=/tmp/dest || return | |
67 | } | |
68 | ||
69 | function check_root | |
70 | { | |
71 | local opts="$MAKE_CHECK_OPTS --show-diff" | |
72 | ||
73 | xconfigure \ | |
74 | --enable-all-programs \ | |
75 | || return | |
76 | $MAKE || return | |
77 | ||
78 | $MAKE check TS_COMMAND="true" || return | |
79 | osx_prepare_check | |
80 | sudo -E $MAKE check TS_OPTS="$opts" || return | |
81 | ||
82 | # root on osx has not enough permission for make install ;) | |
83 | [ "$TRAVIS_OS_NAME" = "osx" ] && return | |
84 | ||
85 | # keep PATH to make sure sudo would find $CC | |
86 | sudo env "PATH=$PATH" $MAKE install || return | |
87 | } | |
88 | ||
89 | function check_dist | |
90 | { | |
91 | xconfigure \ | |
92 | || return | |
93 | $MAKE distcheck || return | |
94 | } | |
95 | ||
96 | function travis_install_script | |
97 | { | |
98 | if [ "$TRAVIS_OS_NAME" = "osx" ]; then | |
99 | osx_install_script | |
100 | return | |
101 | fi | |
102 | ||
103 | # install required packages | |
104 | sudo apt-get -qq update --fix-missing | |
105 | sudo apt-get install -qq >/dev/null \ | |
106 | bc \ | |
107 | btrfs-tools \ | |
108 | dnsutils \ | |
109 | libcap-ng-dev \ | |
110 | libncursesw5-dev \ | |
111 | libpam-dev \ | |
112 | libudev-dev \ | |
113 | gtk-doc-tools \ | |
114 | mdadm \ | |
115 | ntp \ | |
116 | socat \ | |
117 | || return | |
118 | ||
119 | # install only if available (e.g. Ubuntu Trusty) | |
120 | sudo apt-get install -qq >/dev/null \ | |
121 | libsystemd-daemon-dev \ | |
122 | libsystemd-journal-dev \ | |
123 | || true | |
124 | } | |
125 | ||
126 | function osx_install_script | |
127 | { | |
128 | brew update >/dev/null | |
129 | ||
130 | brew install gettext ncurses socat xz | |
131 | brew link --force gettext | |
132 | brew link --force ncurses | |
133 | ||
134 | OSX_CONFOPTS=" | |
135 | --disable-ipcrm \ | |
136 | --disable-ipcs \ | |
137 | " | |
138 | ||
139 | # workaround: glibtoolize could not find sed | |
140 | export SED="sed" | |
141 | } | |
142 | ||
143 | function osx_prepare_check | |
144 | { | |
145 | [ "$TRAVIS_OS_NAME" = "osx" ] || return 0 | |
146 | ||
147 | # these ones only need to be gnu for our test-suite | |
148 | brew install coreutils findutils gnu-tar gnu-sed | |
149 | ||
150 | # symlink minimally needed gnu commands into PATH | |
151 | mkdir ~/bin | |
152 | for cmd in readlink seq timeout truncate find xargs tar sed; do | |
153 | ln -s /usr/local/bin/g$cmd $HOME/bin/$cmd | |
154 | done | |
155 | hash -r | |
156 | ||
157 | export TS_OPT_col_multibyte_known_fail=yes | |
158 | export TS_OPT_colcrt_regressions_known_fail=yes | |
159 | export TS_OPT_column_invalid_multibyte_known_fail=yes | |
160 | } | |
161 | ||
162 | function travis_before_script | |
163 | { | |
164 | set -o xtrace | |
165 | ||
166 | ./autogen.sh | |
167 | ret=$? | |
168 | ||
169 | set +o xtrace | |
170 | return $ret | |
171 | } | |
172 | ||
173 | function travis_script | |
174 | { | |
175 | local ret | |
176 | set -o xtrace | |
177 | ||
178 | case "$MAKE_CHECK" in | |
179 | nonroot) | |
180 | check_nonroot | |
181 | ;; | |
182 | root) | |
183 | check_root | |
184 | ;; | |
185 | dist) | |
186 | check_dist | |
187 | ;; | |
188 | *) | |
189 | echo "error, check environment (travis.yml)" >&2 | |
190 | false | |
191 | ;; | |
192 | esac | |
193 | ||
194 | # We exit here with case-switch return value! | |
195 | ret=$? | |
196 | set +o xtrace | |
197 | return $ret | |
198 | } | |
199 | ||
200 | function travis_after_script | |
201 | { | |
202 | local diff_dir | |
203 | local tmp | |
204 | ||
205 | # find diff dir from check as well as from distcheck | |
206 | diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1) | |
207 | if [ -d "$diff_dir" ]; then | |
208 | tmp=$(find "$diff_dir" -type f | sort) | |
209 | echo -en "dump test diffs:\n${tmp}\n" | |
210 | echo "$tmp" | xargs cat | |
211 | fi | |
212 | } |