File: 009_bigger_files

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (128 lines) | stat: -rwxr-xr-x 2,783 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash

set -e 
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC


function CheckSyntax
{
# verify that the byte numbers are ascending, hole-free, and that the MD5s 
# are correct
  perl -e '
	  use Digest::MD5 qw(md5_hex);

		open(DATA,shift) || die "open: $!"; 
		$data=join("", <DATA>); 
		close DATA;

		open(MD,shift) || die "open: $!";
		$pos=0;
		while (<MD>)
		{
			# line found
			$cnt--;
			($md5, $hash, $start, $length)=split(/\s+/);
			die "start $start != position $pos\n" if $start != $pos;
			die "MD5 differs\n" if $md5 ne md5_hex(substr($data, $pos, $length));

			$pos=$start+$length;
		}

		exit 0;
	' $1 $2
}


filename=big_file
sparse=sparse

if [[ -e $filename ]]
then
  rm $filename
	$BINq ci -m "delete the test-file"
fi

sparse_md5s=`$PATH2SPOOL $sparse md5s`
test -f $sparse_md5s && rm $sparse_md5s

# There was a performance problem with files of many zero bytes (but not 
# starting with them) ... every zero byte got its own manber-block or some 
# such.
( echo Test1 ; dd if=/dev/zero bs=1024k count=1 ; echo Test2 ) > many_0
# TODO: do sparse files on update, and test for it.

# make sure that VM usage stays sane.
ulimit -v 200000

seq 1 199999 > $filename
dd if=/dev/null of=$sparse bs=1024 count=1 seek=256k 2> /dev/null
echo "     ci1"
$BINq ci -m "big files"
ci_md5=`$PATH2SPOOL $filename md5s`
echo $ci_md5
CheckSyntax $filename $ci_md5

if [[ -f $sparse_md5s ]]
then
  $ERROR "For a sparse file no md5s should be written!"
else
  $SUCCESS "No md5s for a sparse file."
fi

echo "Another line" >> $filename
echo "     ci2"
$BINq ci -m "big file 2"
CheckSyntax $filename $ci_md5

if [[ -e $ci_md5 ]]
then
  $SUCCESS "Committing a big file creates the md5s-data"
else
  $ERROR "Committing a file doesn't create the md5s-data"
fi


# update other wc
$WC2_UP_ST_COMPARE
up_md5=`$PATH2SPOOL $WC2/$filename md5s "" $WC2`

if [[ ! -f $up_md5 ]]
then
  $ERROR "PATH2SPOOL wrong - got $up_md5"
fi

if cmp $ci_md5 $up_md5
then
  $SUCCESS "Update and commit give the same manber-hashes and MD5s"
else
  $ERROR_NB "Update and commit give DIFFERENT manber-hashes and/or MD5s!!"
	ls -la $ci_md5 $up_md5 2> /dev/null
	diff -uw $ci_md5 $up_md5 2> /dev/null
  $ERROR "Update and commit disagree"
fi

# for identical files this should always be correct, but better check ...
CheckSyntax $WC2/$filename $up_md5

# now delete the file and test if the .../md5s is gone.
rm $filename
$BINq ci -m "delete the big test-file"

$WC2_UP_ST_COMPARE

if [[ -e $ci_md5 ]]
then
  $ERROR "Committing a deleted file doesn't remove the md5s-data"
else
  $SUCCESS "Committing a deleted file removes the md5s-data"
fi

if [[ -e $up_md5 ]]
then
  $ERROR "Updating a deleted file doesn't remove the md5s-data"
else
  $SUCCESS "Updating a deleted file removes the md5s-data"
fi