simple testing framework
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- -*- lua -*-
|
||||
mt.echo("beginning test")
|
||||
conn = mt.connect("unix:signing.sock")
|
||||
if conn == nil then
|
||||
error "mt.connect() failed"
|
||||
end
|
||||
mt.disconnect(conn)
|
||||
mt.echo("test complete")
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
-- -*- lua -*-
|
||||
mt.echo("beginning test")
|
||||
conn = mt.connect("unix:signing.sock")
|
||||
if conn == nil then
|
||||
error "mt.connect() failed"
|
||||
end
|
||||
if mt.conninfo(conn, "localhost", "127.0.0.1") ~= nil then
|
||||
error "mt.conninfo() failed"
|
||||
end
|
||||
if mt.getreply(conn) ~= SMFIR_CONTINUE then
|
||||
error "mt.conninfo() unexpected reply"
|
||||
end
|
||||
mt.disconnect(conn)
|
||||
mt.echo("test complete")
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
WORKDIR=$(mktemp -d)
|
||||
TESTDIR=$(realpath "$(dirname "$0")")
|
||||
|
||||
cd "$WORKDIR"
|
||||
|
||||
dknewkey --ktype ed25519 testkey
|
||||
cat > signing.conf <<EOF
|
||||
Domain example.net
|
||||
KeyFileEd25519 testkey.key
|
||||
SelectorEd25519 testkey
|
||||
Socket unix:signing.sock
|
||||
PidFile milter.pid
|
||||
Mode s
|
||||
UserID $(id --name --user):$(id --name --group)
|
||||
EOF
|
||||
rm -f milter.pid milter.sock
|
||||
|
||||
cleanup() {
|
||||
echo cleaning up jobs:
|
||||
jobs
|
||||
if [ -s milter.pid ] && kill -0 "$(cat milter.pid)"; then
|
||||
kill "$(cat milter.pid)"
|
||||
wait
|
||||
fi
|
||||
if [ -s stderr ]; then
|
||||
printf -- "-> stderr:\n"
|
||||
cat stderr
|
||||
printf -- "-> end stderr\n"
|
||||
fi
|
||||
rm -rf "$WORKDIR"
|
||||
}
|
||||
|
||||
PYTHONPATH="$(dirname "$TESTDIR")" dkimpy-milter signing.conf 2>stderr &
|
||||
trap cleanup EXIT
|
||||
|
||||
# ugly ugly (how are we supposed to know that the filter is ready?):
|
||||
sleep 2
|
||||
|
||||
# uses miltertest from opendkim:
|
||||
for x in ${TESTS:-"$TESTDIR"/*.miltertest}; do
|
||||
if ! [ -e "$x" ]; then
|
||||
if [ -e "$TESTDIR/$x" ]; then
|
||||
x="$TESTDIR/$x"
|
||||
fi
|
||||
fi
|
||||
printf -- "-> running %s...\n" "$x"
|
||||
miltertest -s "$x"
|
||||
done
|
||||
Reference in New Issue
Block a user