File: 032_commit-pipe

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

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

function cmpdiff
{
  [[ `cat $logfile` == *"--- $filename"*"$1"*"+++ $filename"*"$2"*"@@ -1 +1 @@"*"-$text"*"+$text$text" ]]
}


logfile=$LOGDIR/032.commit-pipe
logfile2=$logfile.2
filename=abcdefg.ijk
text=abcde.123
encoder="openssl enc -e -a"
decoder="openssl enc -d -a"

export encoder


# try with a few bytes first
echo $text > $filename
$BINq ps fsvs:commit-pipe "$encoder" $filename
$BINq ps fsvs:update-pipe "$decoder" $filename
$BINdflt ci -m1 > $logfile
rev=`grep "revision	" $logfile | tail -1 | cut -f2 -d"	" | cut -f1 -d" "`
rev_base64=$rev
base64=`$encoder < $filename`

repos_val=`svn cat $REPURL/$filename -r $rev_base64`
echo "Expect $base64, found $repos_val"

if [[ $repos_val == $base64 ]]
then
	$SUCCESS "Commit-pipe works"
else
	$ERROR "Encoded commit failed!"
fi


# Try update
$WC2_UP_ST_COMPARE
# Make sure both arrived there
if [[ X`$BINdflt pl -v $WC2/$filename | sort` == X"fsvs:commit-pipe=$encoder"*"fsvs:update-pipe=$decoder" ]]
then
  $SUCCESS "En- and decoder arrived in $WC2."
else
  $ERROR "En- or decoder didn't arrive in $WC2."
fi

# Try diff
echo $text$text > $filename
$BINdflt diff $filename > $logfile
if cmpdiff "Rev. $rev_base64" "Local version"
then
	$SUCCESS "Diff works."
else
	$ERROR "Error while diffing!"
fi

# use a different encoder
$BINq ps fsvs:commit-pipe "gzip" $filename
$BINq ps fsvs:update-pipe "gzip -d" $filename
# compare
$BINdflt diff $filename > $logfile
if cmpdiff "Rev. $rev_base64" "Local version"
then
	$SUCCESS "Diff after changing the decoder works."
else
	$ERROR "Error while diffing after setting another decoder!"
fi

# commit other encoder, and do repos-repos diff
$BINdflt ci -m2 > $logfile
rev=`grep "revision	" $logfile | tail -1 | cut -f2 -d"	" | cut -f1 -d" "`
rev_gzip=$rev
# diff -rx:y currently prints the full path - TODO

# If we'd just pipe to perl we wouldn't stop on error.
$BINdflt diff -r $rev_base64:$rev_gzip $filename > $logfile2
perl -pe 's('"$WC"'/*)()g' < $logfile2 > $logfile
if cmpdiff "Rev. $rev_base64" "Rev. $rev_gzip"
then
	$SUCCESS "Repos-repos-diff works."
else
	$ERROR "Error while doing repos-repos diff!"
fi


# The data should still be the same - we just committed, after all.
if [[ `$BINdflt st -C -C $filename | wc -l` != 0 ]]
then
	$BINdflt info $filename
	md5sum $filename
  $ERROR "File seen as changed?"
fi
# Change data, using a temporary file to store the date,
# and see if it's found as changed.
tmp=x$filename
cp -a $filename $tmp
perl -e 'open(F, "+< " . shift) || die $!; print F $$;' $filename
touch -r $tmp $filename
# Should be seen when using checksums, and not without.
# With a single -C it would be checksummed if it's likely to be changed - 
# which it is, because the ctime changed.
if [[ `$BINdflt st $filename -o change_check=none     | wc -l` != 0 ||
      `$BINdflt st $filename -o change_check=allfiles | wc -l` == 0 ]]
then
	$BINdflt st $filename -o change_check=none
	$BINdflt st $filename -o change_check=allfiles
	$ERROR "File status wrong?"
fi


# now try with more data - to see if blocking works
cd $WC
seq -f%9.0f 1000000 1100000 > $filename
$BINdflt ci -m2
$WC2_UP_ST_COMPARE


# Try export
cd ${WCBASE}3


cd $WC
$INFO "Try with no data"
> $filename
$BINdflt ci -m4
$WC2_UP_ST_COMPARE


# Check for error checking
cd $WC
echo $text$text > $filename
$BINq ps fsvs:commit-pipe false $filename
if $BINq ci -m2 2> /dev/null
then
	$ERROR "Error return of commit pipe not seen?"
else
	$SUCCESS "Commit pipe gets checked for return level"
fi

# Delayed error
$BINq ps fsvs:commit-pipe "cat && false" $filename
if $BINq ci -m2 2> /dev/null
then
	$ERROR "Delayed error return of commit pipe not seen?"
else
	$SUCCESS "Commit pipe gets checked for return level, even for delayed"
fi


# vim: formatoptions=q