3 # Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 : ${srctestsuitedir=$srcdir/src/testsuite}
21 : ${srcdatadir=$srctestsuitedir/data}
22 : ${tmptopdir=/var/tmp}
23 : ${hashcalc:=$builddir/src/testsuite/hashcalc}
27 tmpdir=$(mktemp -d "$tmptopdir"/rpm-fake-test.XXXXXX)
28 trap "rm -rf $tmpdir" EXIT
30 ## Usage: createRandFile <name> <size>
31 function createRandFile
33 dd if=/dev/urandom of=$tmpdir/$1-$2 bs=$2 count=1 &>/dev/null
36 pg=$(getconf PAGESIZE)
38 for i in 2 4 8 15 16 23 42 32 64 68 $pg $[ pg+42 ] $[ pg*2 ] \
39 $[ pg*2-23 ] $[ pg*23+42 ]; do
40 createRandFile rand $[ i - 1 ]
41 createRandFile rand $i
42 createRandFile rand $[ i + 1 ]
47 test x"$ensc_use_expensive_tests" != xyes || {
48 dd if=/dev/urandom of=$tmpdir/rand-LARGE1 bs=$[ pg-1 ] count=1 seek=124123
49 dd if=/dev/urandom of=$tmpdir/rand-LARGE2 bs=$[ 1024*1024-1 ] count=1 seek=5003
50 #dd if=/dev/urandom of=$tmpdir/rand-LARGE3 bs=$[ pg-1 ] count=1 seek=12412373
53 for i in $tmpdir/rand-*; do
54 sha1_0=$($hashcalc "$i" SHA-1 | tr -d / )
55 sha1_1=$(sha1sum "$i" | awk '{ print $1}' )
57 test x"$sha1_0" = x"$sha1_1" || {
58 echo "SHA-1 mismatch at $(basename $i)"
62 md5_0=$($hashcalc "$i" MD5 | tr -d / )
63 md5_1=$(md5sum "$i" | awk '{ print $1}' )
65 test x"$md5_0" = x"$md5_1" || {
66 echo "MD5 mismatch at $(basename $i)"