~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/script/tests/test_functions.sh

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
samba3_stop_sig_term() {
 
3
        RET=0
 
4
        kill -USR1 `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 || \
 
5
                kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` || RET=$?
 
6
 
 
7
        kill -USR1 `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 || \
 
8
                kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` || RET=$?
 
9
 
 
10
        return $RET;
 
11
}
 
12
 
 
13
samba3_stop_sig_kill() {
 
14
        kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1
 
15
        kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1
 
16
        return 0;
 
17
}
 
18
 
 
19
samba3_check_or_start() {
 
20
        if [ -n "$SERVER_TEST_FIFO" ];then
 
21
 
 
22
                trap samba3_stop_sig_kill INT QUIT
 
23
                trap samba3_stop_sig_kill TERM
 
24
 
 
25
                if [ -p "$SERVER_TEST_FIFO" ];then
 
26
                        return 0;
 
27
                fi
 
28
 
 
29
                if [ -n "$SOCKET_WRAPPER_DIR" ];then
 
30
                        if [ -d "$SOCKET_WRAPPER_DIR" ]; then
 
31
                                rm -f $SOCKET_WRAPPER_DIR/*
 
32
                        else
 
33
                                mkdir -p $SOCKET_WRAPPER_DIR
 
34
                        fi
 
35
                fi
 
36
 
 
37
                rm -f $SERVER_TEST_FIFO
 
38
                mkfifo $SERVER_TEST_FIFO
 
39
 
 
40
                rm -f $NMBD_TEST_LOG
 
41
                echo -n "STARTING NMBD..."
 
42
                ((
 
43
                        if test x"$NMBD_MAXTIME" = x; then
 
44
                            NMBD_MAXTIME=2700
 
45
                        fi
 
46
                        timelimit $NMBD_MAXTIME $NMBD_VALGRIND $SRCDIR/bin/nmbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $NMBD_TEST_LOG 2>&1 &
 
47
                        TIMELIMIT_NMBD_PID=$!
 
48
                        echo $TIMELIMIT_NMBD_PID > $PIDDIR/timelimit.nmbd.pid
 
49
                        wait $TIMELIMIT_NMBD_PID
 
50
                        ret=$?;
 
51
                        rm -f $SERVER_TEST_FIFO
 
52
                        if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
 
53
                                rm -f $SOCKET_WRAPPER_DIR/*
 
54
                        fi
 
55
                        if [ x"$ret" = x"0" ];then
 
56
                                echo "nmbd exits with status $ret";
 
57
                                echo "nmbd exits with status $ret" >>$NMBD_TEST_LOG;
 
58
                        elif [ x"$ret" = x"137" ];then
 
59
                                echo "nmbd got SIGXCPU and exits with status $ret!"
 
60
                                echo "nmbd got SIGXCPU and exits with status $ret!">>$NMBD_TEST_LOG;
 
61
                        else
 
62
                                echo "nmbd failed with status $ret!"
 
63
                                echo "nmbd failed with status $ret!">>$NMBD_TEST_LOG;
 
64
                        fi
 
65
                        exit $ret;
 
66
                ) || exit $? &) 2>/dev/null || exit $?
 
67
                echo  "DONE"
 
68
 
 
69
                rm -f $SMBD_TEST_LOG
 
70
                echo -n "STARTING SMBD..."
 
71
                ((
 
72
                        if test x"$SMBD_MAXTIME" = x; then
 
73
                            SMBD_MAXTIME=2700
 
74
                        fi
 
75
                        timelimit $SMBD_MAXTIME $SMBD_VALGRIND $SRCDIR/bin/smbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $SMBD_TEST_LOG 2>&1 &
 
76
                        TIMELIMIT_SMBD_PID=$!
 
77
                        echo $TIMELIMIT_SMBD_PID > $PIDDIR/timelimit.smbd.pid
 
78
                        wait $TIMELIMIT_SMBD_PID
 
79
                        ret=$?;
 
80
                        rm -f $SERVER_TEST_FIFO
 
81
                        if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
 
82
                                rm -f $SOCKET_WRAPPER_DIR/*
 
83
                        fi
 
84
                        if [ x"$ret" = x"0" ];then
 
85
                                echo "smbd exits with status $ret";
 
86
                                echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
 
87
                        elif [ x"$ret" = x"137" ];then
 
88
                                echo "smbd got SIGXCPU and exits with status $ret!"
 
89
                                echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
 
90
                        else
 
91
                                echo "smbd failed with status $ret!"
 
92
                                echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
 
93
                        fi
 
94
                        exit $ret;
 
95
                ) || exit $? &) 2>/dev/null || exit $?
 
96
                echo  "DONE"
 
97
        fi
 
98
        return 0;
 
99
}
 
100
 
 
101
samba3_nmbd_test_log() {
 
102
        if [ -n "$NMBD_TEST_LOG" ];then
 
103
                if [ -r "$NMBD_TEST_LOG" ];then
 
104
                        return 0;
 
105
                fi
 
106
        fi
 
107
        return 1;
 
108
}
 
109
 
 
110
samba3_smbd_test_log() {
 
111
        if [ -n "$SMBD_TEST_LOG" ];then
 
112
                if [ -r "$SMBD_TEST_LOG" ];then
 
113
                        return 0;
 
114
                fi
 
115
        fi
 
116
        return 1;
 
117
}
 
118
 
 
119
samba3_check_only() {
 
120
        if [ -n "$SERVER_TEST_FIFO" ];then
 
121
                if [ -p "$SERVER_TEST_FIFO" ];then
 
122
                        return 0;
 
123
                fi
 
124
                return 1;
 
125
        fi
 
126
        return 0;
 
127
}
 
128
 
 
129
testit() {
 
130
        if [ -z "$PREFIX" ]; then
 
131
            PREFIX=test_prefix
 
132
            mkdir -p $PREFIX
 
133
        fi
 
134
        name=$1
 
135
        shift 1
 
136
        SERVERS_ARE_UP="no"
 
137
        TEST_LOG="$PREFIX/test_log.$$"
 
138
        trap "rm -f $TEST_LOG" EXIT
 
139
        cmdline="$*"
 
140
 
 
141
        if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
 
142
                echo "--==--==--==--==--==--==--==--==--==--==--"
 
143
                echo "Running test $name (level 0 stdout)"
 
144
                echo "--==--==--==--==--==--==--==--==--==--==--"
 
145
                date
 
146
                echo "Testing $name"
 
147
        else
 
148
                echo "Testing $name ($failed)"
 
149
        fi
 
150
 
 
151
        samba3_check_only && SERVERS_ARE_UP="yes"
 
152
        if [ x"$SERVERS_ARE_UP" != x"yes" ];then
 
153
                if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
 
154
                        echo "SERVERS are down! Skipping: $cmdline"
 
155
                        echo "=========================================="
 
156
                        echo "TEST SKIPPED: $name (reason SERVERS are down)"
 
157
                        echo "=========================================="
 
158
                else
 
159
                        echo "TEST SKIPPED: $name (reason SERVERS are down)"
 
160
                fi
 
161
                return 1
 
162
        fi
 
163
        
 
164
        ( $cmdline > $TEST_LOG 2>&1 )
 
165
        status=$?
 
166
        if [ x"$status" != x"0" ]; then
 
167
                echo "TEST OUTPUT:"
 
168
                cat $TEST_LOG;
 
169
                samba3_nmbd_test_log && echo "NMBD OUTPUT:";
 
170
                samba3_nmbd_test_log && cat $NMBD_TEST_LOG;
 
171
                samba3_smbd_test_log && echo "SMBD OUTPUT:";
 
172
                samba3_smbd_test_log && cat $SMBD_TEST_LOG;
 
173
                rm -f $TEST_LOG;
 
174
                if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
 
175
                        echo "=========================================="
 
176
                        echo "TEST FAILED: $name (status $status)"
 
177
                        echo "=========================================="
 
178
                else
 
179
                        echo "TEST FAILED: $cmdline (status $status)"
 
180
                fi
 
181
                return 1;
 
182
        fi
 
183
        rm -f $TEST_LOG;
 
184
        if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
 
185
                echo "ALL OK: $cmdline"
 
186
                echo "=========================================="
 
187
                echo "TEST PASSED: $name"
 
188
                echo "=========================================="
 
189
        fi
 
190
        return 0;
 
191
}
 
192
 
 
193
testok() {
 
194
        name=`basename $1`
 
195
        failed=$2
 
196
 
 
197
        if [ x"$failed" = x"0" ];then
 
198
                :
 
199
        else
 
200
                echo "$failed TESTS FAILED or SKIPPED ($name)";
 
201
        fi
 
202
        exit $failed
 
203
}
 
204
 
 
205
teststatus() {
 
206
        name=`basename $1`
 
207
        failed=$2
 
208
 
 
209
        if [ x"$failed" = x"0" ];then
 
210
                echo "TEST STATUS: $failed";
 
211
        else
 
212
                echo "TEST STATUS: $failed";
 
213
        fi
 
214
        exit $failed
 
215
}
 
216
 
 
217
if [ -z "$VALGRIND" ]; then
 
218
    MALLOC_CHECK_=2
 
219
    export MALLOC_CHECK_
 
220
fi
 
221