diff options
author | Martin Pool <mbp@sourcefrog.net> | 2004-09-10 02:01:34 +0000 |
---|---|---|
committer | Martin Pool <mbp@sourcefrog.net> | 2004-09-10 02:01:34 +0000 |
commit | 1e9b816b45dec797423cbf8fc7d04d3dd98859dd (patch) | |
tree | e5229f49b55cd6e54cd131c096b9f1a983702b9d | |
parent | 49ea8897099a29476326001172a1e317c28afca7 (diff) | |
download | librsync-1e9b816b45dec797423cbf8fc7d04d3dd98859dd.tar.gz |
Test script by Eran Tromer
-rwxr-xr-x | check-rdiff | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/check-rdiff b/check-rdiff new file mode 100755 index 0000000..ca3ff58 --- /dev/null +++ b/check-rdiff @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# Creates a pair of semi-random files and check if rdiff +# correctlys updates the first to the second. + +$size=5*1024*1024*1024; +$runlen=2000; + +sub makefile { # Make a moderately random $size-byte file + ($fname,$size)=@_; + print "Creating: $fname ($size bytes)\n"; + open OUT,">$fname" or die "Can't open $fname"; + for $i (1..$size/$runlen) { + $ch = chr(32+int(rand(127))) ; + print OUT ($ch x $runlen); + } + $ch = chr(32+int(rand(127))) ; + print OUT ($ch x ($size % $runlen)); +} + +sub run { + ($cmd)=@_; + print "Running: $cmd\n"; + system($cmd)==0 or die "FAILED!"; +} + +srand(0); +makefile('old',$size); +makefile('new',$size); +run("rdiff signature -b 6000 old old.sig"); +run("rdiff delta -s old.sig new delta"); +run("rdiff patch -s old delta new2"); +print "Comparing MD5 hashes...\n"; +$sum1 = `md5sum < new`; die 'Failed 1' unless $?==0; print $sum1; +$sum2 = `md5sum < new2`; die 'Failed 2' unless $?==0; print $sum2; +die "DIFFERENT\n" unless $sum1==$sum2; +print "SUCCESS\n" |