File: 061_groupings

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 (238 lines) | stat: -rwxr-xr-x 4,570 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash

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


logfile=$LOGDIR/061.groups
grp_name=MightyTest
grp_dir=`$PATH2SPOOL $WC ^`/groups
grp_file=$grp_dir/$grp_name
cntr=1000

mkdir $grp_dir

# We do the changes without waiting, so we need that for the new files to 
# be found.
export FSVS_CHANGE_CHECK=dir 
# Don't report the changed root directory.
export FSVS_FILTER=new 



if $BINdflt group 'group:,./**'
then
	$ERROR "Empty group names are invalid."
fi


function SetGrpAndTest
{
	status=$1
	output_lines=$2
	shift
	shift

	cntr=`expr $cntr + 1`
	perl -e 'map { print $_,"\n"; } @ARGV' "$@" > $grp_file
	cur_file=file-$cntr
	date > $cur_file

	echo group:$grp_name,mode:0:0 | $BINq group load

	sta=1
	if $BINdflt st > $logfile 2>/dev/null
	then sta=0 ; fi

	if [[ "$status" != "$sta" ]]
	then
		cat $grp_file
		$ERROR_NB "Wrong status $sta (exp. $status) for"
		$ERROR "$@"
	fi

	if [[ `wc -l < $logfile` -ne "$output_lines" ]]
	then
		cat $logfile
		cat $grp_file
		$ERROR_NB "Expected $output_lines output for"
		$ERROR "$@"
	else
		$SUCCESS "'$@' ok"
	fi

	rm $grp_file
	true | $BINdflt group load > /dev/null
	$BINq ci -m1 > /dev/null
}

SetGrpAndTest 1 0 "invalid"
SetGrpAndTest 1 0 " auto-prop"
SetGrpAndTest 1 0 " auto-prop aa"

SetGrpAndTest 0 1 "# a comment"
SetGrpAndTest 0 1 "# comment" " # a further comment" "  # still another"
SetGrpAndTest 0 1 " auto-prop xxx test-prop"
SetGrpAndTest 0 0 "ignore"
SetGrpAndTest 0 0 " ignore     "
SetGrpAndTest 0 1 " # ignore     "
SetGrpAndTest 0 1 "take"
SetGrpAndTest 0 1 "take" "auto-prop aa bb"

SetGrpAndTest 1 0 "take" "# comment" "invalid"
SetGrpAndTest 1 0 "take" "# comment" "ignore"



# Test commit-pipe, too - this must be handled at commit time.
$INFO "committing a property."
file=hzuta
pn="hAsdd:das_3:1"
pd="äöüßµ§ property value"
echo "group:$grp_name,./**" | $BINdflt group load
cat > $grp_file <<EOT 
auto-prop $pn $pd
auto-prop fsvs:commit-pipe openssl enc -e -a
auto-prop fsvs:update-pipe openssl enc -d -a
EOT
date > $file
$BINdflt ci -m1 > $logfile

$INFO "verify"
got=`svn pg "$pn" "$REPURL/$file"`
if [[ "$got" != "$pd" ]]
then
	echo "got '$got'"
	$ERROR "Property not correctly committed?"
else
	$SUCCESS "Property via group committed."
fi

# Check whether the commit pipe is really used.
$WC2_UP_ST_COMPARE


# Check whether the property is stored (and used!) locally, too.
$INFO "verify local use"
export -n FSVS_FILTER
echo $$ - another test > $file
$BINdflt ci -m1 > $logfile
$WC2_UP_ST_COMPARE


$INFO "added file"
file=Added
date > $file
$BINq add $file > $logfile
$BINq ci -m1 $file >> $logfile 
$WC2_UP_ST_COMPARE
# Should be different - the repository data is in base64.
if svn cat $REPURL/$file | diff -u - $file > $logfile
then
	$ERROR "Property not used on added entry."
fi


function TP
{
	$BINdflt prop-list -v "$1" > $logfile
	if [[ `wc -l < $logfile` -ne $2 ]]
	then
		cat $logfile
		$ERROR "Wrong number of properties"
	fi
	# The non-ASCII characters in the property value are shown as \xXX, so we 
	# can't compare them directly.
	if false # [[ `sort < $logfile` != "$pn:"*"fsvs:commit-pipe:cat"* ]]
	then
		$ERROR "Properties wrong."
	fi
}

function S
{
	$BINq ps fsvs:commit-pipe cat $file > $logfile
}

function D
{
	$BINq pd fsvs:update-pipe $file >> $logfile
}

for entry in Set Del
do
	$INFO "propset and propdel; first $entry"

	file=Prop-$entry
	date > $file

	# A new file has no properties; just the "no properties" line is printed.
	TP $WC/$file 1
	opt=""
	if [[ "$entry" == "Set" ]] ; then 
		S
		TP $WC/$file 3
		D
	else
		D
		TP $WC/$file 2
		S
	fi
	TP $WC/$file 2

	$BINq ci -m1 $file >> $logfile 
	TP $WC/$file 2

	if ! svn cat $REPURL/$file | cmp - $file
	then
		$ERROR "Property not used on entry changed via prop-set and prop-del."
	fi
	$WC2_UP_ST_COMPARE

	TP $WC2/$file 2
done


$INFO "Testing the difference between ignore and group."
for g in "" "group:something,"
do
	for cmd in ignore group
	do
		st=1
		if echo "$g./**" | $BINq $cmd load
		then
			st=0
		fi

		should=0
		if [[ "$g" == "" && "$cmd" == "group" ]]
		then
			# FSVS 1.1.18 compatibility mode
			should=0
		fi

		if [[ "$st" != "$should" ]]
		then
			$ERROR "Wrong status for '$cmd' '$g'."
		fi
		
		# Test whether reading the group still works.
		$BINq st
	done
done

$SUCCESS "group/ignore difference ok."


# Test that only alphanumeric group names are allowed
for char in . - : _ \; / @
do
	if $BINq groups "group:G$char,./**" 2> $logfile
	then
		$ERROR "Group name 'G$char' shouldn't be allowed."
	fi
done

$SUCCESS "Group name restrictions seem ok."