File: 031_info

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

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


filename=file-$RANDOM-$RANDOM
logfile=$LOGDIR/031.logfile

touch $filename
chmod 742 $filename
# Be careful - don't do a CR/LF or something like that.
printf "TEST 1" > $filename
touch -t 200602231730.13 $filename
md5=`md5sum - < $filename`

echo Checkin ...
$BINq ci -m 1 -o delay=yes > $logfile 
rev=`grep "revision	" $logfile | tail -1 | cut -f2 -d"	" | cut -f1 -d" "` 


function Check
{
  tag=$1
	data="$2"

	# We need a word boundary; "grep -E" is not POSIX. So use perl.
	# I tried to use \Q in the patterns (svn+ssh has a + in it!), but that
	# doesn't work if it gets expanded from a variable into a pattern.
	# So we have to use the conditional.
	# There must be exactly one line.
	if perl -e '$tag=shift; $pat=shift; $pat=quotemeta($1) if $pat =~ /^=(.*)/; @fnd=grep(m#^\s+$tag:\s+$pat#, <STDIN>); exit 0+(@fnd != 1);' "$tag" "$data" < $logfile
	then
	  # Used to be $SUCCESS, but that's a lot of green
#    echo "found $tag: $data"
		true
  else
    echo "$tag wanted as $data, but found:"
		echo "'"`grep $tag $logfile || true `"'"
    $ERROR "Wrong data returned!"
  fi
}


function CheckAttr
{
	Check Type file
	Check Status "$1"
	Check Flags 0x0
	Check URL "=$REPURL/$filename"
	Check Mode 0100742
	Check UID/GID "$UID .*/.*"
	Check MTime "Thu Feb 23 17:30:13 2006"
	Check Revision 4
	Check Size 6
	Check Repos-MD5 $md5 # f676245d2b1ee5589cd0f19401fda420
}

$BINdflt info $filename > $logfile
CheckAttr "0x0 .unmodified."
$SUCCESS "info prints the expected data for existing files."

# Check that *really* the stored data is printed,
# and not just the current values!
echo "ASDASAAGDGASGa" > $filename
$BINdflt info $filename > $logfile
CheckAttr "0x24 .changed, mtime."
$SUCCESS "info prints the expected data for modified files."

rm $filename
$BINdflt info $filename > $logfile
CheckAttr "0x2 .removed."
$SUCCESS "info prints the expected data for removed files."


if $BINdflt info Does-not-exist-in-this-WC > $logfile 2>&1
then
	$ERROR "info does not stop for non-existing entries!"
else
	$SUCCESS "info stops for non-existing entries!"
fi

copydir=ta
copydirs=a/av/ad
copyfn=a4g
copyfile=$copydir/$copydirs/$copyfn
mkdir -p $copydir/$copydirs
touch $copyfile
$BINdflt cp $filename $copyfile
$BINdflt info -o verbose=copyfrom $copyfile > $logfile
Check "Copyfrom" "=rev. $rev of $REPURL/$filename"
$SUCCESS "info prints the expected data for copied files 1."


$BINq ci -m 1 > $logfile
rev=`grep "revision	" $logfile | tail -1 | cut -f2 -d"	" | cut -f1 -d" "` 
dir2=qwerhg
cp -a $copydir $dir2
$BINdflt cp $copydir $dir2
$BINdflt info -o verbose=copyfrom $dir2/$copydirs/$copyfn > $logfile
Check "Copyfrom" "=rev. $rev of $REPURL/$copydir/$copydirs/$copyfn"
$SUCCESS "info prints the expected data for copied files 2."


# set ts=2 sw=2