diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-02-21 21:40:07 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-02-22 19:27:15 +0100 |
commit | a9e24d130d4f67417d9943b09764ad7b56a3ea83 (patch) | |
tree | 35356e8974317df7b7b0007342b3873f7051b5cc | |
parent | e66ce6f292be86851a7077ed8fe08e36ba46ea05 (diff) |
gitlab-ci: run at least a simple integration test
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | .gitlab-ci.yml | 59 | ||||
-rwxr-xr-x | test/integration_test.sh | 42 |
2 files changed, 81 insertions, 20 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6993f34..9b8e378 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ before_script: - test ! -r /etc/debian_version || apt-get install -y git debhelper dpkg-dev build-essential fakeroot flawfinder wget unzip - test ! -r /etc/debian_version || apt-get install -y libpcap-dev libselinux1-dev - test ! -r /etc/debian_version || apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64 mingw-w64-i686-dev mingw-w64-common clang - - test ! -r /etc/debian_version || apt-get install -y valgrind sudo + - test ! -r /etc/debian_version || apt-get install -y valgrind sudo netcat-openbsd - test ! -r /etc/debian_version || apt-get install -y autoconf automake dh-autoreconf - test ! -r /etc/arch-release || pacman -Syu --noconfirm - test ! -r /etc/arch-release || pacman -S --noconfirm binutils gcc base-devel git @@ -20,6 +20,7 @@ build: script: - autoreconf -fi - ./configure --enable-option-checking=fatal --prefix=/ + - mv config.log deploy/config-default.log - make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/gcc)" V=s - make dist - cp ptunnel-ng-*.tar.gz ./deploy/ @@ -27,28 +28,31 @@ build: artifacts: paths: - deploy/ - - config.log when: always build-sanitizer-asserts: script: - autoreconf -fi - ./configure --enable-option-checking=fatal --prefix=/ --enable-sanitizer --enable-asserts + - mv config.log deploy/config-sanitizer-assert.log - make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/gcc-sanitizer-asserts)" V=s stage: build artifacts: paths: - deploy/ - - config.log when: always build-debian: script: - dpkg-buildpackage -b -us -uc + - mv config.log deploy/config-debian.log + - ls -alh .. + - mkdir -p deploy/debian + - mv -v ../ptunnel-ng-dbgsym_* ../ptunnel-ng_* deploy/debian/ stage: build artifacts: paths: - - config.log + - deploy/ when: always build-archlinux: @@ -59,32 +63,40 @@ build-archlinux: - chown -R builduser . - su -m builduser bash -c 'makepkg' - su -m builduser bash -c 'makepkg -p PKGBUILD.dev --skipchecksums' + - ls -alh . + - mkdir deploy/archlinux + - mv -v ptunnel-ng-*.tar.xz deploy/archlinux/ stage: build + artifacts: + paths: + - deploy/ + when: always build-mingw: script: - autoreconf -fi - ./configure --enable-option-checking=fatal --prefix=/ --host=i686-w64-mingw32 + - mv config.log deploy/config-mingw-i686.log - make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/i686-w64-mingw32-winpcap)" V=s - ./configure --enable-option-checking=fatal --prefix=/ --host=i686-w64-mingw32 --enable-npcap + - mv config.log deploy/config-mingw-i686-npcap.log - make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/i686-w64-mingw32-npcap)" V=s stage: build artifacts: paths: - deploy/ - - config.log when: always build-clang: script: - autoreconf -fi - CC=clang ./configure --enable-option-checking=fatal --prefix=/ + - mv config.log deploy/config-clang.log - make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/clang)" V=s stage: build artifacts: paths: - deploy/ - - config.log when: always build-android: @@ -99,20 +111,45 @@ build-android: - cd .. - autoreconf -fi - CC=aarch64-linux-android28-clang PATH="${PATH}:$(realpath ./vendor/android-ndk-r19/toolchains/llvm/prebuilt/linux-x86_64/bin)" ./configure --enable-option-checking=fatal --host=aarch64-linux-android + - mv config.log deploy/config-aarch64-linux-android28-clang.log - PATH="${PATH}:$(realpath ./vendor/android-ndk-r19/toolchains/llvm/prebuilt/linux-x86_64/bin)" make install CFLAGS='-Werror' DESTDIR="$(realpath ./deploy/android28-clang)" V=s stage: build artifacts: paths: - deploy/ - - config.log when: always -test-debian: +test-valgrind: script: - - /bin/true + - ls -alhR . + - deploy/gcc/bin/ptunnel-ng --help + - deploy/gcc-sanitizer-asserts/bin/ptunnel-ng --help + - PTUNNEL_BIN="deploy/gcc/bin/ptunnel-ng" test/integration_test.sh + - mv /tmp/ptunnel-client.log ptunnel-client-valgrind.log + - mv /tmp/ptunnel-server.log ptunnel-server-valgrind.log stage: test + artifacts: + paths: + - deploy/ + - ptunnel-client-valgrind.log + - ptunnel-server-valgrind.log + when: always -test-archlinux: +test-asan: script: - - /bin/true + - ls -alhR . + - export DISABLE_VALGRIND=y && export PTUNNEL_BIN="deploy/gcc-sanitizer-asserts/bin/ptunnel-ng" && test/integration_test.sh + - mv /tmp/ptunnel-client.log ptunnel-client-sanitizer.log + - mv /tmp/ptunnel-server.log ptunnel-server-sanitizer.log + - export DISABLE_VALGRIND=y && export PTUNNEL_BIN="deploy/gcc-sanitizer-asserts/bin/ptunnel-ng" && export PTUNNEL_ARGS="--passwd=ci" && test/integration_test.sh + - mv /tmp/ptunnel-client.log ptunnel-client-sanitizer-passwd.log + - mv /tmp/ptunnel-server.log ptunnel-server-sanitizer-passwd.log stage: test + artifacts: + paths: + - deploy/ + - ptunnel-client-sanitizer.log + - ptunnel-server-sanitizer.log + - ptunnel-client-sanitizer-passwd.log + - ptunnel-server-sanitizer-passwd.log + when: always diff --git a/test/integration_test.sh b/test/integration_test.sh index 165436e..1708216 100755 --- a/test/integration_test.sh +++ b/test/integration_test.sh @@ -6,30 +6,54 @@ set -o pipefail SRC_ROOT=$(realpath $(dirname $0)/..) -PTUNNEL_BIN=${SRC_ROOT}/src/ptunnel-ng +PTUNNEL_BIN=${PTUNNEL_BIN:-${SRC_ROOT}/src/ptunnel-ng} +PTUNNEL_ARGS="${PTUNNEL_ARGS:-}" +VALGRIND_BIN=${VALGRIND_BIN:-valgrind} +VALGRIND_ARGS="--error-exitcode=1 --exit-on-first-error=yes" +if [ "x${DISABLE_VALGRIND}" = xy ]; then + VALGRIND_BIN="" + VALGRIND_ARGS="" +fi + +test -x "${PTUNNEL_BIN}" TUNNEL_TIMEOUT=25 +DATA_TIMEOUT=22 + +echo -n >/tmp/ptunnel-server.log +echo -n >/tmp/ptunnel-client.log + 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 & + ${VALGRIND_BIN} ${VALGRIND_ARGS} \ + "${PTUNNEL_BIN}" -v4 -r127.0.0.1 -R3000 -l4000 ${PTUNNEL_ARGS} -o/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 & + ${VALGRIND_BIN} ${VALGRIND_ARGS} \ + "${PTUNNEL_BIN}" -v4 -p127.0.0.1 -r127.0.0.1 -R3000 -l4000 ${PTUNNEL_ARGS} -o/tmp/ptunnel-client.log & PTUNNEL_CLIENT_PID=$! -timeout --foreground -k1 ${TUNNEL_TIMEOUT} \ - nc -l -p 3000 >/dev/null & +timeout --foreground -k1 ${DATA_TIMEOUT} \ + nc -l -p 3000 >/dev/null || true & 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 ${PTUNNEL_SERVER_PID} || true wait ${DATA_SERVER_PID} || true +cat /tmp/ptunnel-client.log +cat /tmp/ptunnel-server.log + +cat /tmp/ptunnel-client.log |& grep 'Incoming connection.' +cat /tmp/ptunnel-server.log |& grep 'Starting new session to 127.0.0.1:3000' + +CLIENT_ACK_SERIES=$(cat /tmp/ptunnel-client.log |& grep 'Received ack-series starting at seq' | wc -l) +SERVER_ACK_SERIES=$(cat /tmp/ptunnel-server.log |& grep 'Received ack-series starting at seq' | \ + grep -v 'Received ack-series starting at seq 65535' | wc -l) +test ${CLIENT_ACK_SERIES} -eq ${SERVER_ACK_SERIES} + printf 'done\n' |