File: 090_special

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 (161 lines) | stat: -rwxr-xr-x 3,346 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
#!/bin/bash

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

cd $WC


logfile=$LOGDIR/090.spec


mv tree gt
mkdir 4rg
for a in `seq 1 200`
do
  echo $a > 4rg/$a
done


# Commit a file that's actively changing
$BINdflt ci -m1 > 4rg/file

$BINdflt ci -m1 > 4rg/file2
$BINdflt ci -m1 > 4rg/file3
$BINq ci -m1

$WC2_UP_ST_COMPARE


###############################################################
# 
#  Test commit delay.
#  From common sense this should be done as soon as possible,
#  as most other tests need that to work; but in 001 it would
#  slow down even single case testing, and as 002 it might be
#  run after all other tests (with RANDOM_ORDER=1).
#  So we hope that it just works - and try to get a test
#  summary. 

$INFO "Testing commit delay"
function CT
{
	delay_start=`date +%s`
# Make sure the files have different lengths
	msecs=0
	for a in 1 22 333 4444
	do
		echo $a > file
		$BINq ci -m$a $1 > /dev/null
		nsec=`date +%_9N`
		c_msec=${nsec:0:3}
		msecs=$(($msecs + ${c_msec:=0}))
	done
# We get an error here if the result is 0 ... so make it at least 1.
	delta=$(expr `date +%s` - $delay_start + 1)
}

CT -odelay=yes
with_delay=$delta
wd_msec=$msecs
echo "With delay that took $delta seconds (dm=$wd_msec)"

CT -odelay=no
normal=$delta
n_msec=$msecs
echo "Without delay that took $delta seconds (dm=$n_msec)"

diff=$(expr $with_delay - $normal)
factor=$(expr $n_msec / $wd_msec)
$INFO "Difference $diff, factor $factor"

# At least two seconds difference should be here.
if [[ $diff -ge 2 ]]
then
  $SUCCESS "The delay option seems to work (runtime)."
else
	if [[ $factor -ge 4 ]]
	then
		$SUCCESS "The delay option seems to work (msec-diff)."
	else
		$ERROR "The delay option is too fast"
	fi
fi


$INFO "Testing delay command."
dirfile=`$PATH2SPOOL . dir`
touch -d "now + 2 seconds" $dirfile
a=`date +%s`
$BINdflt delay
b=`date +%s`
diff=`echo $b - $a | bc`
if [ $diff -ge 1 ]
then
	$SUCCESS "Delay command works."
else
	$ERROR "Delay command took only diff=$diff"
fi


# Test having *many* subdirectories in parallel in waa__output_dir(), 
# triggering reallocating the directory array.
# On tmpfs the inode numbers are given in ascending order; so creating many 
# directories, and then putting files there might do the trick.
# We do that as 50 * 50 directories, with each having a file.
$INFO "Creating many directories"
list=`seq 1 50`
declare -a entries
for a in $list
do
	mkdir $a
	for b in $list
	do
	  entries+=($a/$b/file)
		mkdir $a/$b
	done
done


# create files
touch "${entries[@]}"
opt=""
if [[ "$opt_DEBUG" == "1" ]]
then
  opt="-d -D waa__output_tree"
fi

$BINq ci -m1 $opt > $logfile
$WC2_UP_ST_COMPARE

if [[ "$opt_DEBUG" == "1" ]]
then
	if grep "reallocated directory pointers to " $logfile
	then
		$SUCCESS "Many parallel directories in output_tree"
	else
	# Should that only be a warning? Might not work on other filesystems.
		$ERROR "No realloc message found for many parallel directories"
	fi
else
  $WARN "no debug info compiled in"
fi

# If writing the tree didn't work, we will find out when we do a status or 
# another commit.
G=40/32/file
touch $G
if [[ `$BINdflt st` == ".m.."*" 0 "*"$G" ]]
then
	$SUCCESS "Entry list seems to be correct"
else
	$ERROR "Status wrong - entry list destroyed?"
fi
if $BINq ci -m1
then
	$SUCCESS "Commit ok"
else
	$ERROR "Commit barks"
fi
$WC2_UP_ST_COMPARE