File: 015_sync_repos

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 (179 lines) | stat: -rwxr-xr-x 4,581 bytes parent folder | download | duplicates (5)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash

set -e 
$PREPARE_DEFAULT > /dev/null
$INCLUDE_FUNCS
cd $WC2


# The temporary filenames for the lists after update, sync, and from wc
TMP_UP=$LOGDIR/015.sync-repos-test.up.tmp
TMP_UP0=$LOGDIR/015.sync-repos-test.up0.tmp
TMP_SYNC=$LOGDIR/015.sync-repos-test.sync.tmp
TMP_WC=$LOGDIR/015.sync-repos-test.wc.tmp
logfile=$LOGDIR/015.log

dir_path=`$PATH2SPOOL $WC2 dir`

echo "Directory file is $dir_path"

REV=HEAD



# Get the dir-files.
################################

# If we do the sync-repos later it should take the inodes from the working
# copy, so that both entry lists are identically sorted.

function copy_dir
{
# Quick fix: the files $sync and $up won't be identical, as the RF_CHECK
# flag will be set for some entries.
	perl -e 'print scalar(<>); while (<>) { @a=split(/(\s+)/); $a[6] &= ~4; } '
}

echo "step 1: update from empty set."
rm -rf $WC2/*
rm $dir_path
# re-set the URL, so that we start empty.
echo $REPURL | $BINq urls load

$BINq up -r $REV
ls -lad tree/b
cp -a $dir_path $TMP_UP-ORIG
copy_dir < $dir_path > $TMP_UP
up_md5=`md5sum < $TMP_UP`

echo "step 2: update from already-up-to-date."
$BINq up -r $REV
cp -a $dir_path $TMP_UP-ORIG2
copy_dir < $dir_path > $TMP_UP0
up0_md5=`md5sum < $TMP_UP0`

echo "step 3: build new list"
rm $dir_path
$BINq _build-new-list -C
cp $dir_path $TMP_WC
wc_md5=`md5sum < $TMP_WC`

echo "step 4: sync"
# Do the sync at last, so that a correct list is left
# for other tests.
# Test whether a copy database gets removed.
# We need an entries file with correct revision numbers, so we do an 
# initial sync-repos before the copy.
$BINq sync-repos -r $REV
# We copy on an non-existing target; if we'd create that directory, the 
# status check below would fail.
$BINq cp tree/a ggg
$BINq sync-repos -r $REV

$BINdflt st > $logfile
if [[ `wc -l < $logfile ` -eq 0 ]]
then
	$SUCCESS "no status output - 1"
else
	cat $logfile
	$ERROR "status prints something - 1"
fi

if [[ `$BINdflt cp dump | wc -l` -eq 1 ]]
then
  $SUCCESS "copy db gets removed on sync-repos"
else
  $ERROR "copy db not removed on sync-repos?"
fi

# The "cp dump" iterates through the hash itself; look for the copy 
# markings in the status report, too.
if $BINdflt st -v | grep -F ".....+" > $logfile
then
	cat $logfile
  $ERROR "Still copy flags set"
else
# If grep returns an error, no lines were found.
  $SUCCESS "No copy flags set"
fi


# As the RF_CHECK flag is set, we need to normalize:
# - Header is taken unchanged
# - Keep the whitespace separator, to get the line as identical as possible.
# - The 4th field (counted beginning with 1 :-) has index 6 (separators).
cp -a $dir_path $TMP_SYNC-ORIG
copy_dir < $dir_path > $TMP_SYNC
sync_md5=`md5sum < $TMP_SYNC`

echo "found MD5s:      update=$up_md5"
echo "            noop update=$up0_md5"
echo "                   sync=$sync_md5"
echo "                from wc=$wc_md5"


if [[ $up_md5 == $up0_md5  ]]
then
	$SUCCESS "update ident with noop update"
	# remove temporary files on successful testing.
	# we keep them if any tests fails, though.
	rm $TMP_SYNC $TMP_UP0 $TMP_WC
else
	$ERROR_NB "$TMP_UP and $TMP_UP0 are different"
	diff -au $TMP_UP $TMP_UP0
	$ERROR "'fsvs update error"
fi


# test if status and update work
# root modified is allowed.
$BINdflt st > $logfile
if [[ `grep -v ' \.$' $logfile | wc -l` -eq 0 ]]
then
	$SUCCESS "no status output - 2"
else
	cat $logfile
	$ERROR "status prints something - 2"
fi

# Update to HEAD
$BINq up 

REV=3
# Now go down, sync with older revision, and go up again
$BINq up -r $REV
$BINq sync-repos -r $REV
$BINq up -r HEAD


$INFO "Updating entries without meta-data"
# Now do some other entries *without* the meta-data properties, and look.
# We have to get rid of special devices ... svn would bail out.
find . -not -type f -and -not -type d -exec rm {} \;
$BINq ci -m "no more special nodes"

svn import --no-ignore --no-auto-props -m no-meta . $REPURL/no-meta > /dev/null

# We'd like to fake some device entry; but that's not easily possible, as 
# there's no "svn propset URL" currently.

$BINq up > $logfile
$BINdflt st > $logfile
if [[ `wc -l < $logfile` -eq 0 ]]
then
	$SUCCESS "No status output after meta-data less update"
else
	cat $logfile
  $ERROR "Status output for meta-data-less entries unexpected"
fi

# Symlinks have lrwxrwxrwx, all other entries should be not writeable for 
# group/others.
find no-meta -not -type l -printf "%U %m\n" | grep -v "^$UID [67]00\$" > $logfile || true
if [[ `wc -l < $logfile` -eq 0 ]]
then
	$SUCCESS "Owner and mode correctly set."
else
	$ERROR "Wrong rights set - expected go-rwx."
fi