Commit 9d417188 authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Test --external veth option (v5)

Inspired by Tycho's macvlan test, here's the same thing for
--external veth option. In master we still have the --veth-pair
one, but the plan is to move this all under the --external opt.

v2:
* Travis doesn't have /usr/bin/sed
* Added .checkskip hook for older environments

v3:
* Delete bridge hanging around after previous flavor
* Wait for host veth end to die after dump

v4:
* Get the pid of task to move veth into from .pid.inprogress file

v5:
* Wait for host veth end to die after test stop too :\

Travised-by: https://travis-ci.org/xemul/criu/builds/170726663Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent f58eb91d
...@@ -995,6 +995,7 @@ def cr(cr_api, test, opts): ...@@ -995,6 +995,7 @@ def cr(cr_api, test, opts):
sbs('pre-restore') sbs('pre-restore')
try_run_hook(test, ["--pre-restore"]) try_run_hook(test, ["--pre-restore"])
cr_api.restore() cr_api.restore()
try_run_hook(test, ["--post-restore"])
sbs('post-restore') sbs('post-restore')
time.sleep(iters[1]) time.sleep(iters[1])
......
...@@ -10,3 +10,4 @@ ...@@ -10,3 +10,4 @@
*.inprogress *.inprogress
*.test *.test
*.test.* *.test.*
*.state
...@@ -153,6 +153,7 @@ TST_NOFILE := \ ...@@ -153,6 +153,7 @@ TST_NOFILE := \
helper_zombie_child \ helper_zombie_child \
clone_fs \ clone_fs \
macvlan \ macvlan \
cr_veth \
# jobctl00 \ # jobctl00 \
ifneq ($(SRCARCH),arm) ifneq ($(SRCARCH),arm)
......
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <linux/limits.h>
#include <signal.h>
#include <arpa/inet.h>
#include <net/if.h>
#include "zdtmtst.h"
const char *test_doc = "check that veth C/R-s right";
const char *test_author = "Pavel Emelyanov <xemul@virtuozzo.com>";
#define IF_NAME "zdtmvthc0"
static bool wait_for_veth(void)
{
int i;
for (i = 0; i < 10; i++) {
if (system("ip addr list dev " IF_NAME) == 0)
return true;
sleep(1);
}
return false;
}
int main(int argc, char **argv)
{
int ret = 1;
test_init(argc, argv);
if (!wait_for_veth()) {
fail("failed to inject veth device\n");
return 1;
}
if (system("ip addr list dev " IF_NAME " | sed -e 's/@.*://' > cr_veth.dump.state")) {
fail("can't save net config");
goto out;
}
test_daemon();
test_waitsig();
if (system("ip addr list dev " IF_NAME " | sed -e 's/@.*://' > cr_veth.rst.state")) {
fail("can't get net config");
goto out;
}
if (system("diff cr_veth.rst.state cr_veth.dump.state")) {
fail("Net config differs after restore");
goto out;
}
pass();
ret = 0;
out:
return ret;
}
#!/bin/bash
unshare --net ip link add type veth
{'flavor': 'ns uns', 'deps': [ '/bin/sh', '/bin/sed', '/bin/grep', '/sbin/ip', '/usr/bin/diff'], 'flags': 'suid', 'ropts': '--external veth[zdtmvthc0]:zdtmvthh0@zdtmbr0'}
#!/bin/bash
if [ "$1" == "--post-start" ]; then
set -e
PIDF="zdtm/static/cr_veth.pid.inprogress"
while [ ! -f "$PIDF" ]; do
sleep ".1"
done
TPID=$(cat $PIDF)
ps xaf
echo "-> $TPID"
ip link add zdtmvthc0 type veth peer name zdtmvthh0
ip link set zdtmvthc0 netns $TPID
ip link del zdtmbr0 || true # Ignore the failure
ip link add zdtmbr0 type bridge
ip link set zdtmbr0 up
ip link set zdtmvthh0 master zdtmbr0
elif [ "$1" == "--post-restore" ]; then
ip link list zdtmvthh0
if ! ip link list zdtmvthh0 | fgrep -q 'master zdtmbr0'; then
echo "Device missing or not in bridge"
exit 1
fi
echo "Device OK"
elif [ "$1" == "--pre-restore" -o "$1" == "--cleanup" ]; then
# Wait for the link to die
while ip l l zdtmvthh0 ; do
true
done
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment