messaging: Avoid passing lp_ctx to tdb_wrap_open in messaging_tdb_parent_init
[Samba.git] / lib / ldb / tests / test-tdb-features.sh
blob59e61ee5d2e380c45e7d84d18c2faf710c4f5644
1 #!/bin/sh
3 echo "Running tdb feature tests"
5 mv $LDB_URL $LDB_URL.2
7 checkcount() {
8 count=$1
9 expression="$2"
10 n=`$VALGRIND ldbsearch "$expression" | grep '^dn' | wc -l`
11 if [ $n != $count ]; then
12 echo "Got $n but expected $count for $expression"
13 $VALGRIND ldbsearch "$expression"
14 exit 1
16 echo "OK: $count $expression"
19 echo "Testing case sensitive search"
20 cat <<EOF | $VALGRIND ldbadd || exit 1
21 dn: cn=t1,cn=TEST
22 objectClass: testclass
23 test: foo
24 EOF
25 checkcount 1 '(test=foo)'
26 checkcount 0 '(test=FOO)'
27 checkcount 0 '(test=FO*)'
29 echo "Making case insensitive"
30 cat <<EOF | $VALGRIND ldbmodify || exit 1
31 dn: @ATTRIBUTES
32 changetype: add
33 add: test
34 test: CASE_INSENSITIVE
35 EOF
37 echo $ldif | $VALGRIND ldbmodify || exit 1
38 checkcount 1 '(test=foo)'
39 checkcount 1 '(test=FOO)'
40 checkcount 1 '(test=fo*)'
42 echo "adding i"
43 cat <<EOF | $VALGRIND ldbmodify || exit 1
44 dn: cn=t1,cn=TEST
45 changetype: modify
46 add: i
47 i: 0x100
48 EOF
49 checkcount 1 '(i=0x100)'
50 checkcount 0 '(i=256)'
52 echo "marking i as INTEGER"
53 cat <<EOF | $VALGRIND ldbmodify || exit 1
54 dn: @ATTRIBUTES
55 changetype: modify
56 add: i
57 i: INTEGER
58 EOF
59 checkcount 1 '(i=0x100)'
60 checkcount 1 '(i=256)'
62 echo "adding j"
63 cat <<EOF | $VALGRIND ldbmodify || exit 1
64 dn: cn=t1,cn=TEST
65 changetype: modify
66 add: j
67 j: 0x100
68 EOF
69 checkcount 1 '(j=0x100)'
70 checkcount 0 '(j=256)'
72 echo "Adding wildcard attribute"
73 cat <<EOF | $VALGRIND ldbmodify || exit 1
74 dn: @ATTRIBUTES
75 changetype: modify
76 add: *
77 *: INTEGER
78 EOF
79 checkcount 1 '(j=0x100)'
80 checkcount 1 '(j=256)'
82 echo "Testing class search"
83 checkcount 0 '(objectClass=otherclass)'
84 checkcount 1 '(objectClass=testclass)'
86 echo "Adding index"
87 cat <<EOF | $VALGRIND ldbadd || exit 1
88 dn: @INDEXLIST
89 @IDXATTR: i
90 @IDXATTR: test
91 EOF
92 checkcount 1 '(i=0x100)'
93 checkcount 1 '(i=256)'
94 checkcount 0 '(i=-256)'
95 checkcount 1 '(test=foo)'
96 checkcount 1 '(test=FOO)'
97 checkcount 1 '(test=*f*o)'
99 echo "making test case sensitive"
100 cat <<EOF | $VALGRIND ldbmodify || exit 1
101 dn: @ATTRIBUTES
102 changetype: modify
103 replace: test
104 test: NONE
106 checkcount 1 '(test=foo)'
107 checkcount 0 '(test=FOO)'
108 checkcount 1 '(test=f*o*)'
110 checkone() {
111 count=$1
112 base="$2"
113 expression="$3"
114 n=`$VALGRIND ldbsearch -s one -b "$base" "$expression" | grep '^dn' | wc -l`
115 if [ $n != $count ]; then
116 echo "Got $n but expected $count for $expression"
117 $VALGRIND ldbsearch -s one -b "$base" "$expression"
118 exit 1
120 echo "OK: $count $expression"
123 echo "Removing wildcard attribute"
124 cat <<EOF | $VALGRIND ldbmodify || exit 1
125 dn: @ATTRIBUTES
126 changetype: modify
127 delete: *
128 *: INTEGER
131 echo "Adding one level indexes"
132 cat <<EOF | $VALGRIND ldbmodify || exit 1
133 dn: @INDEXLIST
134 changetype: modify
135 add: @IDXONE
136 @IDXONE: 1
139 echo "Testing one level indexed search"
140 cat <<EOF | $VALGRIND ldbadd || exit 1
141 dn: cn=one,cn=t1,cn=TEST
142 objectClass: oneclass
143 cn: one
144 test: one
146 checkone 1 "cn=t1,cn=TEST" '(test=one)'
147 cat <<EOF | $VALGRIND ldbadd || exit 1
148 dn: cn=two,cn=t1,cn=TEST
149 objectClass: oneclass
150 cn: two
151 test: one
153 dn: cn=three,cn=t1,cn=TEST
154 objectClass: oneclass
155 cn: three
156 test: one
158 dn: cn=four,cn=three,cn=t1,cn=TEST
159 objectClass: oneclass
160 cn: four
161 test: one
163 checkone 3 "cn=t1,cn=TEST" '(test=one)'
164 checkone 1 "cn=t1,cn=TEST" '(cn=two)'