X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=.travis-functions.sh;h=992905a1639eb4e0b2a272cb113c7c2368b2f4d5;hb=b8671fe76370436beb37ca65ea1563c3284a2699;hp=bbfdf1f13bcdf16579c8cd386a4b000b1634a2a7;hpb=aa4e57e3ba6c8ae96cecc13009095fac7301fba1;p=thirdparty%2Futil-linux.git diff --git a/.travis-functions.sh b/.travis-functions.sh index bbfdf1f13b..992905a163 100755 --- a/.travis-functions.sh +++ b/.travis-functions.sh @@ -5,29 +5,41 @@ # - helper functions to be sourced from .travis.yml # - designed to respect travis' environment but testing locally is possible # +# Variables: +# +# TS_OPT__=yes +# - forces tests/functions.sh:ts_has_option() to return "yes" for +# variable in test +# +# TESTS_OPTIONS= +# TESTS_PARALLEL= +# TESTS_COMMAND= +# - overwrites default from tests/Makemodule.am +# +# Do not use TS_* prefix for any travis or build-system stuff. This prefix is +# exclusively used by tests/ stuff. +# if [ ! -f "configure.ac" ]; then echo ".travis-functions.sh must be sourced from source dir" >&2 return 1 || exit 1 fi -# some config settings -MAKE="make -j4" +## some config settings +# travis docs say we get 1.5 CPUs +MAKE="make -j2" DUMP_CONFIG_LOG="short" -# We could test (exotic) out-of-tree build dirs using relative or abs paths. -# After sourcing this script we are living in build dir. Tasks for source dir -# have to use $SOURCE_DIR. -SOURCE_DIR="." -BUILD_DIR="." -CONFIGURE="$SOURCE_DIR/configure" - -mkdir -p "$BUILD_DIR" -cd "$BUILD_DIR" || return 1 || exit 1 +# workaround ugly warning on travis OSX, +# see https://github.com/direnv/direnv/issues/210 +shell_session_update() { :; } -function configure_travis +function xconfigure { - "$CONFIGURE" "$@" + which "$CC" + "$CC" --version + + ./configure "$@" $OSX_CONFOPTS err=$? if [ "$DUMP_CONFIG_LOG" = "short" ]; then grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE=" @@ -37,74 +49,153 @@ function configure_travis return $err } -function check_nonroot +# TODO: integrate checkusage into our regular tests and remove this function +function make_checkusage { - local opts="$MAKE_CHECK_OPTS" + local tmp + if ! tmp=$($MAKE checkusage 2>&1) || test -n "$tmp"; then + echo "$tmp" + echo "make checkusage failed" >&2 + return 1 + fi +} - configure_travis \ +function check_nonroot +{ + local make_opts="$MAKE_CHECK_OPTS --show-diff --parsable" + local conf_opts="\ --disable-use-tty-group \ - --with-python \ - --enable-all-programs \ - --enable-gtk-doc \ - || return + --disable-makeinstall-chown \ + --enable-all-programs" + + if [ "$TRAVIS_OS_NAME" != "osx" ]; then + conf_opts="$conf_opts --enable-asan" + make_opts="$make_opts --memcheck-asan" + fi + + xconfigure $conf_opts || return $MAKE || return - $MAKE check TS_OPTS="$opts" || return + + osx_prepare_check + + # TESTS_* overwrites default from tests/Makemodule.am + $MAKE check TESTS_OPTIONS="$make_opts" || return + + make_checkusage || return + $MAKE install DESTDIR=/tmp/dest || return } function check_root { - local opts="$MAKE_CHECK_OPTS --parallel=1" + local make_opts="$MAKE_CHECK_OPTS --show-diff" + local conf_opts="--enable-all-programs" - configure_travis \ - --with-python \ - --enable-all-programs \ - || return + if [ "$TRAVIS_OS_NAME" != "osx" ]; then + conf_opts="$conf_opts --enable-asan" + make_opts="$make_opts --memcheck-asan" + fi + + xconfigure $conf_opts || return $MAKE || return - $MAKE check TS_COMMAND="true" || return - sudo -E $MAKE check TS_OPTS="$opts" || return - sudo $MAKE install || return + + # compile tests only + $MAKE check-programs || return + + # Modify environment for OSX + osx_prepare_check + + # TESTS_* overwrites default from tests/Makemodule.am + sudo -E $MAKE check TESTS_PARALLEL="" TESTS_OPTIONS="$make_opts" || return + + # root on osx has not enough permission for make install ;) + [ "$TRAVIS_OS_NAME" = "osx" ] && return + + # keep PATH to make sure sudo would find $CC + sudo env "PATH=$PATH" $MAKE install || return } function check_dist { - configure_travis \ + xconfigure \ || return $MAKE distcheck || return } function travis_install_script { - # install some packages from Ubuntu's default sources - sudo apt-get -qq update || return + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + osx_install_script + return + fi + + # install required packages + sudo apt-get -qq update --fix-missing sudo apt-get install -qq >/dev/null \ bc \ + btrfs-tools \ dnsutils \ libcap-ng-dev \ + libncursesw5-dev \ libpam-dev \ libudev-dev \ gtk-doc-tools \ + mdadm \ ntp \ + socat \ || return - # install/upgrade custom stuff from non-official sources - sudo add-apt-repository -y ppa:malcscott/socat || return - sudo apt-get -qq update || return + # install only if available (e.g. Ubuntu Trusty) sudo apt-get install -qq >/dev/null \ - socat \ - || return + libsystemd-daemon-dev \ + libsystemd-journal-dev \ + || true +} + +function osx_install_script +{ + brew update >/dev/null + + brew install gettext ncurses socat xz + brew link --force gettext + brew link --force ncurses + + OSX_CONFOPTS=" + --disable-ipcrm \ + --disable-ipcs \ + " + + # workaround: glibtoolize could not find sed + export SED="sed" +} + +function osx_prepare_check +{ + [ "$TRAVIS_OS_NAME" = "osx" ] || return 0 + + # these ones only need to be gnu for our test-suite + brew install coreutils findutils gnu-tar gnu-sed + + # symlink minimally needed gnu commands into PATH + mkdir ~/bin + for cmd in readlink seq timeout truncate find xargs tar sed; do + ln -s /usr/local/bin/g$cmd $HOME/bin/$cmd + done + hash -r + + export TS_OPT_col_multibyte_known_fail=yes + export TS_OPT_colcrt_regressions_known_fail=yes + export TS_OPT_column_invalid_multibyte_known_fail=yes } function travis_before_script { - pushd "$SOURCE_DIR" || return set -o xtrace ./autogen.sh ret=$? set +o xtrace - popd return $ret } @@ -141,10 +232,10 @@ function travis_after_script local tmp # find diff dir from check as well as from distcheck - diff_dir=$(find -type d -a -name "diff" | grep "tests/diff" | head -n 1) + diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1) if [ -d "$diff_dir" ]; then tmp=$(find "$diff_dir" -type f | sort) echo -en "dump test diffs:\n${tmp}\n" - echo "$tmp" | xargs -r cat + echo "$tmp" | xargs cat fi }