mirror of
https://github.com/osmarks/ngircd.git
synced 2025-07-05 19:32:50 +00:00
Test suite: clean up scripts
- Reformat code. - Cleanup some glitches, streamline scripts ... - Enable "set -u": Error on unset variables. - Detect "$srcdir" in prep-server3 script, too.
This commit is contained in:
parent
8d6f2c2820
commit
7e78c293a9
@ -1,10 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
# did we get a name?
|
# did we get a name?
|
||||||
[ $# -ne 1 ] && exit 1
|
[ $# -ne 1 ] && exit 1
|
||||||
|
|
||||||
[ -x /bin/pidof ] && exec /bin/pidof -s $@
|
[ -x /bin/pidof ] && exec /bin/pidof -s "$1"
|
||||||
|
|
||||||
# detect flags for "ps" and "head"
|
# detect flags for "ps" and "head"
|
||||||
UNAME=`uname`
|
UNAME=`uname`
|
||||||
@ -42,10 +44,7 @@ pid=`head $HEAD_FLAGS pids.tmp`
|
|||||||
rm -rf procs.tmp pids.tmp
|
rm -rf procs.tmp pids.tmp
|
||||||
|
|
||||||
# validate PID
|
# validate PID
|
||||||
[ "$pid" -gt 1 ] > /dev/null 2>&1
|
[ "$pid" -gt 1 ] >/dev/null 2>&1 || exit 1
|
||||||
[ $? -ne 0 ] && exit 1
|
|
||||||
|
|
||||||
echo $pid
|
echo $pid
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -eu
|
||||||
mkdir -p ssl
|
mkdir -p ssl
|
||||||
cp "${srcdir}"/ssl/cert-my-first-domain-tld.pem ssl/cert.pem
|
cp "${srcdir}"/ssl/cert-my-first-domain-tld.pem ssl/cert.pem
|
||||||
cp "${srcdir}"/ssl/key-my-first-domain-tld.pem ssl/key.pem
|
cp "${srcdir}"/ssl/key-my-first-domain-tld.pem ssl/key.pem
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
id="$1"; shift
|
id="$1"; shift
|
||||||
@ -28,5 +29,3 @@ if [ $r -eq 0 ]; then
|
|||||||
fi
|
fi
|
||||||
echo " failure: server ${id} could not be reloaded!"
|
echo " failure: server ${id} could not be reloaded!"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
id="$1"; shift
|
id="$1"; shift
|
||||||
@ -40,15 +41,13 @@ MALLOC_CHECK_=3
|
|||||||
export MALLOC_CHECK_
|
export MALLOC_CHECK_
|
||||||
|
|
||||||
# starting up test-server ...
|
# starting up test-server ...
|
||||||
./T-ngircd${id} -n -f ${srcdir}/ngircd-test${id}.conf $* \
|
./T-ngircd${id} -n -f "${srcdir}/ngircd-test${id}.conf" "$@" \
|
||||||
>ngircd-test${id}.log 2>&1 &
|
>ngircd-test${id}.log 2>&1 &
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# validate running test-server
|
# validate running test-server
|
||||||
|
r=1
|
||||||
pid=`./getpid.sh T-ngircd${id}`
|
pid=`./getpid.sh T-ngircd${id}`
|
||||||
[ -n "$pid" ] && kill -0 $pid >/dev/null 2>&1; r=$?
|
[ -n "$pid" ] && kill -0 $pid >/dev/null 2>&1; r=$?
|
||||||
|
|
||||||
[ $r -eq 0 ] && echo " ok." || echo " failure!"
|
[ $r -eq 0 ] && echo " ok." || echo " failure!"
|
||||||
exit $r
|
exit $r
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/start-server.sh 1
|
set -u
|
||||||
|
"${srcdir}/start-server.sh" 1
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/start-server.sh 2
|
set -u
|
||||||
|
"${srcdir}/start-server.sh" 2
|
||||||
# -eof-
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/start-server.sh 3
|
set -u
|
||||||
# -eof-
|
"${srcdir}/start-server.sh" 3
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
id="$1"; shift
|
id="$1"; shift
|
||||||
@ -33,5 +34,3 @@ for i in 1 2 3 4 5; do
|
|||||||
done
|
done
|
||||||
echo " failure: server ${id} still running!?"
|
echo " failure: server ${id} still running!?"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/stop-server.sh 1
|
set -u
|
||||||
|
"${srcdir}/stop-server.sh" 1
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/stop-server.sh 2
|
set -u
|
||||||
|
"${srcdir}/stop-server.sh" 2
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
${srcdir}/stop-server.sh 3
|
set -u
|
||||||
|
"${srcdir}/stop-server.sh" 3
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
# Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
|
# Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -10,15 +10,16 @@
|
|||||||
# Please read the file COPYING, README and AUTHORS for more information.
|
# Please read the file COPYING, README and AUTHORS for more information.
|
||||||
#
|
#
|
||||||
|
|
||||||
# detect source directory
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
|
||||||
|
|
||||||
# parse command line
|
# parse command line
|
||||||
[ "$1" -gt 0 ] 2>/dev/null && CLIENTS="$1" || CLIENTS=5
|
[ "$1" -gt 0 ] 2>/dev/null && CLIENTS="$1" || CLIENTS=5
|
||||||
[ "$2" -gt 0 ] 2>/dev/null && MAX="$2" || MAX=-1
|
[ "$2" -gt 0 ] 2>/dev/null && MAX="$2" || MAX=-1
|
||||||
|
|
||||||
|
# detect source directory
|
||||||
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
# get our name
|
# get our name
|
||||||
name=`basename $0`
|
name=`basename "$0"`
|
||||||
|
|
||||||
# create directories
|
# create directories
|
||||||
[ -d logs ] || mkdir logs
|
[ -d logs ] || mkdir logs
|
||||||
@ -27,25 +28,27 @@ name=`basename $0`
|
|||||||
# test for required external tools
|
# test for required external tools
|
||||||
type expect >/dev/null 2>&1
|
type expect >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "${name}: \"expect\" not found."; exit 77
|
echo "${name}: \"expect\" not found."
|
||||||
|
exit 77
|
||||||
fi
|
fi
|
||||||
type telnet >/dev/null 2>&1
|
type telnet >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "${name}: \"telnet\" not found."; exit 77
|
echo "${name}: \"telnet\" not found.";
|
||||||
|
exit 77
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# hello world! :-)
|
# hello world! :-)
|
||||||
echo "stressing server with $CLIENTS clients (be patient!):"
|
echo "stressing server with $CLIENTS clients (be patient!):"
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
# create scripts for expect(1)
|
# create scripts for expect(1)
|
||||||
no=0
|
no=0
|
||||||
while [ ${no} -lt $CLIENTS ]; do
|
while [ ${no} -lt $CLIENTS ]; do
|
||||||
cat ${srcdir}/stress-A.e > tests/${no}.e
|
cat "${srcdir}/stress-A.e" >tests/${no}.e
|
||||||
echo "send \"nick test${no}\\r\"" >>tests/${no}.e
|
echo "send \"nick test${no}\\r\"" >>tests/${no}.e
|
||||||
cat ${srcdir}/stress-B.e >> tests/${no}.e
|
cat "${srcdir}/stress-B.e" >>tests/${no}.e
|
||||||
no=`expr ${no} + 1`
|
no=`expr ${no} + 1`
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -66,13 +69,13 @@ while [ ${no} -lt $CLIENTS ]; do
|
|||||||
no=`expr ${no} + 1`
|
no=`expr ${no} + 1`
|
||||||
echo "started client $no/$CLIENTS."
|
echo "started client $no/$CLIENTS."
|
||||||
|
|
||||||
[ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX
|
[ $MAX -gt 0 ] && "$srcdir/wait-tests.sh" $MAX
|
||||||
done
|
done
|
||||||
|
|
||||||
echo_n "waiting for clients to complete: ."
|
echo_n "waiting for clients to complete: ."
|
||||||
touch logs/check-idle.log
|
touch logs/check-idle.log
|
||||||
while true; do
|
while true; do
|
||||||
expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$?
|
expect "${srcdir}/check-idle.e" >>logs/check-idle.log; res=$?
|
||||||
echo "====================" >>logs/check-idle.log
|
echo "====================" >>logs/check-idle.log
|
||||||
[ $res -ne 99 ] && break
|
[ $res -ne 99 ] && break
|
||||||
|
|
||||||
@ -82,7 +85,4 @@ while true; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
[ $res -eq 0 ] && echo " ok." || echo " failure!"
|
[ $res -eq 0 ] && echo " ok." || echo " failure!"
|
||||||
|
|
||||||
exit $res
|
exit $res
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
# Copyright (c)2002-2004 by Alexander Barton (alex@barton.de)
|
# Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -9,22 +9,21 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
# Please read the file COPYING, README and AUTHORS for more information.
|
# Please read the file COPYING, README and AUTHORS for more information.
|
||||||
#
|
#
|
||||||
# $Id: test-loop.sh,v 1.2 2004/09/04 19:14:46 alex Exp $
|
|
||||||
#
|
|
||||||
|
|
||||||
# detect source directory
|
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
|
||||||
|
|
||||||
# parse command line
|
# parse command line
|
||||||
[ "$1" -gt 0 ] 2>/dev/null && LOOPS="$1" || LOOPS=5
|
[ "$1" -gt 0 ] 2>/dev/null && LOOPS="$1" || LOOPS=5
|
||||||
[ "$2" -gt 0 ] 2>/dev/null && WAIT="$2" || WAIT=5
|
[ "$2" -gt 0 ] 2>/dev/null && WAIT="$2" || WAIT=5
|
||||||
|
|
||||||
|
# detect source directory
|
||||||
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
loop=0
|
loop=0
|
||||||
while [ ${loop} -lt $LOOPS ]; do
|
while [ ${loop} -lt $LOOPS ]; do
|
||||||
loop=`expr ${loop} + 1`
|
loop=`expr ${loop} + 1`
|
||||||
echo " loop $loop/$LOOPS starting:"
|
echo " loop $loop/$LOOPS starting:"
|
||||||
for s in $srcdir/*-test; do
|
for s in "$srcdir"/*-test; do
|
||||||
sh $s; r=$?
|
sh "$s"; r=$?
|
||||||
[ $r -ne 0 ] && exit $r
|
[ $r -ne 0 ] && exit $r
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
@ -33,5 +32,3 @@ while [ ${loop} -lt $LOOPS ]; do
|
|||||||
sleep $WAIT
|
sleep $WAIT
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -11,9 +11,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# detect source directory
|
# detect source directory
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
name=`basename $0`
|
name=`basename "$0"`
|
||||||
test=`echo ${name} | cut -d '.' -f 1`
|
test=`echo ${name} | cut -d '.' -f 1`
|
||||||
[ -d logs ] || mkdir logs
|
[ -d logs ] || mkdir logs
|
||||||
|
|
||||||
@ -24,17 +25,19 @@ if [ ! -r "$test" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
type expect >/dev/null 2>&1
|
type expect >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$test: \"expect\" not found" >>tests-skipped.lst
|
echo "$test: \"expect\" not found" >>tests-skipped.lst
|
||||||
echo "${name}: \"expect\" not found."; exit 77
|
echo "${name}: \"expect\" not found."
|
||||||
|
exit 77
|
||||||
fi
|
fi
|
||||||
type telnet >/dev/null 2>&1
|
type telnet >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$test: \"telnet\" not found" >>tests-skipped.lst
|
echo "$test: \"telnet\" not found" >>tests-skipped.lst
|
||||||
echo "${name}: \"telnet\" not found."; exit 77
|
echo "${name}: \"telnet\" not found."
|
||||||
|
exit 77
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$test" in
|
case "$test" in
|
||||||
@ -42,7 +45,8 @@ case "$test" in
|
|||||||
type openssl >/dev/null 2>&1
|
type openssl >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$test: \"openssl\" not found" >>tests-skipped.lst
|
echo "$test: \"openssl\" not found" >>tests-skipped.lst
|
||||||
echo "${name}: \"openssl\" not found."; exit 77
|
echo "${name}: \"openssl\" not found."
|
||||||
|
exit 77
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -63,5 +67,3 @@ expect "$e_exec" > logs/${test}.log; r=$?
|
|||||||
|
|
||||||
rm -f "$e_tmp"
|
rm -f "$e_tmp"
|
||||||
exit $r
|
exit $r
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# ngIRCd Test Suite
|
# ngIRCd Test Suite
|
||||||
# Copyright (c)2002-2004 by Alexander Barton (alex@barton.de)
|
# Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -9,20 +9,19 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
# Please read the file COPYING, README and AUTHORS for more information.
|
# Please read the file COPYING, README and AUTHORS for more information.
|
||||||
#
|
#
|
||||||
# $Id: wait-tests.sh,v 1.5 2005/08/12 21:34:19 alex Exp $
|
|
||||||
#
|
|
||||||
|
|
||||||
[ "$1" -gt 0 ] 2>/dev/null && MAX="$1" || MAX=5
|
[ "$1" -gt 0 ] 2>/dev/null && MAX="$1" || MAX=5
|
||||||
|
|
||||||
# detect source directory
|
# detect source directory
|
||||||
[ -z "$srcdir" ] && srcdir=`dirname $0`
|
[ -z "$srcdir" ] && srcdir=`dirname "$0"`
|
||||||
|
set -u
|
||||||
|
|
||||||
PS_FLAGS="-f"
|
PS_FLAGS="-f"
|
||||||
ps $PS_FLAGS >/dev/null 2>&1
|
ps $PS_FLAGS >/dev/null 2>&1
|
||||||
[ $? -ne 0 ] && PS_FLAGS="a"
|
[ $? -ne 0 ] && PS_FLAGS="a"
|
||||||
|
|
||||||
# read in functions
|
# read in functions
|
||||||
. ${srcdir}/functions.inc
|
. "${srcdir}/functions.inc"
|
||||||
|
|
||||||
msg=0
|
msg=0
|
||||||
while true; do
|
while true; do
|
||||||
@ -43,5 +42,3 @@ done
|
|||||||
|
|
||||||
[ $msg -gt 0 ] && echo "done: $count"
|
[ $msg -gt 0 ] && echo "done: $count"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
# -eof-
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user