Add unit testing

This commit is contained in:
Darko Poljak 2019-11-15 08:28:55 +01:00
commit 8f5d9b2c97
52 changed files with 89 additions and 118 deletions

View file

View file

View file

@ -0,0 +1 @@
5

View file

@ -0,0 +1 @@
4

View file

@ -0,0 +1 @@
4

View file

@ -0,0 +1 @@
2

5
test/conf/defaults/post_exec Executable file
View file

@ -0,0 +1,5 @@
#!/bin/cat
######################################################################
General post_exec executed.
######################################################################

5
test/conf/defaults/pre_exec Executable file
View file

@ -0,0 +1,5 @@
#!/bin/cat
######################################################################
General pre__exec executed.
######################################################################

View file

@ -0,0 +1 @@
.git

View file

View file

View file

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1 @@
.git

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1 @@
.git

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -0,0 +1 @@
/tmp/ccollect/backup-chint

View file

@ -0,0 +1 @@
.git

View file

@ -0,0 +1 @@
3

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1 @@
.git

View file

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1 @@
.git

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1 @@
.git

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

View file

View file

@ -0,0 +1 @@
/tmp/ccollect/backup

View file

@ -0,0 +1,5 @@
#!/bin/cat
######################################################################
Source post_exec executed.
######################################################################

View file

@ -0,0 +1,5 @@
#!/bin/cat
######################################################################
Source pre_exec executed.
######################################################################

View file

@ -0,0 +1 @@
/tmp/ccollect/source

View file

@ -1,18 +0,0 @@
#!/bin/sh
host="home.schottelius.org"
host=""
set -x
pcmd()
{
echo "$#", "$@"
if [ "$host" ]; then
ssh "$host" "$@"
else
$@
fi
}
#pcmd ls /
#pcmd cd /; ls "/is not there"
pcmd cd / && ls

View file

@ -1 +0,0 @@
CCOLLECT_CONF=./conf ./ccollect.sh daily -v local1

View file

@ -1 +0,0 @@
CCOLLECT_CONF=./conf ./ccollect.sh daily -v remote1

View file

@ -1,23 +0,0 @@
#!/bin/sh
ls /surely-not-existent$$ 2>/dev/null
if [ "$?" -ne 0 ]; then
echo "$?"
fi
ls /surely-not-existent$$ 2>/dev/null
ret=$?
if [ "$ret" -ne 0 ]; then
echo "$ret"
fi
# if is true, ls is fales
if [ "foo" = "foo" ]; then
ls /surely-not-existent$$ 2>/dev/null
fi
# but that's still the return of ls and not of fi
echo $?

View file

@ -1,29 +0,0 @@
#!/bin/sh
#
# 2009 Nico Schottelius (nico-ccollect at schottelius.org)
#
# This file is part of ccollect.
#
# ccollect is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ccollect is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ccollect. If not, see <http://www.gnu.org/licenses/>.
#
#
# Test the ccollect tools suite
#
set -x
tmp="$(mktemp /tmp/ccollect-tools.XXXXXXXXXXX)"
rm -rf "${tmp}"

View file

@ -1,44 +0,0 @@
#!/bin/sh
#
# Nico Schottelius <nico-linux //@// schottelius.org>
# Date: 27-Jan-2007
# Last Modified: -
# Description:
#
ccollect=../ccollect.sh
testdir="$(dirname $0)/test-backups"
confdir="$(dirname $0)/test-config"
source="$(hostname)"
source_source="/tmp"
interval="taeglich"
# backup destination
mkdir -p "$testdir"
source_dest="$(cd "$testdir"; pwd -P)"
# configuration
mkdir -p "${confdir}/sources/${source}"
ln -s "$source_dest" "${confdir}/sources/${source}/destination"
echo "$source_source" > "${confdir}/sources/${source}/source"
touch "${confdir}/sources/${source}/summary"
touch "${confdir}/sources/${source}/verbose"
mkdir -p "${confdir}/defaults/intervals/"
echo 3 > "${confdir}/defaults/intervals/$interval"
# create backups
CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a
touch "${source_source}/$(date +%s)-$$.1982"
CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a
touch "${source_source}/$(date +%s)-$$.42"
CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a
du -sh "$testdir"
du -shl "$testdir"
echo "Delete $testdir and $confdir after test"