vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

copy-check (2439B)


      1 #! /bin/bash
      2 ## $Id$
      3 
      4 # Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
      5 #  
      6 # This program is free software; you can redistribute it and/or modify
      7 # it under the terms of the GNU General Public License as published by
      8 # the Free Software Foundation; version 2 of the License.
      9 #  
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #  
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program; if not, write to the Free Software
     17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     18 
     19 set -e
     20 
     21 dir=$(mktemp -d ${TMP:-/var/tmp}/copy-check.XXXXXX)
     22 trap "rm -rf $dir" EXIT
     23 
     24 COPY=${libinternaltestsuitedir:-$(dirname "$0")}/copy
     25 
     26 test -x "$COPY"
     27 
     28 function execWrap()
     29 {
     30     nr=$1
     31     msg=$2
     32     shift 2
     33 
     34     "$@" || {
     35 	rc=$?
     36 	echo $"Test $nr '$msg' failed with code $rc"
     37 	return $rc
     38     }
     39 
     40     return 0
     41 }
     42 
     43 function doit()
     44 {
     45     execWrap "$nr" "copying"   $COPY $dir/$nr-in $dir/$nr-out
     46     execWrap "$nr" "comparing" cmp   $dir/$nr-in $dir/$nr-out
     47 }
     48 
     49 ## Usage: execCheck <nr> [<dd-args>*]
     50 function execCheck()
     51 {
     52     local nr=$1
     53     shift
     54 
     55     dd if=/dev/urandom of=$dir/$nr-in "$@" &>/dev/null
     56 
     57     doit $nr
     58 }
     59 
     60 LANG=C
     61 
     62 ### Check 1: small file copy
     63 execCheck 01 bs=10 count=1
     64 
     65 ### Check 2: PAGESIZEd file copy
     66 execCheck 02 bs=4096 count=1
     67 
     68 ### Check 3: PAGESIZE+1 file copy
     69 execCheck 03 bs=4097 count=1
     70 
     71 ### Check 3a: really large file copy
     72 test x"$ensc_use_expensive_tests" != xyes ||
     73     execCheck 03a bs=$[ 64 * 1024*1024 + 23 ] count=1
     74 
     75 ### Check 4: small sparse file copy
     76 execCheck 04 bs=10   count=1 seek=1
     77 
     78 ### Check 5: large sparse file copy
     79 execCheck 05 bs=4097 count=1 seek=1
     80 
     81 ### Check 6: large sparse file copy
     82 execCheck 06 bs=4098 count=1 seek=1
     83 
     84 ### Check 7: large sparse file copy
     85 execCheck 07 bs=4099 count=1 seek=1
     86 
     87 ### Check 8: large sparse file copy
     88 execCheck 08 bs=4100 count=1 seek=1
     89 
     90 ### Check 8a: really large sparse file copy
     91 test x"$ensc_use_expensive_tests" != xyes ||
     92     execCheck 08a bs=$[ 64 * 1024*1024 + 23 ] count=1 seek=1
     93 
     94 ### Check 9: huge sparse file copy
     95 test x"$ensc_use_expensive_tests" != xyes ||
     96     execCheck 09 bs=1024 count=1 seek=$[ 1024*1024 * 5 ]
     97 
     98 test x"$ensc_test_debug" != xyes || {
     99     ls -l $dir/* 
    100     du    $dir/*
    101 }