s3:dbwrap fix return value of db_tdb_parse
[Samba/bb.git] / lib / ldb / tests / test-generic.sh
blob7c3db4a4119a2bd5b35c23271409879e326bd065
1 #!/bin/sh
3 if [ -z "$LDB_SPECIALS" ]; then
4 LDB_SPECIALS=1
5 export LDB_SPECIALS
6 fi
8 echo "LDB_URL: $LDB_URL"
10 echo "Adding base elements"
11 $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test.ldif || exit 1
13 echo "Adding again - should fail"
14 $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test.ldif 2> /dev/null && {
15 echo "Should have failed to add again - gave $?"
16 exit 1
19 echo "Modifying elements"
20 $VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/test-modify.ldif || exit 1
22 echo "Showing modified record"
23 $VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1
25 echo "Rename entry with ldbmodify - modrdn"
26 $VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/test-modify-modrdn.ldif || exit 1
28 echo "Rename entry with ldbrename"
29 OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
30 NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
31 $VALGRIND ldbrename$EXEEXT "$OLDDN" "$NEWDN" || exit 1
33 echo "Showing renamed record"
34 $VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1
36 echo "Starting ldbtest"
37 $VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 10 || exit 1
39 if [ $LDB_SPECIALS = 1 ]; then
40 echo "Adding index"
41 $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-index.ldif || exit 1
44 echo "Adding bad attributes - should fail"
45 $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wrong_attributes.ldif && {
46 echo "Should fhave failed - gave $?"
47 exit 1
50 echo "Testing indexed search"
51 $VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1
52 $VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
53 $VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham))' || exit 1
54 $VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham))' || exit 1
55 $VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1
56 $VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1
57 $VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1
58 $VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
60 echo "Testing invalid search expression"
61 $VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(title=foo\blah))' uid && exit 1
63 # note that the "((" is treated as an attribute not an expression
64 # this matches the openldap ldapsearch behaviour of looking for a '='
65 # to see if the first argument is an expression or not
66 $VALGRIND ldbsearch$EXEEXT '((' uid || exit 1
67 $VALGRIND ldbsearch$EXEEXT '(objectclass=)' uid || exit 1
68 $VALGRIND ldbsearch$EXEEXT -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
70 echo "Test wildcard match"
71 $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wildcard.ldif || exit 1
72 $VALGRIND ldbsearch$EXEEXT '(cn=test*multi)' || exit 1
73 $VALGRIND ldbsearch$EXEEXT '(cn=*test*multi*)' || exit 1
74 $VALGRIND ldbsearch$EXEEXT '(cn=*test_multi)' || exit 1
75 $VALGRIND ldbsearch$EXEEXT '(cn=test_multi*)' || exit 1
76 $VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi)' || exit 1
77 $VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi*multi_*)' || exit 1
79 echo "Starting ldbtest indexed"
80 $VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 500 || exit 1
82 echo "Testing one level search"
83 count=`$VALGRIND ldbsearch$EXEEXT -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l`
84 if [ $count != 3 ]; then
85 echo returned $count records - expected 3
86 exit 1
89 echo "Testing binary file attribute value"
90 $VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/photo.ldif || exit 1
91 count=`$VALGRIND ldbsearch$EXEEXT '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l`
92 if [ $count != 1 ]; then
93 echo returned $count records - expected 1
94 exit 1
97 echo "*TODO* Testing UTF8 upper lower case searches !!"
99 echo "Testing compare"
100 count=`$VALGRIND ldbsearch$EXEEXT '(cn>=t)' cn | grep '^dn' | wc -l`
101 if [ $count != 2 ]; then
102 echo returned $count records - expected 2
103 echo "this fails on openLdap ..."
106 count=`$VALGRIND ldbsearch$EXEEXT '(cn<=t)' cn | grep '^dn' | wc -l`
107 if [ $count != 13 ]; then
108 echo returned $count records - expected 13
109 echo "this fails on openLdap ..."
112 checkcount() {
113 count=$1
114 scope=$2
115 basedn=$3
116 expression="$4"
117 n=`$VALGRIND ldbsearch$EXEEXT -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l`
118 if [ $n != $count ]; then
119 echo "Got $n but expected $count for $expression"
120 bin/ldbsearch "$expression"
121 exit 1
123 echo "OK: $count $expression"
126 checkcount 0 'base' '' '(uid=uham)'
127 checkcount 0 'one' '' '(uid=uham)'
129 checkcount 1 'base' 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
130 checkcount 1 'one' 'ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
131 checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb test)'