From df0cedf62aa76598b9f1c48a1ae7cc4aa9a40ecc Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Tue, 25 Oct 2005 16:06:26 +0000 Subject: [PATCH] added hashcalc.sh git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2176 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/src/testsuite/Makefile-files | 8 +++- util-vserver/src/testsuite/hashcalc.sh | 71 +++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100755 util-vserver/src/testsuite/hashcalc.sh diff --git a/util-vserver/src/testsuite/Makefile-files b/util-vserver/src/testsuite/Makefile-files index 6575e8c..973809a 100644 --- a/util-vserver/src/testsuite/Makefile-files +++ b/util-vserver/src/testsuite/Makefile-files @@ -32,6 +32,9 @@ check_PROGRAMS += $(src_testsuite_check_passive_PRGS) \ if ENSC_HAVE_C99_COMPILER src_testsuite_check_src_C99_SCRPTS = src/testsuite/vunify-test.sh +if ENSC_HAVE_BEECRYPT +src_testsuite_check_src_C99_SCRPTS += src/testsuite/hashcalc.sh +endif else src_testsuite_check_src_C99_SCRPTS = endif @@ -46,8 +49,9 @@ TESTS += $(src_testsuite_check_active_PRGS) \ $(src_testsuite_check_src_SCRPTS) \ $(src_testsuite_check_gen_SCRPTS) -EXTRA_DIST += $(src_testsuite_check_src_SCRPTS) - +EXTRA_DIST += $(src_testsuite_check_src_SCRPTS) \ + src/testsuite/vunify-test.sh \ + src/testsuite/hashcalc.sh src_testsuite_rpm_fake_test_SOURCES = src/testsuite/rpm-fake-test.c diff --git a/util-vserver/src/testsuite/hashcalc.sh b/util-vserver/src/testsuite/hashcalc.sh new file mode 100755 index 0000000..600109a --- /dev/null +++ b/util-vserver/src/testsuite/hashcalc.sh @@ -0,0 +1,71 @@ +#! /bin/bash + +# Copyright (C) 2005 Enrico Scholz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +: ${srcdir=.} +: ${builddir=.} +: ${srctestsuitedir=$srcdir/src/testsuite} +: ${srcdatadir=$srctestsuitedir/data} +: ${tmptopdir=/var/tmp} +: ${hashcalc:=$builddir/src/testsuite/hashcalc} + +set -e + +tmpdir=$(mktemp -d "$tmptopdir"/rpm-fake-test.XXXXXX) +trap "rm -rf $tmpdir" EXIT + +## Usage: createRandFile +function createRandFile +{ + dd if=/dev/urandom of=$tmpdir/$1-$2 bs=$2 count=1 &>/dev/null +} + +pg=$(getconf PAGESIZE) + +for i in 2 4 8 15 16 23 42 32 64 68 $pg $[ pg+42 ] $[ pg*2 ] \ + $[ pg*2-23 ] $[ pg*23+42 ]; do + createRandFile rand $[ i - 1 ] + createRandFile rand $i + createRandFile rand $[ i + 1 ] +done + +: > $tmpdir/rand-0 + +test x"$ensc_use_expensive_tests" != xyes || { + dd if=/dev/urandom of=$tmpdir/rand-LARGE1 bs=$[ pg-1 ] count=1 seek=124123 + dd if=/dev/urandom of=$tmpdir/rand-LARGE2 bs=$[ 1024*1024-1 ] count=1 seek=5003 + #dd if=/dev/urandom of=$tmpdir/rand-LARGE3 bs=$[ pg-1 ] count=1 seek=12412373 +} &>/dev/null + +for i in $tmpdir/rand-*; do + sha1_0=$($hashcalc "$i" SHA-1 | tr -d / ) + sha1_1=$(sha1sum "$i" | awk '{ print $1}' ) + + test x"$sha1_0" = x"$sha1_1" || { + echo "SHA-1 mismatch at $(basename $i)" + exit 1 + } + + md5_0=$($hashcalc "$i" MD5 | tr -d / ) + md5_1=$(md5sum "$i" | awk '{ print $1}' ) + + test x"$md5_0" = x"$md5_1" || { + echo "MD5 mismatch at $(basename $i)" + exit 1 + } +done + +true -- 1.8.1.5