File: 003_change_type

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 (136 lines) | stat: -rwxr-xr-x 2,862 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
#!/bin/bash

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

logfile=$LOGDIR/003.change_types

if [[ $UID -eq 0 ]]
then
	ONLY_ROOT=
else
	ONLY_ROOT=ignore_func
	function ignore_func()
	{
	  true
	}
fi

if test -d typechange
then
  rm -r typechange
fi

mkdir typechange
 pushd typechange > /dev/null

 for i in file device symlink dir missing fifo
 do
	 echo file $RANDOM > file-$i
	 $ONLY_ROOT cp -a /dev/zero device-$i
	 ln -s file-$i symlink-$i
	 mkdir dir-$i
	 echo sub $RANDOM > dir-$i/sub-entry
	 mkdir dir-$i/sub
	 echo $RANDOM > dir-$i/sub/sub-entry
	 mkfifo fifo-$i
 done
popd > /dev/null


$BINq ci -m "inserted types" -o delay=yes > $logfile
rev=`grep "revision	" $logfile | tail -1 | cut -f2 -d"	" | cut -f1 -d" "` 
$INFO "initial checkin is r$rev"

# now goto other wc and update
pushd $WC2 > /dev/null
$BINq up

$BINdflt st > $logfile

$COMPARE -x change/fifo- $WC/ $WC2/
popd > /dev/null

rm -r typechange/*
pushd typechange > /dev/null

 for i in file device symlink dir missing fifo
 do
	 echo file $RANDOM > $i-file
	 $ONLY_ROOT cp -a /dev/zero $i-device
	 ln -s $i-file $i-symlink
	 mkdir $i-dir
	 echo sub $RANDOM > $i-dir/sub-entry
	 mkdir $i-dir/sub
	 echo $RANDOM > $i-dir/sub/sub-entry
	 mkfifo $i-fifo
 done
popd > /dev/null

$BINq ci -m "changed types" -o delay=yes > $logfile
if [[ `$BINdflt st -C -C | wc -l` -ne 0 ]]
then
	$BINdflt st -C -C
	$ERROR "Entries left out of commit"
fi
$INFO "typechange done, running update"

$BINdflt up $WC2 > $logfile
$INFO "update done"

$COMPARE -x "change/.*-fifo" $WC/ $WC2/
$SUCCESS "all types changed to other types."

export FSVS_WARNING="mixed-rev-wc=ignore"

$BINdflt diff -v -v -r$rev -R > $logfile

# Now we change WC1 by using revert, and WC2 via update.
$INFO "Using r$rev as compare point"
$BINq up -r$rev $WC2 > $logfile
$BINq revert -r$rev -R -R . > $logfile
$SUCCESS "Revert works across type-changes too."

# WC1 still has FIFOs left
$COMPARE -x "change/.*-fifo" $WC/ $WC2/
$SUCCESS "Revert across type-changes ok"


for wc in "$WC1" "$WC1 -rHEAD" "$WC2 -rHEAD"
do
	$INFO "Diff on $wc"

	LANG=C $BINdflt -v -v diff -rHEAD -R > $logfile
	# The specific number depends on whether devices are done etc.
	# But at least we know that FSVS doesn't crash.
	if [[ `wc -l < $logfile` -lt 25 ]]
	then
		$ERROR "Diff over type-changes wrong?"
	fi

	# A single thing is checked, though.
	if perl -e 'undef $/; $srch=<STDIN>; $_=<>; exit !/$srch/;' $logfile <<'EOF'
--- typechange/symlink-symlink\s+Rev. \d+ .*
\+\+\+ typechange/symlink-symlink\s+Local version .*
@@ -1 \+1 @@
-link symlink-file(
. No newline at end of file)?
\+link file-symlink(
. No newline at end of file)?
EOF
	then
		$SUCCESS "Diff with type-changes ok"
	else
		cat $logfile
		$ERROR "Didn't find expected chunk in diff"
	fi
done


cd $WC2
$BINdflt diff -rHEAD > $logfile
$BINq up
$BINdflt diff -r$rev > $logfile