]> git.sur5r.net Git - openldap/blob - tests/scripts/all
Add NOEXIT envvar to run all tests and tally failures
[openldap] / tests / scripts / all
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2011 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
15
16 . $SRCDIR/scripts/defines.sh
17
18 TB="" TN=""
19 if test -t 1 ; then
20         TB=`$SHTOOL echo -e "%B" 2>/dev/null`
21         TN=`$SHTOOL echo -e "%b" 2>/dev/null`
22 fi
23
24 FAILCOUNT=0
25 SLEEPTIME=10
26
27 echo ">>>>> Executing all LDAP tests for $BACKEND"
28
29 if [ -n "$NOEXIT" ]; then
30         echo "Result    Test" > $TESTWD/results
31 fi
32
33 for CMD in $SRCDIR/scripts/test*; do
34         case "$CMD" in
35                 *~)             continue;;
36                 *.bak)  continue;;
37                 *.orig) continue;;
38                 *.sav)  continue;;
39                 *)              test -f "$CMD" || continue;;
40         esac
41
42         # remove cruft from prior test
43         if test $PRESERVE = yes ; then
44                 /bin/rm -rf $TESTDIR/db.*
45         else
46                 /bin/rm -rf $TESTDIR
47         fi
48         if test $BACKEND = ndb ; then
49                 mysql --user root <<EOF
50                 drop database if exists db_1;
51                 drop database if exists db_2;
52                 drop database if exists db_3;
53                 drop database if exists db_4;
54                 drop database if exists db_5;
55                 drop database if exists db_6;
56 EOF
57         fi
58
59         echo ">>>>> Starting ${TB}`basename $CMD`${TN} for $BACKEND..."
60         $CMD
61         RC=$?
62         if test $RC -eq 0 ; then
63                 echo ">>>>> $CMD completed ${TB}OK${TN} for $BACKEND."
64         else
65                 echo ">>>>> $CMD ${TB}failed${TN} for $BACKEND"
66                 FAILCOUNT=`expr $FAILCOUNT + 1`
67
68                 if [ -n "$NOEXIT" ]; then
69                         echo "Continuing..."
70                 else
71                         echo "(exit $RC)"
72                         exit $RC
73                 fi
74         fi
75         if [ -n "$NOEXIT" ]; then
76                 echo "$RC       $CMD" >> $TESTWD/results
77         fi
78
79 #       echo ">>>>> waiting $SLEEPTIME seconds for things to exit"
80 #       sleep $SLEEPTIME
81         echo ""
82 done
83
84 if [ -n "$NOEXIT" ]; then
85         if [ "$FAILCOUNT" -gt 0 ]; then
86                 cat $TESTWD/results
87                 echo "$FAILCOUNT tests failed. Please review the test log."
88                 exit $FAILCOUNT
89         else
90                 echo "All tests succeeded."
91         fi
92 fi