smbd: Remove "st" from struct open_symlink_err
[Samba.git] / lib / ldb / tests / test-tdb-features.sh
blob1007fa048e7027e0f01d28b388cdd138c27efb9b
1 #!/bin/sh
3 echo "Running tdb feature tests"
5 mv $LDB_URL $LDB_URL.2
7 cat <<EOF | $VALGRIND ldbadd || exit 1
8 dn: @MODULES
9 @LIST: rdn_name
10 EOF
12 checkcount()
14 count=$1
15 expression="$2"
16 n=$($VALGRIND ldbsearch "$expression" | grep '^dn' | wc -l)
17 if [ $n != $count ]; then
18 echo "Got $n but expected $count for $expression"
19 $VALGRIND ldbsearch "$expression"
20 exit 1
22 echo "OK: $count $expression"
25 echo "Testing case sensitive search"
26 cat <<EOF | $VALGRIND ldbadd || exit 1
27 dn: cn=t1,cn=TEST
28 objectClass: testclass
29 test: foo
30 EOF
31 checkcount 1 '(test=foo)'
32 checkcount 0 '(test=FOO)'
33 checkcount 0 '(test=FO*)'
34 checkcount 1 '(cn=t1)'
36 echo "Making case insensitive"
37 cat <<EOF | $VALGRIND ldbmodify || exit 1
38 dn: @ATTRIBUTES
39 changetype: add
40 add: test
41 test: CASE_INSENSITIVE
42 EOF
44 echo $ldif | $VALGRIND ldbmodify || exit 1
45 checkcount 1 '(test=foo)'
46 checkcount 1 '(test=FOO)'
47 checkcount 1 '(test=fo*)'
49 echo "adding i"
50 cat <<EOF | $VALGRIND ldbmodify || exit 1
51 dn: cn=t1,cn=TEST
52 changetype: modify
53 add: i
54 i: 0x100
55 EOF
56 checkcount 1 '(i=0x100)'
57 checkcount 0 '(i=256)'
59 echo "marking i as INTEGER"
60 cat <<EOF | $VALGRIND ldbmodify || exit 1
61 dn: @ATTRIBUTES
62 changetype: modify
63 add: i
64 i: INTEGER
65 EOF
66 checkcount 1 '(i=0x100)'
67 checkcount 1 '(i=256)'
69 echo "adding j"
70 cat <<EOF | $VALGRIND ldbmodify || exit 1
71 dn: cn=t1,cn=TEST
72 changetype: modify
73 add: j
74 j: 0x100
75 EOF
76 checkcount 1 '(j=0x100)'
77 checkcount 0 '(j=256)'
79 echo "Adding wildcard attribute"
80 cat <<EOF | $VALGRIND ldbmodify || exit 1
81 dn: @ATTRIBUTES
82 changetype: modify
83 add: *
84 *: INTEGER
85 EOF
86 checkcount 1 '(j=0x100)'
87 checkcount 1 '(j=256)'
89 cat <<EOF | $VALGRIND ldbadd || exit 1
90 dn: num=1
91 EOF
93 echo "Testing search for attribute after change to use wildcard"
94 checkcount 1 '(num=1)'
96 echo "Testing class search"
97 checkcount 0 '(objectClass=otherclass)'
98 checkcount 1 '(objectClass=testclass)'
100 echo "Adding index"
101 cat <<EOF | $VALGRIND ldbadd || exit 1
102 dn: @INDEXLIST
103 @IDXATTR: i
104 @IDXATTR: test
106 checkcount 1 '(i=0x100)'
107 checkcount 1 '(i=256)'
108 checkcount 0 '(i=-256)'
109 checkcount 1 '(test=foo)'
110 checkcount 1 '(test=FOO)'
111 checkcount 1 '(test=*f*o)'
113 echo "making test case sensitive"
114 cat <<EOF | $VALGRIND ldbmodify || exit 1
115 dn: @ATTRIBUTES
116 changetype: modify
117 replace: test
118 test: NONE
120 checkcount 1 '(test=foo)'
121 checkcount 0 '(test=FOO)'
122 checkcount 1 '(test=f*o*)'
124 checkone()
126 count=$1
127 base="$2"
128 expression="$3"
129 n=$($VALGRIND ldbsearch --scope=one -b "$base" "$expression" | grep '^dn' | wc -l)
130 if [ $n != $count ]; then
131 echo "Got $n but expected $count for $expression"
132 $VALGRIND ldbsearch --scope=one -b "$base" "$expression"
133 exit 1
135 echo "OK: $count $expression"
138 echo "Removing wildcard attribute"
139 cat <<EOF | $VALGRIND ldbmodify || exit 1
140 dn: @ATTRIBUTES
141 changetype: modify
142 delete: *
143 *: INTEGER
146 echo "Adding one level indexes"
147 cat <<EOF | $VALGRIND ldbmodify || exit 1
148 dn: @INDEXLIST
149 changetype: modify
150 add: @IDXONE
151 @IDXONE: 1
154 echo "Testing one level indexed search"
155 cat <<EOF | $VALGRIND ldbadd || exit 1
156 dn: cn=one,cn=t1,cn=TEST
157 objectClass: oneclass
158 cn: one
159 test: one
161 checkone 1 "cn=t1,cn=TEST" '(test=one)'
162 cat <<EOF | $VALGRIND ldbadd || exit 1
163 dn: cn=two,cn=t1,cn=TEST
164 objectClass: oneclass
165 cn: two
166 test: one
168 dn: cn=three,cn=t1,cn=TEST
169 objectClass: oneclass
170 cn: three
171 test: one
173 dn: cn=four,cn=three,cn=t1,cn=TEST
174 objectClass: oneclass
175 cn: four
176 test: one
178 checkone 3 "cn=t1,cn=TEST" '(test=one)'
179 checkone 1 "cn=t1,cn=TEST" '(cn=two)'