File: 024_urls

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 (213 lines) | stat: -rwxr-xr-x 4,474 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash

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

logfile=$LOGDIR/024.urls


# clean up
echo "" | $BINq urls load

prio=15
for p in http https svn svn+ssh file svn+some_other_tunnel svn+1
do
	$BINq urls N:$p,prio:$prio,T:$prio,$p://$p/some/path
	# Do pseudo-random
	prio=`perl -e 'print +(shift()*11+41) % 61' $prio`
done
$SUCCESS "Set all known protocols"

if $BINq urls unknown:///void 2> /dev/null
then
  $ERROR "Invalid protocols are accepted"
else
  $SUCCESS "Invalid protocols are rejected"
fi

if $BINq urls svn+:///void 2> /dev/null
then
  $ERROR "'svn+' is wrong, but got accepted"
else
  $SUCCESS "'svn+' rejected"
fi



# Having a invalid sequence
if $BINq urls dump '\\\r\n\t\f\x01\*' > /dev/null 2>&1 ||
	$BINq urls dump '%n%t%u%p%r%%%/' > /dev/null 2>&1 
then
  $ERROR "Parsing escape sequences doesn't work"
fi


# We would have to do the sorting afterwards - if the program fails, 
# we wouldn't get the error.
# But if there's an priority, the output order is defined.
$BINq urls dump > urls.txt
$BINq urls load < urls.txt
$BINq urls dump > urls2.txt

if cmp urls.txt urls2.txt
then
  $SUCCESS "Dump/Load works"
else
  $ERROR "Dump/Load gives different results!"
fi

url=http://egal
echo "name:1qay,P:9812,target:HEAD,$url" | $BINq urls load
if [[ `$BINdflt urls dump '%p'` != 9812 ]]
then
  $ERROR "Dumping priority with '%p'"
fi
if [[ `$BINdflt urls dump '%u'` != $url ]]
then
  $ERROR "Dumping url with '%u'"
fi
if [[ `$BINdflt urls dump '%n'` != 1qay ]]
then
  $ERROR "Dumping name with '%n'"
fi
if [[ `$BINdflt urls dump '%%\x20%%'` != "% %" ]]
then
  $ERROR "Dumping some other format"
fi
if [[ `$BINdflt urls dump '%t'` != "HEAD" ]]
then
	$ERROR "Dumping target revision with '%t'"
fi
$SUCCESS "URL load/dump tests pass"


$BINq urls "prio:22,N:XX,$url"
if [[ `$BINdflt urls dump | wc -l` -ne 1 ]]
then
  $ERROR "URL taken twice"
fi
if [[ `$BINdflt urls dump '%p'` != 22 ]]
then
  $ERROR "Changing priority with '%p'"
fi
if [[ `$BINdflt urls dump '%n'` != XX ]]
then
  $ERROR "Changing name with '%n'"
fi
$SUCCESS "URL change tests pass"


if $BINq urls "N:XX,$url/g" > /dev/null 2>&1
then
	$ERROR "Duplicate names should not be allowed"
else
	$SUCCESS "Duplicate names rejected"
fi


# Test error for non-WC directories
mkdir Xt
cd Xt
if $BINdflt urls dump > $logfile 2>&1
then
	cat $logfile
	$ERROR "No error for non-WC-directories"
else
	if grep $(pwd) $logfile
	then
		$SUCCESS "Error message with path printed"
	else
		cat $logfile
		$ERROR "No or wrong error message"
	fi
fi


# Test keeping the internal numbers
U1=name:1,file:///r/1
U2=name:2,file:///r/2
U3=name:3,file:///r/3
echo -e "$U1\n$U2\n$U3\n" | $BINdflt urls load
$BINdflt urls dump "%u %I\\n" | sort > f-1
echo -e "$U2\n$U3\n$U1\n" | $BINdflt urls load
$BINdflt urls dump "%u %I\\n" | sort > f-2
echo -e "$U3\n$U2\n$U1\n" | $BINdflt urls load
$BINdflt urls dump "%u %I\\n" | sort > f-3
md5sum f-?
if [[ `md5sum f-? | cut -f1 -d" " | sort -u | wc -l` -eq	1 ]]
then
	$SUCCESS "Internal URL numbers are kept."
else
	$ERROR "Internal URL numbers lost."
fi

for a in s sv svn svn: svn:/ svn://
do
	if $BINq urls $a
	then
		$ERROR "invalid URL $a accepted"
	fi
done
$SUCCESS "Cut-off URLs not taken."
if $BINq urls svn://x/t
then
	$SUCCESS "Valid URL taken."
else
	$ERROR "Valid URL not taken."
fi


# Test changes.
function CU
{
	dump="$1"
	exp="$2"
	decl="$3"
	if [[ `$BINdflt urls dump "$dump"` == $exp ]]
	then
		$SUCCESS "$decl"
	else
		$ERROR_NB "expected '$exp', got:"
		$BINdflt urls dump "$dump"
		echo
		$ERROR "$decl"
	fi
}

( echo name:n1,prio:8,target:3,http://localhost/nothing ;
	echo prio:4,name:n2,file:///hopeless ) | $BINq urls load

CU "%n-%p-%t:" 'n2-4-HEAD:n1-8-3:' "Loading with reversed priority"

$BINdflt urls N:n1,prio:3
CU "%n-%p:" 'n1-3:n2-4:' "Reversing priority"

$BINdflt urls N:n3,http://localhost/nothing
CU "%n-%p:" 'n3-3:n2-4:' "Changing name"

$BINdflt urls target:87,http://localhost/nothing
CU "%n-%t:" 'n3-87:n2-HEAD:' "Changing the target revision"


cd $WC1
echo "$REPURL" | $BINq urls load
$BINq ci -m1
$WC2_UP_ST_COMPARE

# Check that nothing below FSVS_CONF gets changed for update/commit - not 
# even the timestamps.
mkdir -p aaa b/c/d b/k
date | tee aaa/2 5g3 b/gg b/c/d/5 > $RANDOM
find $FSVS_CONF -ls | sort > $logfile
$BINq ci -m2
$WC2_UP_ST_COMPARE
find $FSVS_CONF -ls | sort > $logfile.2
if diff -u $logfile $logfile.2
then
	$SUCCESS "FSVS_CONF not changed on commit/update."
else
	$ERROR "FSVS_CONF changed"
fi