summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlberto <alberto.ruiz@codethink.co.uk>2011-10-03 15:29:29 +0100
committerAlberto <alberto.ruiz@codethink.co.uk>2011-10-03 15:29:29 +0100
commit7000a3a6909294aed8c3ad794edbdddc3261c45c (patch)
tree0a1c553d30217e4e4128a1d5bb7c6b29e3ddfa39 /tests
parent02203eb936986e6b6b0b366120c6b3407f37d91c (diff)
downloadtbdiff-7000a3a6909294aed8c3ad794edbdddc3261c45c.tar.gz
Improvements to the test framework and documentation
Diffstat (limited to 'tests')
-rwxr-xr-xtests/02_symlink_add_remove.sh19
-rwxr-xr-xtests/03_regular_file_add_remove.sh33
-rwxr-xr-xtests/run_tests.sh16
3 files changed, 57 insertions, 11 deletions
diff --git a/tests/02_symlink_add_remove.sh b/tests/02_symlink_add_remove.sh
index b3280c2..e4b81a9 100755
--- a/tests/02_symlink_add_remove.sh
+++ b/tests/02_symlink_add_remove.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-TEST_ID="01"
-TEST_NAME="Simple symlink diff"
+TEST_ID="03"
+TEST_NAME="Symlink add/remove"
CREATE=`pwd`/$1
DEPLOY=`pwd`/$2
@@ -14,18 +14,19 @@ TEST_TOOLS=$3
# This test checks that normal files content and metadata are
function setup {
- ln -s /foo $ORIGIN/a && \
- ln -s /bar $TARGET/a && \
- chown -h :cdrom $TARGET/a
+ ln -s /foo $ORIGIN/remove && \
+ ln -s /bar $TARGET/add && \
+ chown -h :cdrom $TARGET/add
}
# check_same_mtime FILE_A FILE_B
function check_results {
- test -L $ORIGIN/a && \
- check_symlink $ORIGIN/a "/bar" && \
- check_group $ORIGIN/a cdrom && \
- check_same_mtime $ORIGIN/a $ORIGIN/a
+ test -L $ORIGIN/add && \
+ test ! -L $ORIGIN/remove && \
+ check_symlink $ORIGIN/add "/bar" && \
+ check_same_mtime $ORIGIN/add $TARGET/add && \
+ check_same_uidgid $ORIGIN/add $TARGET/add
}
#############################################
diff --git a/tests/03_regular_file_add_remove.sh b/tests/03_regular_file_add_remove.sh
new file mode 100755
index 0000000..f8b5652
--- /dev/null
+++ b/tests/03_regular_file_add_remove.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+TEST_ID="01"
+TEST_NAME="Regular file add remove"
+
+CREATE=`pwd`/$1
+DEPLOY=`pwd`/$2
+TEST_TOOLS=$3
+
+. ./test_lib.sh
+
+############# Test specific code ############
+
+# This test checks that normal files content and metadata are
+
+function setup {
+ touch $ORIGIN/remove && \
+ echo 1 > $TARGET/add && \
+ chown -h :cdrom $TARGET/add
+}
+
+# check_same_mtime FILE_A FILE_B
+
+function check_results {
+ test -f $ORIGIN/add && \
+ test ! -f $ORIGIN/remove && \
+ check_content $ORIGIN/add "1" && \
+ check_same_mtime $ORIGIN/add $TARGET/add && \
+ check_same_uidgid $ORIGIN/add $TARGET/add
+}
+
+#############################################
+main $@
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 024351e..873d2eb 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -1,15 +1,27 @@
#!/bin/bash
-if [ ! -f $TESTLIB ]
+if [ ! -f run_tests.sh ]
+then
+ echo "Test suite needs to be run from the tests directory" 1>&2
+ exit 1
+fi
+
+if [ ! -f test_lib.sh ]
then
echo "Could not find test_lib.sh" 1>&2
+ exit 1
fi
+ALLTESTSDIR=`pwd`
+
for i in [0-9][0-9]*
do
- ./$i $1 $2
+ cd $ALLTESTSDIR
+ ./$i ../tbdiff-create ../tbdiff-deploy
if [ $? -ne 0 ]
then
+ echo "Test program $i failed" 1>&2
+ cd $ALLTESTSDIR
exit 1
fi
done