mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
infamy: Add new class to test multicast
Depends on having mtools v3+ on test PC, so add it to the docker.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user