check_logfiles: 3.7.4.1
[omd.git] / t / test_all.sh
blob0caadccd1c4c10a57da5cf26f81f553efd068ca8
1 #!/bin/bash
3 if [ ! -d t ]; then
4 echo "please run via 'make test' from the project directory"
5 exit 1
6 fi
8 if [ $(id -u) -ne 0 ]; then
9 echo "please run as root because we need to create test sites"
10 exit 1
13 export PATH="$PATH:/usr/sbin"
15 # do we install a package?
16 if [ ! -z "$OMD_PACKAGE" ]; then
17 echo "###################################################################"
19 OMD_PACKAGE=`ls -1 $OMD_PACKAGE | head -n 1`
21 if [ ! -e "$OMD_PACKAGE" ]; then
22 echo "cannot install $OMD_PACKAGE: no such file"
25 echo "installing " `basename $OMD_PACKAGE`
27 # Debian / Ubuntu
28 if [ -x /usr/bin/apt-get ]; then
29 VERSION=`dpkg-deb -W --showformat='${Package}\n' $OMD_PACKAGE | sed -e 's/^omd-//'`
30 DEPENDS=`dpkg-deb -W --showformat='${Depends}\n' $OMD_PACKAGE | sed -e 's/debconf.*debconf-2.0,//' | tr -d ','`
31 apt-get -qq update && \
32 DEBIAN_FRONTEND=noninteractive apt-get -q -y --no-install-recommends install $DEPENDS && \
33 dpkg -i $OMD_PACKAGE && \
34 update-alternatives --set omd /omd/versions/$VERSION
36 # Centos
37 elif [ -x /usr/bin/yum ]; then
38 # remove version if alread installed
39 /usr/bin/yum remove -y `rpm -qp $OMD_PACKAGE`
40 /usr/bin/yum install -y --nogpgcheck $OMD_PACKAGE
42 # Suse
43 elif [ -x /usr/bin/zypper ]; then
44 # remove version if alread installed
45 /usr/bin/zypper --quiet --non-interactive remove `rpm -qp $OMD_PACKAGE`
46 /usr/bin/zypper --quiet --non-interactive install $OMD_PACKAGE
49 rc=$?
50 if [ $rc -ne 0 ]; then
51 echo "Package installation failed, cannot run tests..."
52 exit 1
56 # set perl environment
57 PERLARCH=$(perl -e 'use Config; print $Config{archname}')
58 export PERL5LIB="/omd/versions/default/lib/perl5/lib/perl5/${PERLARCH}:/omd/versions/default/lib/perl5/lib/perl5:$PERL5LIB"
60 if [ -z $OMD_BIN ]; then
61 OMD_BIN=/usr/bin/omd
64 echo "###################################################################"
65 echo "running tests..."
66 TESTS=t/*.t
67 VERBOSE="0"
68 if [ ! -z $1 ]; then
69 TESTS=$*
70 VERBOSE="1"
72 OMD_BIN=$OMD_BIN PERL_DL_NONLAZY=1 /usr/bin/env perl "-MExtUtils::Command::MM" "-e" "test_harness($VERBOSE)" $TESTS