File: largefile.test

package info (click to toggle)
librsync 2.3.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,204 kB
  • sloc: ansic: 4,956; sh: 245; xml: 182; perl: 30; makefile: 21
file content (64 lines) | stat: -rwxr-xr-x 2,262 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/sh -e
#
# librsync -- the library for network deltas
# Copyright (C) 2001, 2014 by Martin Pool <mbp@sourcefrog.net>
#
# largefile.test: Generate some large random files with 50% matches
# and generate signature, delta, and patch files, comparing for
# correctness.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# Note this test is not included in make check because it creates very
# large data files and takes a long time.

srcdir='.'
. $srcdir/testcommon.sh

# Note $1 is used to specify "RDIFF" by cmake tests, so we use
# arguments after that.

# Allow the number of blocks to be specified in $2 in the form '64K'.
blocks=${2:-64K}

# Allow a data directory to be specified in $3 to use persistent
# random data files to make tests more repeatable, otherwise use
# $tmpdir.
datadir=${3:-$tmpdir}
echo "DATADIR $datadir"

# Use $4 to optionally specify a block size to use.
blocksize=${4:-1024}

old="$datadir/old.$blocks"
new="$datadir/new.$blocks"
sig="$datadir/sig.$blocks"
delta="$datadir/delta.$blocks"
out="$datadir/out.$blocks"

if [ ! -f "$old" ]; then
   mkdir -p $datadir
   dd bs=$blocks count=1024 if=/dev/urandom >"$old"
   dd bs=$blocks count=256 if=/dev/urandom >"$new"
   dd bs=$blocks count=256 skip=128 if="$old" >>"$new"
   dd bs=$blocks count=256 if=/dev/urandom >>"$new"
   dd bs=$blocks count=256 skip=640 if="$old" >>"$new"
fi

run_test time ${RDIFF} $debug -f -s -b $blocksize -S 8 signature $old $sig
run_test time ${RDIFF} $debug -f -s delta $sig $new $delta
run_test time ${RDIFF} $debug -f -s patch $old $delta $out
check_compare $new $out "large files"
true