File: 065_test_group-test

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 (96 lines) | stat: -rwxr-xr-x 1,575 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
#!/bin/bash

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


logfile=$LOGDIR/065.group-test

grp_dir=`$PATH2SPOOL $WC ^`/groups
mkdir $grp_dir

for a in 1 2 3 Ab CA void
do
	echo $a > $a
	$BINq groups "group:$a,./**$a*"
	echo "take" > $grp_dir/$a
done

$BINq delay
# Make sure that the new entries are seen.
touch .

function Check
{
	pattern="$1"
	count="$2"

	echo "Testing '$pattern'."
	$BINdflt group test "$pattern" > $logfile
	if [[ `wc -l < $logfile` -ne "$count" ]]
	then
		cat $logfile
		$ERROR "Wrong number of output lines - expected $count."
	fi
}

Check './*A*' 2
Check './?' 3

echo "Non-existing groups should be ignored"
Check 'group:doesntexist,./*d' 1


# Now check full listings
function CheckFull
{
	echo "Testing '$1', expect $2."
	if [[ `grep "$1" $logfile | wc -l` -ne $2 ]]
	then
		$ERROR "Wrong number of lines."
	fi
}

$INFO "Testing group lists."
mkdir X
touch X/1 X/3
$BINdflt group test > $logfile
CheckFull . 9
CheckFull ^1 2
CheckFull ^3 2
CheckFull ^2 1
CheckFull ^Ab 1
CheckFull ^X 0
CheckFull X 3

$INFO "With -N"
$BINdflt group test -N > $logfile
CheckFull X 1
CheckFull . 7

$INFO "In subdir."
cd X
$BINdflt group test > $logfile
CheckFull X 3
CheckFull ^1 1
# The directory itself isn't printed.
CheckFull . 3

cd $WC
$INFO "Verbose output"
$BINdflt group test -v > $logfile
CheckFull . 9
CheckFull group: 8
CheckFull group:., 5
CheckFull '^Ab[[:space:]]group:Ab,./..Ab.[[:space:]]./Ab$' 1
CheckFull i 1

$BINq ignore './**'
$BINdflt group test -v > $logfile
CheckFull group: 9
CheckFull i 2

$SUCCESS "group/ignore test ok."