Skip to content

Commit

Permalink
Parallel tests support
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch authored and daghf committed Apr 19, 2016
1 parent a589f82 commit 7c5e4b1
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 142 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
language: c

before_install:
- sudo apt-get update -q
- sudo apt-get install -qq libev-dev libssl-dev automake python-docutils flex bison

- sudo apt-get update
- sudo apt-get install libev-dev libssl-dev automake python-docutils flex bison

before_script:
- ./bootstrap
- ./configure --prefix=/usr
- ./configure
- make -j4

script:
# - make check -j4
- ./src/tests/runtests
- make -j4 check VERBOSE=1

compiler:
- clang
Expand Down
5 changes: 4 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AC_INIT([hitch], [1.2.0-beta1], [[email protected]])
AC_CONFIG_SRCDIR([src/configuration.c])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([foreign])
AM_INIT_AUTOMAKE([foreign color-tests parallel-tests])

# Checks for programs.
AC_PROG_CC
Expand Down Expand Up @@ -61,6 +61,9 @@ AC_FUNC_FORK
AC_FUNC_MMAP
AC_CHECK_FUNCS([accept4])

SH_TESTS="$(cd src && echo tests/test*)"
AC_SUBST(SH_TESTS)

AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])

Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ AM_CPPFLAGS = $(EV_CFLAGS)
AM_CFLAGS = -O2 -g -std=c99 -fno-strict-aliasing -Wall -W -D_GNU_SOURCE
AM_YFLAGS = -d -t

TESTS_ENVIRONMENT = \
TESTDIR=$(abs_top_builddir)/src/tests/; export TESTDIR; \
PATH=$(abs_top_builddir)/src:$$PATH; export PATH;
TESTS = @SH_TESTS@
TEST_EXTENSIONS = .sh

nobase_noinst_HEADERS = ringbuffer.h configuration.h shctx.h miniobj.h \
vqueue.h vpf.h flopen.h uthash.h sysl_tbl.h vas.h vsb.h
BUILT_SOURCES = cfg_parser.h
Expand Down
10 changes: 4 additions & 6 deletions src/tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ LISTENPORT=$(($RANDOM + 1024))
PIDFILE="$(mktemp -u)"
CONFFILE="$(mktemp -u)"
DUMPFILE="$(mktemp -u)"
TESTDIR="$(pwd)"
CERTSDIR="${TESTDIR}/certs"
CONFDIR="${TESTDIR}/configs"

HITCH=../hitch
HITCH_ARGS="--pidfile=$PIDFILE --daemon --quiet"

if [ "$USER" == "root" ]; then
HITCH_ARGS="$HITCH_ARGS --user=nobody"

fi


cleanup() {
test -s $PIDFILE && kill `cat "$PIDFILE"`
rm -f "$PIDFILE" "$CONFFILE" "$DUMPFILE" 2>/dev/null
rm -f "$PIDFILE" "$CONFFILE" "$DUMPFILE"
}
trap cleanup EXIT

Expand All @@ -38,6 +36,6 @@ mk_cfg() {

runcurl() {
# Verify that we got a HTTP reply.
BUF=$(curl $CURL_EXTRA --silent --insecure https://$1:$2/ 2>&1)
curl $CURL_EXTRA -I -X GET --max-time 5 --silent --insecure https://$1:$2/
test "$?" = "0" || die "Incorrect HTTP response code."
}
2 changes: 1 addition & 1 deletion src/tests/configs/test08d.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Test extra whitespace.
frontend = "[*]:8443"
frontend = "[*]:8443"
backend = "[127.0.0.1]:6086"
ciphers = "HIGH"
prefer-server-ciphers = off
Expand Down
20 changes: 0 additions & 20 deletions src/tests/runtests

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#/bin/bash
#/bin/sh
# Test basic argument handling.
. common.sh
. ${TESTDIR}common.sh
set +o errexit

$HITCH --help 1>/dev/null
hitch --help
test "$?" = "0" || die "--help does not work."

$HITCH --OBVIOUSLY_BROKEN_ARG 2>/dev/null
hitch --OBVIOUSLY_BROKEN_ARG
test "$?" = "1" || die "Wrong exit code."

$HITCH --version 1>/dev/null
hitch --version
test "$?" = "0" || die "--version does not work"

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#/bin/bash
#/bin/sh
# Test basic argument handling.
# This implements T2 in the original test plan.
. common.sh
. ${TESTDIR}common.sh
set +o errexit

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" certs/site1.example.com
hitch $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" ${CERTSDIR}/site1.example.com
test "$?" = "0" || die "Hitch did not start."

echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"

grep -q -c "subject=/CN=site1.example.com" $DUMPFILE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
#/bin/bash
#/bin/sh
#
# Test multiple listening sockets.
#
# This implements T3 in the original test plan.
. common.sh
. ${TESTDIR}common.sh

PORT2=$(($RANDOM + 1024))

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 \
hitch $HITCH_ARGS --backend=[hitch-tls.org]:80 \
"--frontend=[${LISTENADDR}]:$LISTENPORT" \
"--frontend=[${LISTENADDR}]:$PORT2" \
certs/site1.example.com
${CERTSDIR}/site1.example.com
test "$?" = "0" || die "Hitch did not start."

echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
#cat $DUMPFILE
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE

# Second listen port.
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$PORT2 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$PORT2 >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
#cat $DUMPFILE
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE

runcurl $LISTENADDR $LISTENPORT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#/bin/bash
#/bin/sh
#
# Test multiple listening sockets, each with their own certificate.
#
# This implements T3 in the original test plan.
. common.sh
. ${TESTDIR}common.sh
set +o errexit

PORT2=$(($RANDOM + 1024))

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 \
"--frontend=[${LISTENADDR}]:$LISTENPORT+certs/site1.example.com" \
"--frontend=[${LISTENADDR}]:$PORT2+certs/site2.example.com" \
certs/default.example.com
hitch $HITCH_ARGS --backend=[hitch-tls.org]:80 \
"--frontend=[${LISTENADDR}]:$LISTENPORT+${CERTSDIR}/site1.example.com" \
"--frontend=[${LISTENADDR}]:$PORT2+${CERTSDIR}/site2.example.com" \
${CERTSDIR}/default.example.com
test "$?" = "0" || die "Hitch did not start."

echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE || die "s_client failed"
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1 || die "s_client failed"
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate on listen port #1"

# Second listen port.
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$PORT2 2>/dev/null > $DUMPFILE || die "s_client failed"
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$PORT2 >$DUMPFILE 2>&1 || die "s_client failed"
grep -q -c "subject=/CN=site2.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#/bin/bash
#/bin/sh
#
# Test multiple certificates (SNI) on a listening socket.
#
# This implements T4 in the original test plan.
. common.sh
. ${TESTDIR}common.sh
set +o errexit

#PORT2=$(($RANDOM + 1024))

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 --frontend=[${LISTENADDR}]:$LISTENPORT \
certs/site1.example.com certs/site2.example.com certs/default.example.com
hitch $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" \
${CERTSDIR}/site1.example.com ${CERTSDIR}/site2.example.com ${CERTSDIR}/default.example.com
test "$?" = "0" || die "Hitch did not start."

echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=default.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate on listen port #1"

# send a SNI request
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#/bin/bash
#/bin/sh
#
# Test resuming a session via a session ticket

. common.sh
. ${TESTDIR}common.sh
set +o errexit

sessfile=$(mktemp)
Expand All @@ -12,13 +12,13 @@ function rmsess {
}
trap rmsess EXIT

$HITCH $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" certs/site1.example.com
hitch $HITCH_ARGS --backend=[hitch-tls.org]:80 "--frontend=[${LISTENADDR}]:$LISTENPORT" ${CERTSDIR}/site1.example.com
test "$?" = "0" || die "Hitch did not start."

echo -e "\n" | openssl s_client -prexit -sess_out $sessfile -connect $LISTENADDR:$LISTENPORT >/dev/null 2>&1
echo -e "\n" | openssl s_client -prexit -sess_out $sessfile -connect $LISTENADDR:$LISTENPORT
test "$?" = "0" || die "s_client failed (1)"

echo -e "\n" | openssl s_client -prexit -sess_in $sessfile -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -sess_in $sessfile -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed (2)"

grep -q -c "Reused, " $DUMPFILE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#/bin/bash
#/bin/sh
#
# Test --sni-nomatch-abort
#
. common.sh
. ${TESTDIR}common.sh
set +o errexit

#PORT2=$(($RANDOM + 1024))

mk_cfg <<EOF
sni-nomatch-abort = on
pem-file = "$TESTDIR/certs/site1.example.com"
pem-file = "$TESTDIR/certs/site2.example.com"
pem-file = "$TESTDIR/certs/default.example.com"
pem-file = "${CERTSDIR}/site1.example.com"
pem-file = "${CERTSDIR}/site2.example.com"
pem-file = "${CERTSDIR}/default.example.com"
backend = "[hitch-tls.org]:80"
Expand All @@ -24,29 +24,29 @@ frontend = {
frontend = {
host = "$LISTENADDR"
port = "$((LISTENPORT+1))"
pem-file = "$TESTDIR/certs/site3.example.com"
pem-file = "${CERTSDIR}/site3.example.com"
sni-nomatch-abort = off
}
EOF

$HITCH $HITCH_ARGS --config=$CONFFILE
hitch $HITCH_ARGS --config=$CONFFILE
test "$?" = "0" || die "Hitch did not start."

# No SNI - should not be affected.
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=default.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate on listen port #1"

# SNI request w/ valid servername
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$LISTENPORT 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=site1.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"

# SNI w/ unknown servername
echo | openssl s_client -servername invalid.example.com -prexit -connect $LISTENADDR:$LISTENPORT > $DUMPFILE 2>&1
echo | openssl s_client -servername invalid.example.com -prexit -connect $LISTENADDR:$LISTENPORT >$DUMPFILE 2>&1
test "$?" != "0" || die "s_client did NOT fail when it should have. "
grep -q -c "unrecognized name" $DUMPFILE
test "$?" = "0" || die "Expected 'unrecognized name' error."
Expand All @@ -55,13 +55,13 @@ CURL_EXTRA="--resolve site1.example.com:$LISTENPORT:127.0.0.1"
runcurl site1.example.com $LISTENPORT

# SNI request w/ valid servername
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$((LISTENPORT+1)) 2>/dev/null > $DUMPFILE
echo -e "\n" | openssl s_client -servername site1.example.com -prexit -connect $LISTENADDR:$((LISTENPORT+1)) >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=site3.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"

# SNI w/ unknown servername
echo | openssl s_client -servername invalid.example.com -prexit -connect $LISTENADDR:$((LISTENPORT+1)) > $DUMPFILE 2>&1
echo | openssl s_client -servername invalid.example.com -prexit -connect $LISTENADDR:$((LISTENPORT+1)) >$DUMPFILE 2>&1
test "$?" = "0" || die "s_client failed"
grep -q -c "subject=/CN=site3.example.com" $DUMPFILE
test "$?" = "0" || die "s_client got wrong certificate in listen port #2"
27 changes: 0 additions & 27 deletions src/tests/test08-test-configs

This file was deleted.

Loading

0 comments on commit 7c5e4b1

Please sign in to comment.