File: 034_status

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 (225 lines) | stat: -rwxr-xr-x 4,326 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
#!/bin/bash

set -e
$INCLUDE_FUNCS

logfile=$LOGDIR/034.status

file=empty-file


function Filter
{
	filt=$1
	exp=$2

	$BINdflt st -C -f $filt $file > $logfile
	if [[ `wc -l < $logfile` -ne $exp ]]
	then
		cat $logfile
		$ERROR "Status output wrong - filter $filt, expected $exp."
	fi
}

function FiltMTOGNDA
{
	Filter meta $1
	Filter text $2
	Filter owner $3
	Filter group $4
	Filter new $5
	Filter deleted $6
	Filter any $7

	$SUCCESS "Trial run $1$2$3$4$5$6$7 ok."
}

export FSVS_DIR_SORT
# Keep the dir_sort option at the default *after* the loop; that's 
# necessary for tests afterwards.
for FSVS_DIR_SORT in yes no
do
	$INFO "Using dir_sort=$FSVS_DIR_SORT."

	$PREPARE_DEFAULT > /dev/null
	cd $WC



	# without any change?
	FiltMTOGNDA 0 0 0 0 0 0 0

	# meta-data change.
	touch -t 200101270007 $file
	FiltMTOGNDA 1 0 0 0 0 0 1

	# set as known state.
	$BINdflt ci -m 1

	# text change, meta-data same
	echo aiikortv > $file
	touch -t 200101270007 $file
	FiltMTOGNDA 0 1 0 0 0 0 1

	# text and meta-data change
	echo adehlnor > $file
	touch -t 200210291240 $file

	FiltMTOGNDA 1 1 0 0 0 0 1


	# deleted
	rm $file
	FiltMTOGNDA 0 1 0 0 0 1 1

	# replaced
	mkdir $file
	FiltMTOGNDA 1 1 0 0 1 1 1


	$INFO "Testing removed directories."

	mkdir -p a/b/c/d a/b/c/e a/b/d a/h/u a/h/j
	( cd a/h ; touch -d yesterday some files in dir )
	$BINq ci -m 2
	if [[ `$BINdflt st -o verbose=none,status a -N -N` == 'N...  ' ]]
	then
		$ERROR "Hierarchy a not committed"
	fi
	rmdir a/b/c/d a/b/c/e a/b/c a/h/u

	$BINdflt st -C -o filter=deleted > $logfile
	if [[ `wc -l < $logfile` -ne 4 || 
		`grep -w dir < $logfile | wc -l` -ne 4 ||
		`grep a/ < $logfile | wc -l` -ne 4 ]]
	then
		cat $logfile
		$ERROR "Status output wrong (deleted directories #1)"
	fi

	# The parent directories are changed, and that gets counted, too.
	$BINdflt st -C -o filter=text > $logfile
	if [[ `wc -l < $logfile` -ne 6 || 
		`grep a/ < $logfile | wc -l` -ne 6 ]]
	then
		cat $logfile
		$ERROR "Status output wrong (deleted directories #2)"
	fi

	date > a/h/some
	date > a/h/dir

	$BINdflt st -C > $logfile
	if [[ `wc -l < $logfile` -ne 8 || 
		`grep a/ < $logfile | wc -l` -ne 8 ]]
	then
		cat $logfile
		$ERROR "Status output wrong (deleted directories #3)"
	fi
done

$SUCCESS "Ok, filter works."

# set as known state.
$BINq ci -m 2 -o delay=yes

$INFO "Testing dir_exclude_mtime"

mkdir -p test1
$BINdflt ci -m 3
# wait some time after checkin
sleep 2
# change mtime of parent folder
touch test1/test2
# remove fake temp. file
rm    test1/test2
# test option
$BINdflt st -odir_exclude_mtime=true > $logfile

if [[ `wc -l < $logfile` -gt 0 ]]
then
  echo "logfile contains entries"
  cat $logfile
  $ERROR "dir_exclude_mtime option does not work"
fi

if ! $BINdflt st -ostop_change=true -odir_exclude_mtime=true
then 
  $ERROR "stop_change returns true in conjunction with dir_exclude_mtime"
fi

$SUCCESS "dir_exclude checks ok."

$PREPARE_DEFAULT > /dev/null
cd $WC

$INFO "Testing color output."

function HasEscape
{
	# I cannot make grep and egrep understand \x1b.
  if $BINdflt st -o stat_color=yes | perl -e 'exit (0 == grep(/\x1b\[0;0m/, <STDIN>))'
	then
	  $SUCCESS "$1 colorized"
	else
	  $ERROR "$1 not colorized"
	fi
}

echo aaa > hazgr
HasEscape "New"
$BINq ci -m1
echo aaar > hazgr
HasEscape "Changed"
$BINq ci -m1
rm hazgr
HasEscape "Deleted"



# Butterfly test.
# This checks the assertion BUG_ON(entry already output) for various inode 
# number sortings.
$INFO "Checking for inode dependencies."
cd ..
$PREPARE_CLEAN > /dev/null
cd $WC1

perl -e 'for $i (0 .. 15) { 
	$b = (($i & 5) << 1) | (($i & 0xa) >> 1);
	$a = (($b & 3) << 2) | (($b & 0xc) >> 2);
	for $c ( $a, $a ^ 0x1f)
	{
		$f= $c <= 9 ? $c : chr($c + 64+32+1-10);
		mkdir($f) || die "mkdir $f: $!"; 
		open(F, "> $f/file-$f") || die "touch file-$a: $!";
	}
}'

# Now move the directories into one another.
perl -e ' while (1)
{
	($g, $l)=reverse sort grep(/^\w$/, <?>);
	last if !defined($l);

	rename($g, $l . "/" . $g) || die "rename($g, $l): $!";
} '


$BINdflt st > $logfile
$BINq ci -m1

for a in z w r q k f d c 9 6
do
	find . -name file-$a -exec rm {} \;
	$BINdflt st > $logfile
done
$INFO "Files ok."

for a in q k f d c 9 6
do
	find . -depth -name $a -exec rm -r {} \;
	$BINdflt st > $logfile
done

$SUCCESS "Status seems to work regardless of the inode numbering."