-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·126 lines (103 loc) · 2.78 KB
/
test.sh
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
#!/bin/sh
mkfile()
{
mkdir -p "`dirname \"$1\"`"
dd if=/dev/zero of="$1" bs=1 count=$2 2> /dev/null
}
export DUC_DATABASE=test.db
rm -rf test test.db
mkdir test
# Regular files
mkfile test/tree/one 100
mkfile test/tree/two 100
mkfile test/tree/three 100
mkfile test/tree/four 100
mkfile test/tree/sub1/alpha 100
mkfile test/tree/sub1/bravo 1000
mkfile test/tree/sub1/charlie 1000
mkfile test/tree/sub1/delta 10000
mkfile test/tree/sub2/echo 100
mkfile test/tree/sub2/foxtrot 1000
mkfile test/tree/sub2/golf 1000
mkfile test/tree/sub2/hotel 10000
mkfile test/tree/sub3/india 5000
mkfile test/tree/sub3/juliet 4000
mkfile test/tree/sub4/kilo 1000
mkfile test/tree/sub4/lima 2000
mkfile test/tree/sub4/mike 3000
mkfile test/tree/sub4/november 5000
# Hard link
mkdir test/hard-link
mkfile test/hard-link/one 10000
ln test/hard-link/one test/hard-link/two
ln test/hard-link/one test/hard-link/three
# Sparse file
mkdir test/sparse
dd if=/dev/zero of=test/sparse/first bs=1 count=1 seek=32K 2> /dev/null
# Potentional problematic characters
mkfile "test/strange/cgi-space-%20-dir/file" 100
mkfile "test/strange/newline--dir/file" 100
mkfile "test/strange/tab- -dir/file" 100
mkfile "test/strange/space- -dir/file" 100
mkfile "test/strange/carriage-return-
-dir/file" 100
mkfile "test/strange/question-mark-?-dir/file" 100
mkfile "test/strange/control-a--dir/file" 100
mkfile "test/strange/escape--dir/file" 100
mkfile "test/strange/less-then-<-dir/file" 100
mkfile "test/strange/more-then->-dir/file" 100
mkfile "test/strange/ampersand-&-dir/file" 100
mkfile "test/strange/single-quote-'-dir/file" 100
mkfile "test/strange/double-quote-\"-dir/file" 100
mkfile "test/strange/backslash-\\-dir/file" 100
# UTF-8 characters
mkfile test/utf-8/оживлённым/foo 100
mkfile test/utf-8/有朋自遠方來/foo 100
mkfile test/utf-8/♜♞♝♛♚♝♞♜/foo 100
# Create index
valgrind \
--quiet \
--suppressions=valgrind-suppressions \
--leak-check=full \
--leak-check=full \
--show-leak-kinds=all \
--num-callers=30 \
--error-exitcode=1 \
./duc index --debug --check-hard-links --bytes --verbose test > test.out 2>&1
if [ "$?" != "0" ]; then
echo "valgrind error"
cat test.out
exit 1
fi
cat test.out | grep -q "Indexed 37 files and 27 directories, (199661B apparent, 294912B actual)"
if [ "$?" = "0" ]; then
echo "report ok"
else
echo "report failed"
cat test.out
exit 1
fi
valgrind \
--quiet \
--suppressions=valgrind-suppressions \
--leak-check=full \
--leak-check=full \
--show-leak-kinds=all \
--num-callers=30 \
--error-exitcode=1 \
duc ls -aR test > test.out 2>&1
if [ "$?" != "0" ]; then
echo "valgrind error"
cat test.out
exit 1
fi
md5sum test.out | grep -q decda4c4f77b20a45aee5e90f7587603
if [ "$?" = "0" ]; then
echo "md5sum ok"
else
echo "md5sum failed"
cat test.out
exit 1
fi
# end