File: 058_ignore_modematch

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

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

$BINdflt delay

# General ignore patterns are tested somewhere else.
# Here the mode match is tested.

logfile=$LOGDIR/058.log
ign_file=`$PATH2SPOOL $WC Ign`

if $BINdflt ignore m:0700:0070 > $logfile 2>&1
then
	$ERROR "Wrong match pattern (masks) shouldn't work."
fi
if $BINdflt ignore m-7:7 > $logfile 2>&1
then
	$ERROR "Wrong match pattern (syntax) shouldn't work."
fi
if $BINdflt ignore m:8:7 > $logfile 2>&1
then
	$ERROR "Wrong match pattern (octal) shouldn't work."
fi
if $BINdflt ignore m:a > $logfile 2>&1
then
	$ERROR "Wrong match pattern (non-numeric) shouldn't work."
fi
if $BINdflt ignore m:010000:00 > $logfile 2>&1
then
	$ERROR "Wrong match pattern (numbers) shouldn't work."
fi
if $BINdflt ignore m:-2:03 > $logfile 2>&1
then
	$ERROR "Wrong match pattern (negative numbers) shouldn't work."
fi

$SUCCESS "Invalid specifications rejected."


function T
{
	exp=$1
	shift
	$INFO "testing $@."

	test -e $ign_file && rm $ign_file
	$BINdflt ignore "$@"
	$BINdflt st | grep -v dir > $logfile || true
	if [[ `wc -l < $logfile` -eq $exp ]]
	then
		$SUCCESS "Match mode $@ ok."
	else
		cat $logfile
		$ERROR "Expected $exp lines output for $@."
	fi
}


date > file
chmod 0750 file

T 0 './**'
T 1 'take,./file' './**'
T 0 'mode:0700:0700,./file'
T 1 'mod:0700:0500,./**'
T 0 mo:0050:0050
T 1 m:0050:0000
T 0 mode:0007:0000


# Test with a directory, too.
# Commit everything.
true | $BINq ignore load
$BINq ci -m1

mkdir -m 0700 dir
touch dir/file other
echo 'mode:04:0' | $BINq ignore load
$BINq ci -m1 > $logfile

if [[ `$BINdflt log -v -rHEAD | grep other` == "  other" ]]
then
	$SUCCESS "Mode match on directory."
else
	cat $logfile
	$BINdflt log -v -rHEAD
	$ERROR "Too much taken - directory should be ignored."
fi

#  Now show the entries again.
true | $BINq ignore load
$BINq delay
touch .
if [[ `$BINdflt st | wc -l` -eq 3 ]]
then
	$SUCCESS "Not stored in local list."
else
	$ERROR "Stored in local list? Not seen as new"
fi