aboutsummaryrefslogtreecommitdiff
path: root/test/integration_test.sh
blob: 165436e3ebfbd03c9ef61e054bd0267bed806c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash

set -e
set -x
set -o pipefail


SRC_ROOT=$(realpath $(dirname $0)/..)
PTUNNEL_BIN=${SRC_ROOT}/src/ptunnel-ng

TUNNEL_TIMEOUT=25
timeout --foreground -k1 ${TUNNEL_TIMEOUT} \
    valgrind --error-exitcode=1 --exit-on-first-error=yes \
    "${PTUNNEL_BIN}" -v4 -r127.0.0.1 -R3000 -l4000 >/tmp/ptunnel-server.log &
PTUNNEL_SERVER_PID=$!

timeout --foreground -k1 ${TUNNEL_TIMEOUT} \
    valgrind --error-exitcode=1 --exit-on-first-error=yes \
    "${PTUNNEL_BIN}" -v4 -p127.0.0.1 -r127.0.0.1 -R3000 -l4000 >/tmp/ptunnel-client.log &
PTUNNEL_CLIENT_PID=$!

timeout --foreground -k1 ${TUNNEL_TIMEOUT} \
    nc -l -p 3000 >/dev/null &
DATA_SERVER_PID=$!

sleep 3
DATA_TIMEOUT=20
timeout --foreground -k1 ${DATA_TIMEOUT} \
    sh -c "dd if=/dev/urandom bs=8192 | nc 127.0.0.1 4000" || true

wait ${PTUNNEL_SERVER_PID} || true
wait ${PTUNNEL_CLIENT_PID} || true
wait ${DATA_SERVER_PID} || true

printf 'done\n'