From 807c3eebe1de06f8a81fd64ede0249a6339f19fe Mon Sep 17 00:00:00 2001 From: Danny Abukalam Date: Thu, 26 Jan 2012 17:23:27 +0000 Subject: Corrupted git repo --- tests/PATCHES/patchfive.tbd | Bin 0 -> 77 bytes tests/PATCHES/patchfour.tbd | Bin 0 -> 71 bytes tests/PATCHES/patchone.tbd | Bin 0 -> 56 bytes tests/PATCHES/patchseven.tbd | Bin 0 -> 75 bytes tests/PATCHES/patchsix.tbd | Bin 0 -> 74 bytes tests/PATCHES/patchthree.tbd | Bin 0 -> 69 bytes tests/PATCHES/patchtwo.tbd | Bin 0 -> 575 bytes tests/gen.sh | 63 +++++++++++++++++++++++++++++++++++++++ tests/lipsum.txt | 1 + tests/patch1.tbd | Bin 694 -> 0 bytes tests/patch2.tbd | Bin 294 -> 0 bytes tests/test.sh | 69 +++++++++++++++++++++++++++++++++++++++++++ tests/test_lib.sh | 30 +++++++++++++++++++ 13 files changed, 163 insertions(+) create mode 100644 tests/PATCHES/patchfive.tbd create mode 100644 tests/PATCHES/patchfour.tbd create mode 100644 tests/PATCHES/patchone.tbd create mode 100644 tests/PATCHES/patchseven.tbd create mode 100644 tests/PATCHES/patchsix.tbd create mode 100644 tests/PATCHES/patchthree.tbd create mode 100644 tests/PATCHES/patchtwo.tbd create mode 100755 tests/gen.sh create mode 100644 tests/lipsum.txt delete mode 100644 tests/patch1.tbd delete mode 100644 tests/patch2.tbd create mode 100755 tests/test.sh diff --git a/tests/PATCHES/patchfive.tbd b/tests/PATCHES/patchfive.tbd new file mode 100644 index 0000000..e1fea2f Binary files /dev/null and b/tests/PATCHES/patchfive.tbd differ diff --git a/tests/PATCHES/patchfour.tbd b/tests/PATCHES/patchfour.tbd new file mode 100644 index 0000000..95bc2a3 Binary files /dev/null and b/tests/PATCHES/patchfour.tbd differ diff --git a/tests/PATCHES/patchone.tbd b/tests/PATCHES/patchone.tbd new file mode 100644 index 0000000..45de964 Binary files /dev/null and b/tests/PATCHES/patchone.tbd differ diff --git a/tests/PATCHES/patchseven.tbd b/tests/PATCHES/patchseven.tbd new file mode 100644 index 0000000..cb0733e Binary files /dev/null and b/tests/PATCHES/patchseven.tbd differ diff --git a/tests/PATCHES/patchsix.tbd b/tests/PATCHES/patchsix.tbd new file mode 100644 index 0000000..e957a97 Binary files /dev/null and b/tests/PATCHES/patchsix.tbd differ diff --git a/tests/PATCHES/patchthree.tbd b/tests/PATCHES/patchthree.tbd new file mode 100644 index 0000000..9b80a66 Binary files /dev/null and b/tests/PATCHES/patchthree.tbd differ diff --git a/tests/PATCHES/patchtwo.tbd b/tests/PATCHES/patchtwo.tbd new file mode 100644 index 0000000..3e2b5e6 Binary files /dev/null and b/tests/PATCHES/patchtwo.tbd 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 Binary files a/tests/patch1.tbd and /dev/null differ diff --git a/tests/patch2.tbd b/tests/patch2.tbd deleted file mode 100644 index 9d04f8c..0000000 Binary files a/tests/patch2.tbd and /dev/null 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) -- cgit v1.2.1