]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test025-limits
parametrize all directories
[openldap] / tests / scripts / test025-limits
index 1329f81d93597bc077748579127e06ee7519746a..93c0221f9e76063f37ae615ae2f8b0265350a63c 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2005 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,8 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 
+## FIXME: need to exclude legal but wrong results...
+
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
@@ -77,7 +79,80 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limits requested for rootdn=$MANAGERDN..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D "$MANAGERDN" \
+       '(objectClass=*)' >$SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=4
+echo "Testing limit requested for rootdn=$MANAGERDN..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D "$MANAGERDN" \
+       '(objectClass=*)' >$SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -95,10 +170,33 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
-               echo "...bumped into requested size limit ($SIZELIMIT)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -116,10 +214,19 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        3)
-               echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       COUNT=0
+               fi
+               echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -136,10 +243,22 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
-               echo "...bumped into server-side size limit ($COUNT)"
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -157,7 +276,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
@@ -167,7 +297,9 @@ case $RC in
                                echo "...bumped into server-side size limit ($COUNT)"
                        fi
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
                fi
        ;;
        *)
@@ -186,7 +318,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
@@ -196,7 +339,9 @@ case $RC in
                                echo "...bumped into server-side size limit ($COUNT)"
                        fi
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
                fi
        ;;
        *)
@@ -215,7 +360,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                echo "...bumped into requested ($SIZELIMIT) size limit"
@@ -236,14 +392,73 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
-               echo "...bumped into requested ($SIZELIMIT) size limit"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       else
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
-       11)
-               echo "...bumped into server-side hard size administrative limit"
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=max
+echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -259,10 +474,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        11)
-               echo "...bumped into unchecked administrative limit"
+               echo "...error: bumped into unchecked administrative limit"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -279,7 +502,13 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+               fi
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -299,7 +528,13 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+               fi
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -319,17 +554,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -347,17 +586,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -375,17 +618,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -403,17 +650,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -431,17 +682,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -458,17 +713,21 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test "x$SIZELIMIT" = "x$COUNT" ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -490,11 +749,25 @@ case $BACKEND in
        ;;
 esac
 
+if test x"$SLAPD_PAGE_SIZE" != x ; then
+       PAGESIZE="$SLAPD_PAGE_SIZE"
+       if test "$PAGESIZE" -le 0 ; then
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
+               echo ""
+               echo "Testing with pagedResults control disabled"
+               echo ""
+               echo ">>>>> Test succeeded"
+               exit 0
+       fi
+else
+       PAGESIZE=5
+fi
+
 echo ""
-echo "Testing regular search limits with pagedResults control"
+echo "Testing regular search limits with pagedResults control (page size $PAGESIZE)"
 echo ""
 
-PAGESIZE=5
 echo "Testing no limits requested for unlimited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
        -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
@@ -503,7 +776,13 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -521,10 +800,33 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
-               echo "...bumped into requested size limit ($SIZELIMIT)"
+               if test x"$COUNT" != x ; then
+                       if test $COUNT = $SIZELIMIT ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries while requesting $SIZELIMIT..."
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -542,10 +844,19 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        3)
-               echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
+               if test x"$COUNT" = x ; then
+                       COUNT=0
+               fi
+               echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -562,10 +873,22 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        4)
-               echo "...bumped into server-side size limit ($COUNT)"
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -583,7 +906,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
@@ -612,7 +946,18 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
@@ -641,10 +986,33 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
-               echo "...bumped into requested ($SIZELIMIT) size limit"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested ($SIZELIMIT) size limit"
+                       else
+                               echo "...error: got size limit $SIZELIMIT but $COUNT entries"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -662,14 +1030,73 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
-               echo "...bumped into requested ($SIZELIMIT) size limit"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       else
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
-       11)
-               echo "...bumped into hard size administrative limit"
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=max
+echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
+               else
+                       echo "...error: bumped into size limit but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -685,11 +1112,17 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
-       ;;
-       11)
-               echo "...bumped into unchecked administrative limit"
-       ;;
+               if test x"$COUNT" != x ; then
+                        echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
+       ;;
+#      11)
+#              echo "...bumped into unchecked administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -705,7 +1138,13 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                fi
+                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                exit $RC
        ;;
        11)
                echo "...bumped into unchecked administrative limit"
@@ -729,10 +1168,22 @@ RC=$?
 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        4)
-               echo "...bumped into server-side size limit ($COUNT)"
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -874,6 +1325,38 @@ case $RC in
        ;;
 esac
 
+SIZELIMIT=max
+echo "Testing max limit requested for pagedResults total count limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
+                               echo "...bumped into requested ($SIZELIMIT) size limit"
+                       else
+                               echo "...bumped into server-side size limit ($COUNT)"
+                       fi
+               else
+                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+               fi
+       ;;
+       11)
+               echo "...bumped into pagedResults total count administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"