From fc62c87a2ccf0fdaee705350b26650b4370b95a9 Mon Sep 17 00:00:00 2001 From: Danny Abukalam Date: Fri, 27 Jan 2012 14:17:35 +0000 Subject: Cross-Platform testing still kind of broken... --- Makefile | 4 +- tests/cross_plat.sh | 180 ++++++++++++++++++++++++++-------------------------- tests/gen.sh | 4 +- tests/test.sh | 69 -------------------- 4 files changed, 96 insertions(+), 161 deletions(-) delete mode 100755 tests/test.sh diff --git a/Makefile b/Makefile index 3c83800..98cc33f 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,9 @@ uninstall: rm -rf /usr/local/bin/$(CREATE) test: - cd tests && ./run_tests.sh && fakeroot -- ./cross_plat.sh && cd .. + cd tests && ./run_tests.sh && cd .. +# cross platform test needs fixing +# cd tests && ./run_tests.sh && fakeroot -- ./cross_plat.sh && cd .. .PHONY: clean diff --git a/tests/cross_plat.sh b/tests/cross_plat.sh index b29163e..82937de 100755 --- a/tests/cross_plat.sh +++ b/tests/cross_plat.sh @@ -1,104 +1,106 @@ #!/bin/bash +# Deploys the patch files in PATCHES, which were ideally generated on a x64 +# Little-endian system using gen.sh. It then creates its own patches, the +# idea being that upon diffing the committed patches and these patches, they +# should be identical. +# +# It creates seven patches at the moment, one for each change made. This is +# because tbdiff doesn't sort files before it puts them into patches, so +# the order in which files are created can differ from system to system, +# making the patch files different even though they're the same. By limiting +# each patch to only one change, the patches will be identical. -CWD=`pwd` +# CURRENTLY BROKEN!! PATCHES ARE DIFFERENT DUE TO WHAT I SUSPECT IS A DIFF +# IN THE MTIME OF THE ORIGINAL PATCHES AND THE CREATED ONES. -CREATE="../tbdiff-create" -DEPLOY="../tbdiff-deploy" +# To clarify, these are two hexdumps of patch 1, which simply echos 1 into +# a file called a.txt. The first is the committed patch generated by gen.sh, +# and the second is a patch generated by cross_plat.sh. Hint: 4a!! +# +# 0000000 \0 022 \0 C o d e t h i n k : T B D +# 0000020 I F F v 0 005 \0 a . t x t * \0 \0 +# 0000040 \0 \0 \0 \0 \0 207 201 \0 \0 \0 \0 \0 \0 \0 \0 \0 +# 0000060 \0 002 \0 \0 \0 1 \n 001 +# 0000070 +# +# 0000000 \0 022 \0 C o d e t h i n k : T B D +# 0000020 I F F v 0 005 \0 a . t x t * \0 \0 +# 0000040 \0 \0 \0 \0 \0 207 201 \0 \0 350 003 \0 \0 350 003 \0 +# 0000060 \0 002 \0 \0 \0 1 \n 001 +# 0000070 +# +# -PATCH1="../patch1.tbd" -PATCH2="../patch2.tbd" - -EMPTY="empty" -MIDDIR="middir" -FINALDIR="finaldir" - -cleanup() { - echo "Cleaning up..." - cd $CWD - rm -rf $EMPTY $MIDDIR $FINALDIR patch1prime.tbd patch2prime.tbd -} -checkmeta() { - cd $CWD - echo "Checking metadata..." - cd $MIDDIR - #1325779232 is the hardcoded creation time of b.txt and blockdev in patch1 - if [ `stat -c %Y b.txt` -eq 1325779232 ]; then - echo "b.txt OK" - else - echo "Metadata mismatch" - cleanup - exit 1 - fi - if [ `stat -c %Y dirdir/blockdev` -eq 1325779232 ]; then - echo "blockdev OK" - else - echo "Metadata mismatch" - cleanup - exit 1 - fi - cd .. - cd $FINALDIR - #1325769455 is the hardcoded creation time of a.txt and fifo in patch2 - if [ `stat -c %Y a.txt` -eq 1325769455 ]; then - echo "a.txt OK" - else - echo "Metadata mismatch" - cleanup - exit 1 - fi - if [ `stat -c %Y dirdir/fifo` -eq 1325769455 ]; then - echo "fifo OK" - else - echo "Metadata mismatch" - cleanup - exit 1 - fi - cd .. -} - -echo -e "\n#### Preparing Cross Platform Test" if [ ! -f run_tests.sh ] then echo "Test needs to be run from the tests directory" 1>&2 - cleanup exit 1 fi - -mkdir $EMPTY -mkdir $MIDDIR -cd $MIDDIR -../$DEPLOY $PATCH1 -cd .. - -cp -R $MIDDIR $FINALDIR -cd $FINALDIR -../$DEPLOY $PATCH2 -cd .. - -$CREATE patch1prime.tbd $EMPTY $MIDDIR -$CREATE patch2prime.tbd $MIDDIR $FINALDIR - -echo -e "\n#### Testing ####" -echo "Checking Diffs..." -diff patch1.tbd patch1prime.tbd -if [ $? -eq 0 ]; then - echo -n "Patch 1: " - echo OK -else - cleanup +if [ ! -f test_lib.sh ] +then + echo "Could not find test_lib.sh" 1>&2 exit 1 fi -diff patch2.tbd patch2prime.tbd -if [ $? -eq 0 ]; then - echo -n "Patch 2: " - echo OK -else - cleanup +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 +} -checkmeta -cleanup -echo "#####################################################################" +_TESTFOLDER=`pwd` -exit 0 +. ./test_lib.sh + +#trap error ERR + +echo -e "\n#### Running Cross-platform Test" + +echo -e "\nPreparing Test Environment... " +#mkdir foo +#cd $_TESTFOLDER/foo +cd $TESTDIR +# Create 8 folders, one, two ... +for ((i=0; i<8; i++)); do + mkdir ${nums[$i]} +done + +# Deploy the patches in PATCHES/ to those folders +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 + +# Create your own patches +echo -e "\nCreating Patches... " +mkdir -p TESTPATCHES +for ((i=0; i<7; i++)); do + tbdiff-create TESTPATCHES/primepatch${nums[$(($i+1))]}.tbd ${nums[$i]} ${nums[$(($i+1))]} +done + +# Diff patches. Should be identical +for ((i=1; i<8; i++)); do + echo -en "Checking patch ${nums[$i]}... " + diff TESTPATCHES/primepatch${nums[$i]}.tbd $_TESTFOLDER/PATCHES/patch${nums[$i]}.tbd 2>/dev/null 1>&2 + if [ $? -eq 0 ]; then + echo OK + else + error + fi +done diff --git a/tests/gen.sh b/tests/gen.sh index 6f3e803..652728f 100755 --- a/tests/gen.sh +++ b/tests/gen.sh @@ -51,8 +51,8 @@ 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]} +# for ((j=1; j<=$i; j++)); do +# labelmeta ${files[$j]} done cd .. tbdiff-create PATCHES/patch${nums[$i]}.tbd ${nums[$(($i - 1))]} ${nums[$i]} diff --git a/tests/test.sh b/tests/test.sh deleted file mode 100755 index bb71bd5..0000000 --- a/tests/test.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/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 -- cgit v1.2.1