summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Abukalam <dannyabukalam@codethink.co.uk>2012-01-26 17:23:27 +0000
committerDanny Abukalam <dannyabukalam@codethink.co.uk>2012-01-26 17:23:27 +0000
commit807c3eebe1de06f8a81fd64ede0249a6339f19fe (patch)
tree65adac868fe030315888e720c4883555a195cec9
parent1cc3604133185f822d1e076db455aee1b91a0506 (diff)
downloadtbdiff-807c3eebe1de06f8a81fd64ede0249a6339f19fe.tar.gz
Corrupted git repo
-rw-r--r--tests/PATCHES/patchfive.tbdbin0 -> 77 bytes
-rw-r--r--tests/PATCHES/patchfour.tbdbin0 -> 71 bytes
-rw-r--r--tests/PATCHES/patchone.tbdbin0 -> 56 bytes
-rw-r--r--tests/PATCHES/patchseven.tbdbin0 -> 75 bytes
-rw-r--r--tests/PATCHES/patchsix.tbdbin0 -> 74 bytes
-rw-r--r--tests/PATCHES/patchthree.tbdbin0 -> 69 bytes
-rw-r--r--tests/PATCHES/patchtwo.tbdbin0 -> 575 bytes
-rwxr-xr-xtests/gen.sh63
-rw-r--r--tests/lipsum.txt1
-rw-r--r--tests/patch1.tbdbin694 -> 0 bytes
-rw-r--r--tests/patch2.tbdbin294 -> 0 bytes
-rwxr-xr-xtests/test.sh69
-rw-r--r--tests/test_lib.sh30
13 files changed, 163 insertions, 0 deletions
diff --git a/tests/PATCHES/patchfive.tbd b/tests/PATCHES/patchfive.tbd
new file mode 100644
index 0000000..e1fea2f
--- /dev/null
+++ b/tests/PATCHES/patchfive.tbd
Binary files differ
diff --git a/tests/PATCHES/patchfour.tbd b/tests/PATCHES/patchfour.tbd
new file mode 100644
index 0000000..95bc2a3
--- /dev/null
+++ b/tests/PATCHES/patchfour.tbd
Binary files differ
diff --git a/tests/PATCHES/patchone.tbd b/tests/PATCHES/patchone.tbd
new file mode 100644
index 0000000..45de964
--- /dev/null
+++ b/tests/PATCHES/patchone.tbd
Binary files differ
diff --git a/tests/PATCHES/patchseven.tbd b/tests/PATCHES/patchseven.tbd
new file mode 100644
index 0000000..cb0733e
--- /dev/null
+++ b/tests/PATCHES/patchseven.tbd
Binary files differ
diff --git a/tests/PATCHES/patchsix.tbd b/tests/PATCHES/patchsix.tbd
new file mode 100644
index 0000000..e957a97
--- /dev/null
+++ b/tests/PATCHES/patchsix.tbd
Binary files differ
diff --git a/tests/PATCHES/patchthree.tbd b/tests/PATCHES/patchthree.tbd
new file mode 100644
index 0000000..9b80a66
--- /dev/null
+++ b/tests/PATCHES/patchthree.tbd
Binary files differ
diff --git a/tests/PATCHES/patchtwo.tbd b/tests/PATCHES/patchtwo.tbd
new file mode 100644
index 0000000..3e2b5e6
--- /dev/null
+++ b/tests/PATCHES/patchtwo.tbd
Binary files differ
diff --git a/tests/gen.sh b/tests/gen.sh
new file mode 100755
index 0000000..6f3e803
--- /dev/null
+++ b/tests/gen.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# This script generates seven folders with incremental
+# file type additions. This setup allows for the creation
+# of patches for cross-platform testing of tbdiff. These patches
+# are then commited and recreated and compared on different
+# platforms to check compatibility between different systems
+# including endianness and architecture.
+
+. ./test_lib.sh
+
+labelmeta() {
+ touch -ht 197001010100.42 $1
+ chmod 607 $1
+}
+
+cleanup() {
+ for ((i=0; i<8; i++)); do
+ rm -rf ${nums[$i]}
+ done
+}
+
+if [ ! -f run_tests.sh ]
+then
+ echo "Test needs to be run from the tests directory" 1>&2
+ exit 1
+fi
+
+if [ ! $(id -u) -eq 0 ]
+then
+ echo "Root."
+ exit 1
+fi
+
+if [ -d PATCHES ]
+then
+ echo -n "Overwrite Existing Patches? "
+ read input
+ input=`echo $input | tr '[:upper:]' '[:lower:]'`
+ case "$input" in
+ [Yy]|'') ;;
+ [Nn]*) echo "Aborted."; exit 1;;
+ *) echo "??";;
+ esac
+fi
+
+rm -rf PATCHES
+
+mkdir -p zero
+mkdir -p PATCHES
+for ((i=1; i<8; i++)); do
+ mkdir -p ${nums[$i]}
+ cd ${nums[$i]}
+ insertfiles $i
+ for ((j=1; j<=$i; j++)); do
+ labelmeta ${files[$j]}
+ done
+ cd ..
+ tbdiff-create PATCHES/patch${nums[$i]}.tbd ${nums[$(($i - 1))]} ${nums[$i]}
+done
+
+cleanup
+
+exit 0
diff --git a/tests/lipsum.txt b/tests/lipsum.txt
new file mode 100644
index 0000000..8f5f44b
--- /dev/null
+++ b/tests/lipsum.txt
@@ -0,0 +1 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisis porttitor ante ac cursus. Nulla odio magna, auctor in suscipit eu, aliquam id nisi. Maecenas id eros ligula. Nunc erat lacus, dictum sit amet facilisis sit amet, tincidunt ac diam. Integer imperdiet nibh et nulla ultrices et mattis massa vehicula. Aenean massa est, pretium in tincidunt eget, porttitor ac dolor. Etiam vehicula feugiat egestas. Donec felis enim, auctor ac consequat non, pretium sed dui. Maecenas eget urna at purus congue luctus.
diff --git a/tests/patch1.tbd b/tests/patch1.tbd
deleted file mode 100644
index 98f2c3d..0000000
--- a/tests/patch1.tbd
+++ /dev/null
Binary files differ
diff --git a/tests/patch2.tbd b/tests/patch2.tbd
deleted file mode 100644
index 9d04f8c..0000000
--- a/tests/patch2.tbd
+++ /dev/null
Binary files differ
diff --git a/tests/test.sh b/tests/test.sh
new file mode 100755
index 0000000..bb71bd5
--- /dev/null
+++ b/tests/test.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+if [ ! -f run_tests.sh ]
+then
+ echo "Test 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
+if [ ! $(id -u) -eq 0 ]
+then
+ echo "Test needs to be run as root" 1>&2
+ exit 1
+fi
+if [ ! -d PATCHES ];
+then
+ echo "Could not find test patches. Check tests/PATCHES or run tests/gen.sh\
+ to generate new patches for testing" 1>&2
+ exit 1
+fi
+
+error() {
+ echo "Failed"
+ cd $_TESTFOLDER
+# cleanup_and_exit
+ exit 1
+}
+
+_TESTFOLDER=`pwd`
+
+. ./test_lib.sh
+
+#trap error ERR
+
+echo -e "\n#### Running Cross-platform Test"
+
+echo -e "\nPreparing Test Environment... "
+mkdir balls
+cd $_TESTFOLDER/balls
+for ((i=0; i<8; i++)); do
+ mkdir ${nums[$i]}
+done
+for ((i=1; i<7; i++)); do
+ cd ${nums[$i]}
+ echo -e "\nI'M IN ${nums[$i]}!!\n"
+ for ((j=1; j<=i; j++)); do
+ tbdiff-deploy $_TESTFOLDER/PATCHES/patch${nums[$j]}.tbd
+ done
+ cd ..
+done
+
+echo -e "\nCreating Patches... "
+mkdir -p TESTPATCHES
+for ((i=1; i<8; i++)); do
+ tbdiff-create TESTPATCHES/primepatch${nums[$i]}.tbd ${nums[$i]} ${nums[$(($i+1))]}
+done
+
+for ((i=1; i<7; i++)); do
+ echo -en "Checking Patch $ii..."
+ diff TESTPATCHES/primepatch${nums[$i]}.tbd $_TESTFOLDER/PATCHES/patch${nums[$j]}.tbd
+ if [ $? -eq 0 ]; then
+ echo OK
+ else
+ error
+ fi
+done
diff --git a/tests/test_lib.sh b/tests/test_lib.sh
index 0ae5399..d395ce2 100644
--- a/tests/test_lib.sh
+++ b/tests/test_lib.sh
@@ -6,6 +6,36 @@ IMGFILE=$TESTDIR/tbdiff.img
ORIGIN=$TESTDIR/orig
TARGET=$TESTDIR/target
+nums=( zero one two three four five six seven )
+files=( null a.txt b.txt dirdir dirdir/fifo dirdir/symlinkb dirdir/chardev \
+ dirdir/blockdev )
+
+TOPDIR=`pwd`
+
+insertfiles() {
+ if [ $1 -ge 1 ]; then
+ echo 1 > a.txt
+ fi
+ if [ $1 -ge 2 ]; then
+ cat $TOPDIR/lipsum.txt > b.txt
+ fi
+ if [ $1 -ge 3 ]; then
+ mkdir -p dirdir
+ fi
+ if [ $1 -ge 4 ]; then
+ mkfifo dirdir/fifo
+ fi
+ if [ $1 -ge 5 ]; then
+ ln -s ../b.txt dirdir/symlinkb
+ fi
+ if [ $1 -ge 6 ]; then
+ mknod dirdir/chardev c `stat /dev/null -c '%t %T'`
+ fi
+ if [ $1 -ge 7 ]; then
+ mknod dirdir/blockdev b `stat /dev/null -c '%t %T'`
+ fi
+}
+
# check_same_mtime FILE_A FILE_B
check_same_mtime () {
test $(stat -c %Y $1) = $(stat -c %Y $2)