1#! /bin/sh
2# $OpenLDAP$
3## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4##
5## Copyright 1998-2021 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
18TB="" TN=""
19if test -t 1 ; then
20          TB=`$SHTOOL echo -e "%B" 2>/dev/null`
21          TN=`$SHTOOL echo -e "%b" 2>/dev/null`
22fi
23
24FAILCOUNT=0
25SKIPCOUNT=0
26SLEEPTIME=10
27
28echo ">>>>> Executing all LDAP tests for $BACKEND"
29
30if [ -n "$NOEXIT" ]; then
31          echo "Result        Test" > $TESTWD/results
32fi
33
34for CMD in $SRCDIR/scripts/test*; do
35          case "$CMD" in
36                    *~)                 continue;;
37                    *.bak)    continue;;
38                    *.orig)   continue;;
39                    *.sav)    continue;;
40                    *.py)     continue;;
41                    *)                  test -f "$CMD" || continue;;
42          esac
43
44          # remove cruft from prior test
45          if test $PRESERVE = yes ; then
46                    /bin/rm -rf $TESTDIR/db.*
47          else
48                    /bin/rm -rf $TESTDIR
49          fi
50          if test $BACKEND = ndb ; then
51                    mysql --user root <<EOF
52                    drop database if exists db_1;
53                    drop database if exists db_2;
54                    drop database if exists db_3;
55                    drop database if exists db_4;
56                    drop database if exists db_5;
57                    drop database if exists db_6;
58EOF
59          fi
60
61          BCMD=`basename $CMD`
62          if [ -x "$CMD" ]; then
63                    echo ">>>>> Starting ${TB}$BCMD${TN} for $BACKEND..."
64                    START=`date +%s`
65                    $CMD
66                    RC=$?
67                    END=`date +%s`
68
69                    if test $RC -eq 0 ; then
70                              echo ">>>>> $BCMD completed ${TB}OK${TN} for $BACKEND after $(( $END - $START )) seconds."
71                    else
72                              echo ">>>>> $BCMD ${TB}failed${TN} for $BACKEND after $(( $END - $START )) seconds"
73                              FAILCOUNT=`expr $FAILCOUNT + 1`
74
75                              if [ -n "$NOEXIT" ]; then
76                                        echo "Continuing."
77                              else
78                                        echo "(exit $RC)"
79                                        exit $RC
80                              fi
81                    fi
82          else
83                    echo ">>>>> Skipping ${TB}$BCMD${TN} for $BACKEND."
84                    SKIPCOUNT=`expr $SKIPCOUNT + 1`
85                    RC="-"
86          fi
87
88          if [ -n "$NOEXIT" ]; then
89                    echo "$RC $BCMD" >> $TESTWD/results
90          fi
91
92#         echo ">>>>> waiting $SLEEPTIME seconds for things to exit"
93#         sleep $SLEEPTIME
94          echo ""
95done
96
97if [ -n "$NOEXIT" ]; then
98          if [ "$FAILCOUNT" -gt 0 ]; then
99                    cat $TESTWD/results
100                    echo "$FAILCOUNT tests for $BACKEND ${TB}failed${TN}. Please review the test log."
101          else
102                    echo "All executed tests for $BACKEND ${TB}succeeded${TN}."
103          fi
104fi
105
106echo "$SKIPCOUNT tests for $BACKEND were ${TB}skipped${TN}."
107