r11567: Ldb API change patch.
[jelmer/samba4-debian.git] / source / lib / ldb / tests / test-tdb-features.sh
1 #!/bin/sh
2
3 echo "Running tdb feature tests"
4
5 mv $LDB_URL $LDB_URL.2
6
7 checkcount() {
8     count=$1
9     expression="$2"
10     n=`bin/ldbsearch "$expression" | grep '^dn' | wc -l`
11     if [ $n != $count ]; then
12         echo "Got $n but expected $count for $expression"
13         $VALGRIND bin/ldbsearch "$expression"
14         exit 1
15     fi
16     echo "OK: $count $expression"
17 }
18
19 echo "Testing case sensitive search"
20 cat <<EOF | $VALGRIND bin/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*)'
28
29 echo "Making case insensitive"
30 cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
31 dn: @ATTRIBUTES
32 changetype: add
33 add: test
34 test: CASE_INSENSITIVE
35 EOF
36
37 echo $ldif | $VALGRIND bin/ldbmodify || exit 1
38 checkcount 1 '(test=foo)'
39 checkcount 1 '(test=FOO)'
40 checkcount 1 '(test=fo*)'
41
42 echo "adding i"
43 cat <<EOF | $VALGRIND bin/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)'
51
52 echo "marking i as INTEGER"
53 cat <<EOF | $VALGRIND bin/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)'
61
62 echo "adding j"
63 cat <<EOF | $VALGRIND bin/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)'
71
72 echo "Adding wildcard attribute"
73 cat <<EOF | $VALGRIND bin/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)'
81
82 echo "Testing class search"
83 checkcount 0 '(objectClass=otherclass)'
84 checkcount 1 '(objectClass=testclass)'
85
86 echo "Adding subclass"
87 cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
88 dn: @SUBCLASSES
89 changetype: add
90 add: otherclass
91 otherclass: testclass
92 EOF
93 checkcount 1 '(objectClass=otherclass)'
94 checkcount 1 '(objectClass=testclass)'
95
96 echo "Adding index"
97 cat <<EOF | $VALGRIND bin/ldbadd || exit 1
98 dn: @INDEXLIST
99 @IDXATTR: i
100 @IDXATTR: test
101 EOF
102 checkcount 1 '(i=0x100)'
103 checkcount 1 '(i=256)'
104 checkcount 0 '(i=-256)'
105 checkcount 1 '(test=foo)'
106 checkcount 1 '(test=FOO)'
107 checkcount 1 '(test=*f*o)'
108
109 echo "making test case sensitive"
110 cat <<EOF | $VALGRIND bin/ldbmodify || exit 1
111 dn: @ATTRIBUTES
112 changetype: modify
113 replace: test
114 test: NONE
115 EOF
116 checkcount 1 '(test=foo)'
117 checkcount 0 '(test=FOO)'
118 checkcount 1 '(test=f*o*)'
119