r13348: Put a reminder for now.
[samba.git] / source / lib / ldb / tests / test-generic.sh
1 #!/bin/sh
2
3 echo "LDB_URL: $LDB_URL"
4
5 echo "Adding base elements"
6 $VALGRIND ldbadd $LDBDIR/tests/test.ldif || exit 1
7
8 echo "Modifying elements"
9 $VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1
10
11 echo "Showing modified record"
12 $VALGRIND ldbsearch '(uid=uham)'  || exit 1
13
14 echo "Rename entry"
15 OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
16 NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST"
17 $VALGRIND ldbrename "$OLDDN" "$NEWDN"  || exit 1
18
19 echo "Showing renamed record"
20 $VALGRIND ldbsearch '(uid=uham)' || exit 1
21
22 echo "Starting ldbtest"
23 time $VALGRIND ldbtest --num-records 100 --num-searches 10  || exit 1
24
25 echo "Adding index"
26 $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif  || exit 1
27
28 echo "Adding attributes"
29 $VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif  || exit 1
30
31 echo "testing indexed search"
32 $VALGRIND ldbsearch '(uid=uham)'  || exit 1
33 $VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1
34 $VALGRIND ldbsearch '(&(uid=uham)(uid=uham))'  || exit 1
35 $VALGRIND ldbsearch '(|(uid=uham)(uid=uham))'  || exit 1
36 $VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))'  || exit 1
37 $VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))'  || exit 1
38 $VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn  || exit 1
39 $VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
40
41 # note that the "((" is treated as an attribute not an expression
42 # this matches the openldap ldapsearch behaviour of looking for a '='
43 # to see if the first argument is an expression or not
44 $VALGRIND ldbsearch '((' uid || exit 1
45 $VALGRIND ldbsearch '(objectclass=)' uid || exit 1
46 $VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
47
48 echo "Test wildcard match"
49 $VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif  || exit 1
50 $VALGRIND ldbsearch '(cn=test*multi)'  || exit 1
51 $VALGRIND ldbsearch '(cn=*test*multi*)'  || exit 1
52 $VALGRIND ldbsearch '(cn=*test_multi)'  || exit 1
53 $VALGRIND ldbsearch '(cn=test_multi*)'  || exit 1
54 $VALGRIND ldbsearch '(cn=test*multi*test*multi)'  || exit 1
55 $VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1
56
57 echo "Starting ldbtest indexed"
58 time $VALGRIND ldbtest --num-records 100 --num-searches 500  || exit 1
59
60 echo "Testing one level search"
61 count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l`
62 if [ $count != 3 ]; then
63     echo returned $count records - expected 3
64     exit 1
65 fi
66
67 echo "Testing compare"
68 count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l`
69 if [ $count != 2 ]; then
70     echo returned $count records - expected 2
71     exit 1
72 fi
73
74 count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
75 if [ $count != 13 ]; then
76     echo returned $count records - expected 13
77     exit 1
78 fi
79
80 echo "Testing binary file attribute value"
81 $VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1
82
83 echo "*TODO* Testing UTF8 upper lower case searches !!"
84
85 checkcount() {
86     count=$1
87     scope=$2
88     basedn=$3
89     expression="$4"
90     n=`bin/ldbsearch -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l`
91     if [ $n != $count ]; then
92         echo "Got $n but expected $count for $expression"
93         bin/ldbsearch "$expression"
94         exit 1
95     fi
96     echo "OK: $count $expression"
97 }
98
99 checkcount 0 'base' '' '(uid=uham)'
100 checkcount 0 'one' '' '(uid=uham)'
101
102 checkcount 1 'base' 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
103 checkcount 1 'one' 'ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' '(uid=uham)'
104 checkcount 1 'one' 'ou=People,o=University of Michigan,c=TEST' '(ou=ldb  test)'