added testcases for Unify_copy()
[util-vserver.git] / util-vserver / lib_internal / testsuite / copy-check
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 "ls -l $dir; rm -rf $dir" EXIT
23
24 COPY=${libinternaltestsuitedir:-$(dirname "$0")}/copy
25
26 test -x "$COPY"
27
28 function doit()
29 {
30     $COPY  $dir/$nr-in $dir/$nr-out
31     cmp -s $dir/$nr-in $dir/$nr-out
32 }
33
34 ## Usage: execCheck <nr> [<dd-args>*]
35 function execCheck()
36 {
37     local nr=$1
38     shift
39
40     dd if=/dev/urandom of=$dir/$nr-in "$@" &>/dev/null
41
42     doit $nr
43 }
44
45 ### Check 1: small file copy
46 execCheck 01 bs=10 count=1
47
48 ### Check 2: PAGESIZEd file copy
49 execCheck 02 bs=4096 count=1
50
51
52 ### Check 3: PAGESIZE+1 file copy
53 execCheck 03 bs=4097 count=1
54
55 ### Check 4: small sparse file copy
56 execCheck 04 bs=10   count=1 seek=1
57
58 ### Check 5: large sparse file copy
59 execCheck 05 bs=4097 count=1 seek=1
60
61 ### Check 6: large sparse file copy
62 execCheck 06 bs=4098 count=1 seek=1
63
64 ### Check 7: large sparse file copy
65 execCheck 07 bs=4099 count=1 seek=1
66
67 ### Check 8: large sparse file copy
68 execCheck 08 bs=4100 count=1 seek=1
69
70 ### Check 9: huge sparse file copy
71 execCheck 09 bs=1024 count=1 seek=$[ 1024*1024 * 5 ]
72
73 # ls -l $dir/*
74 # du    $dir/*