From 3b09ef1351d865c0b2519e1486f6c88db3905780 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 12 May 2017 16:56:13 +0200 Subject: [PATCH] test: fd_install events --- tests/Dockerfile | 2 +- tests/test.sh | 52 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/tests/Dockerfile b/tests/Dockerfile index b5590c4b..3e4d5d07 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,6 +1,6 @@ FROM fedora:25 -RUN dnf install -y iproute make nmap-ncat procps-ng golang +RUN dnf install -y iproute make nmap-ncat procps-ng golang busybox RUN mkdir -p /go diff --git a/tests/test.sh b/tests/test.sh index fd60034f..c33bac83 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -10,16 +10,21 @@ fi readonly dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly tracer="${dir}/tracer" readonly port=61111 +readonly port2=61112 readonly netns=$(mktemp /tmp/tcptracer-bpf-test-netns-XXXXXXXX) readonly tracer_output=$(mktemp /tmp/tcptracer-bpf-test-stdout-XXXXXXXX) exec 3<> <(tail --pid "$$" -f "${tracer_output}") server_pid=-1 +server2_pid=-1 tracer_pid=-1 function shutdown() { if [[ $server_pid -ne -1 ]]; then kill $server_pid 2>/dev/null || true fi + if [[ $server2_pid -ne -1 ]]; then + kill $server2_pid 2>/dev/null || true + fi if [[ $tracer_pid -ne -1 ]]; then kill $tracer_pid 2>/dev/null || true fi @@ -31,8 +36,18 @@ function shutdown() { trap shutdown EXIT +uname -r + unshare --net="${netns}" ip link set lo up -nsenter --net="${netns}" "${tracer}" >&3 & + +# start a process in the accept syscall to test +# https://github.com/weaveworks/tcptracer-bpf/issues/10 +nsenter --net="${netns}" busybox nc -l -p "${port2}" &3 & tracer_pid=$! sleep 1 # wait for tracer to load @@ -44,25 +59,44 @@ ps -p "$tracer_pid" >/dev/null # https://github.com/weaveworks/tcptracer-bpf/issues/21 nsenter --net="${netns}" ./multiple_connections_refused.sh "1200" -nsenter --net="${netns}" nc -l "${port}" & +nsenter --net="${netns}" nc -l "${port}"