File: 018_various

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

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

logfile=$LOGDIR/018.various


# Test EPIPE handling.
# I could reproduce it with "strace -o /dev/null $BINdflt log | true", (or 
# "| head -1"), but only in 1 of 10 cases without the strace.
strace_bin=`which strace || true`
strace_cmd=${strace_bin:+$strace_bin -o /dev/null}
for command in log st
do
	ret=$(
		set -o pipefail
		$strace_cmd $BINdflt $command 2>$logfile | true
		echo $?
		set +o pipefail )
	if [[ $ret -eq 0 ]]
	then
		# No errors on STDOUT allowed.
		if [[ `wc -l < $logfile` -eq 0 ]]
		then
			$SUCCESS "EPIPE on $command handled correctly"
		else
			$ERROR "wrong number of output lines on EPIPE $command test"
		fi
	else
		$ERROR "Error code on EPIPE $command"
	fi
done


# Test whether / at the end of an URL are removed
$BINq init $REPURL/////
if $BINdflt st > $logfile
then
	$SUCCESS "slashes at end of URLs are ignored."
else
	$ERROR "slashes make fsvs fail??"
fi

if [[ `$BINq help | wc -l` -gt 10 &&
`$BINq -h | wc -l` -gt 10 &&
`$BINq -V` == "FSVS"*"version "* ]]
then
	$SUCCESS "version and help are given"
else
	$ERROR "version or help are not printed?"
fi

if [[ "$opt_DEBUG" == "1" ]]
then
	if FSVS_DEBUGLEVEL=1 $BINdflt -v -D main | grep LC_ALL > $logfile &&
		test `$BINdflt -v -d -D main | egrep "^[^ ]+ +main" | wc -l` -ge 3
	then
		$SUCCESS "Debug messages seem to work"
	else
		$ERROR "debug doesn't work?"
	fi
fi


if [[ `$BINdflt s 2>&1 ` == *"Action \"s\" is ambiguous."* &&
	`$BINdflt invalid-action-which-will-never-exist 2>&1` == \
		*"Action "*" not found."* ]]
then
	$SUCCESS "actions are checked"
else
	$ERROR "actions are not verified?"
fi


if $BINdflt st /$RANDOM/$RANDOM/$RANDOM/$RANDOM/$RANDOM > $logfile 2>&1
then
	$ERROR "non-existing directories don't fail?"
else
	$SUCCESS "error for non-existing directories"
fi


# Look whether there's a human-readable message (1 line) for non-existing 
# CONF or WAA paths. 
# Has to include the missing path, so that the generic "no working copy" 
# error isn't allowed.
function Check_Path
{
	var=FSVS_$1
	if $BINdflt status /bin > $logfile 2>&1
	then
		cat $logfile
		$ERROR "Invalid $var doesn't stop?"
	else
		if [[ `wc -l < $logfile` -eq 1 &&
			`grep -c "${!var}" < $logfile` -eq 1 ]]
		then
			$SUCCESS "$var checked"
		else
			cat $logfile
			$ERROR "Wrong message on invalid $var."
		fi
	fi
}
FSVS_CONF=$WC/not-here Check_Path CONF
FSVS_WAA=$WC/not-here Check_Path WAA

# Define an empty configuration directory, and try to do a status (without 
# a wc file).
if FSVS_CONF=$WC $BINdflt status -N -N /sbin /bin > $logfile 2>&1
then
	$ERROR "Didn't expect status output"
else
	$SUCCESS "No status output for non-committed WCs"
fi

# make a wc, and retry
( 
	export FSVS_CONF=$WC FSVS_WAA=$WC 
	cd / 
	echo file:/// | $BINq urls load 
	echo './*' | $BINq ignore load 
)
if FSVS_CONF=$WC FSVS_WAA=$WC $BINdflt status -N -N /sbin /bin > $logfile 2>&1
then
	if ! grep '^N\.\.\. \+dir \+/s\?bin$' $logfile > $logfile.2
	then
	  $ERROR "Wrong status output"
	fi

	if [[ `wc -l < $logfile` -eq 2 &&
				`wc -l < $logfile.2` -eq 2 ]]
	then
		$SUCCESS "Status output for two root entries as expected."
	else
		$ERROR "Wrong status output"
	fi
else
	$ERROR "No status output for non-committed WCs?"
fi


# Test whether an invalid/not existing $FSVS_WAA allows "help" to work
if FSVS_WAA=/tmp/not-existing-$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM $BINdflt help status > $logfile 2>&1
then
	$SUCCESS 'help needs no $FSVS_WAA'
else
	$ERROR 'help tries to access $FSVS_WAA'
fi

if $BINdflt -V | grep version | grep GPL | grep Marek > /dev/null
then
  $SUCCESS "Version is printed"
else
  $ERROR "Version printing error"
fi

if $BINdflt -v -V | grep "compiled .*, with options" > /dev/null
then
  $SUCCESS "Compile options are printed"
else
  $ERROR "Verbose version printing error"
fi

if $BINdflt help | grep "Known commands:" > /dev/null
then
  $SUCCESS "Help gets printed"
else
  $ERROR "No help output?"
fi

if $BINdflt help help | grep 'Help for command "help".' > /dev/null
then
  $SUCCESS "Help for help gets printed"
else
  $ERROR "No help help output?"
fi

if $BINdflt help -h | grep 'Help for command "help".' > /dev/null
then
  $SUCCESS "Help -h gets printed"
else
  $ERROR "No help -h output?"
fi

if $BINdflt help -? | grep 'Help for command "help".' > /dev/null
then
  $SUCCESS "Help -? gets printed"
else
  $ERROR "No help -? output?"
fi



# If we have an invalid charset, ANSI_X3.4-1968 is returned (=ASCII).
# So there should never be an error, unless nl_langinfo fails.
#if ! LC_ALL=invalid LC_CTYPE=invalid $BINdflt -Wcharset-invalid=stop st 2> $logfile
#then
#  $SUCCESS "invalid locales can stop fsvs"
#else
#  $ERROR "invalid locales don't give an error?" 
#fi
#