X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib_internal%2Ftestsuite%2Fcopy-check;fp=lib_internal%2Ftestsuite%2Fcopy-check;h=77158d8af3701b2a2119012016976e68099ece7f;hb=9c78378bebc1a9f3d400f422df8ede9efea57dea;hp=0000000000000000000000000000000000000000;hpb=faa778968d1a7dfeaebc9fe4b847e691dc62fd15;p=util-vserver.git diff --git a/lib_internal/testsuite/copy-check b/lib_internal/testsuite/copy-check new file mode 100755 index 0000000..77158d8 --- /dev/null +++ b/lib_internal/testsuite/copy-check @@ -0,0 +1,101 @@ +#! /bin/bash +## $Id$ + +# 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. + +set -e + +dir=$(mktemp -d ${TMP:-/var/tmp}/copy-check.XXXXXX) +trap "rm -rf $dir" EXIT + +COPY=${libinternaltestsuitedir:-$(dirname "$0")}/copy + +test -x "$COPY" + +function execWrap() +{ + nr=$1 + msg=$2 + shift 2 + + "$@" || { + rc=$? + echo $"Test $nr '$msg' failed with code $rc" + return $rc + } + + return 0 +} + +function doit() +{ + execWrap "$nr" "copying" $COPY $dir/$nr-in $dir/$nr-out + execWrap "$nr" "comparing" cmp $dir/$nr-in $dir/$nr-out +} + +## Usage: execCheck [*] +function execCheck() +{ + local nr=$1 + shift + + dd if=/dev/urandom of=$dir/$nr-in "$@" &>/dev/null + + doit $nr +} + +LANG=C + +### Check 1: small file copy +execCheck 01 bs=10 count=1 + +### Check 2: PAGESIZEd file copy +execCheck 02 bs=4096 count=1 + +### Check 3: PAGESIZE+1 file copy +execCheck 03 bs=4097 count=1 + +### Check 3a: really large file copy +test x"$ensc_use_expensive_tests" != xyes || + execCheck 03a bs=$[ 64 * 1024*1024 + 23 ] count=1 + +### Check 4: small sparse file copy +execCheck 04 bs=10 count=1 seek=1 + +### Check 5: large sparse file copy +execCheck 05 bs=4097 count=1 seek=1 + +### Check 6: large sparse file copy +execCheck 06 bs=4098 count=1 seek=1 + +### Check 7: large sparse file copy +execCheck 07 bs=4099 count=1 seek=1 + +### Check 8: large sparse file copy +execCheck 08 bs=4100 count=1 seek=1 + +### Check 8a: really large sparse file copy +test x"$ensc_use_expensive_tests" != xyes || + execCheck 08a bs=$[ 64 * 1024*1024 + 23 ] count=1 seek=1 + +### Check 9: huge sparse file copy +test x"$ensc_use_expensive_tests" != xyes || + execCheck 09 bs=1024 count=1 seek=$[ 1024*1024 * 5 ] + +test x"$ensc_test_debug" != xyes || { + ls -l $dir/* + du $dir/* +}