diff --git a/test/.env b/test/.env index cc2a4047..6c0cfb3f 100644 --- a/test/.env +++ b/test/.env @@ -2,7 +2,7 @@ # shellcheck disable=SC2034,SC2154 # Current container image -INFIX_TEST=ghcr.io/kernelkit/infix-test:1.2 +INFIX_TEST=ghcr.io/kernelkit/infix-test:1.3 ixdir=$(readlink -f "$testdir/..") logdir=$(readlink -f "$testdir/.log") diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index d1993c59..c9cc3073 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -19,7 +19,13 @@ RUN apk add --no-cache \ socat \ squashfs-tools \ tcpdump \ - tshark + tshark \ + make + +ARG MTOOL_VERSION="3.0" +RUN wget https://github.com/troglobit/mtools/releases/download/v3.0/mtools-$MTOOL_VERSION.tar.gz -O /tmp/mtools-$MTOOL_VERSION.tar.gz +RUN cd /tmp/ && tar zxvf mtools-$MTOOL_VERSION.tar.gz +RUN cd /tmp/mtools-$MTOOL_VERSION && make && make install # Alpine's QEMU package does not bundle this for some reason, copied # from Ubuntu diff --git a/test/infamy/multicast.py b/test/infamy/multicast.py new file mode 100644 index 00000000..f7226e43 --- /dev/null +++ b/test/infamy/multicast.py @@ -0,0 +1,56 @@ +import time +import subprocess +import signal +import sys + +class MCastSender: + def __init__(self, netns,group): + self.group = group + self.netns = netns + + def __enter__(self): + cmd = f"msend -I iface -g {self.group}" + arg = cmd.split(" ") + + self.proc = self.netns.popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + def __exit__(self, _, __, ___): + if not self.proc: + return False + + sys.stdout.flush() + self.proc.send_signal(signal.SIGINT) + time.sleep(1) + if not self.proc.poll(): + try: + self.proc.kill() + except OSError: + pass + self.proc.wait() + +class MCastReceiver: + def __init__(self, netns, group): + self.group = group + self.netns = netns + + def __enter__(self): + cmd = f"mreceive -I iface -g {self.group}" + arg = cmd.split(" ") + + self.proc = self.netns.popen(arg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + def __exit__(self, _, __, ___): + if not self.proc: + return False + + sys.stdout.flush() + self.proc.send_signal(signal.SIGINT) + time.sleep(3) + if not self.proc.poll(): + print("PROC") + try: + self.proc.kill() + except OSError: + print("ERR") + pass + self.proc.wait()