mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
tests: add a test for c/r of an empty bridge
v2: * add a zdtm.py .desc file * only look to make sure inet addresses match (in particular, don't match the state) Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
8a95be0679
commit
34f33bd7ba
@@ -200,6 +200,7 @@ generate_test_list()
|
|||||||
ns/static/sem
|
ns/static/sem
|
||||||
transition/ipc
|
transition/ipc
|
||||||
ns/static/netns-dev
|
ns/static/netns-dev
|
||||||
|
static/bridge
|
||||||
static/cgroup00
|
static/cgroup00
|
||||||
static/cgroup01
|
static/cgroup01
|
||||||
static/cgroup02
|
static/cgroup02
|
||||||
@@ -361,6 +362,7 @@ different_creds
|
|||||||
inotify01
|
inotify01
|
||||||
ipc_namespace
|
ipc_namespace
|
||||||
utsname
|
utsname
|
||||||
|
bridge
|
||||||
"
|
"
|
||||||
|
|
||||||
TEST_EXPECTED_FAILURE="
|
TEST_EXPECTED_FAILURE="
|
||||||
|
1
test/zdtm/.gitignore
vendored
1
test/zdtm/.gitignore
vendored
@@ -2,6 +2,7 @@
|
|||||||
/live/static/apparmor
|
/live/static/apparmor
|
||||||
/live/static/arm-neon00
|
/live/static/arm-neon00
|
||||||
/live/static/bind-mount
|
/live/static/bind-mount
|
||||||
|
/live/static/bridge
|
||||||
/live/static/busyloop00
|
/live/static/busyloop00
|
||||||
/live/static/caps00
|
/live/static/caps00
|
||||||
/live/static/cgroup00
|
/live/static/cgroup00
|
||||||
|
@@ -130,6 +130,7 @@ TST_NOFILE = \
|
|||||||
seccomp_strict \
|
seccomp_strict \
|
||||||
different_creds \
|
different_creds \
|
||||||
vsx \
|
vsx \
|
||||||
|
bridge \
|
||||||
# jobctl00 \
|
# jobctl00 \
|
||||||
|
|
||||||
TST_FILE = \
|
TST_FILE = \
|
||||||
|
84
test/zdtm/live/static/bridge.c
Normal file
84
test/zdtm/live/static/bridge.c
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <linux/limits.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "zdtmtst.h"
|
||||||
|
|
||||||
|
const char *test_doc = "check that empty bridges are c/r'd correctly";
|
||||||
|
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
|
||||||
|
|
||||||
|
#define BRIDGE_NAME "zdtmbr0"
|
||||||
|
|
||||||
|
int add_bridge(void)
|
||||||
|
{
|
||||||
|
if (system("brctl addbr " BRIDGE_NAME))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (system("ifconfig " BRIDGE_NAME " 10.0.55.55"))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (system("ifconfig " BRIDGE_NAME " up"))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int del_bridge(void)
|
||||||
|
{
|
||||||
|
/* don't check for errors, let's try to make sure it's deleted */
|
||||||
|
system("ifconfig " BRIDGE_NAME " down");
|
||||||
|
|
||||||
|
if (system("brctl delbr " BRIDGE_NAME))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
test_init(argc, argv);
|
||||||
|
|
||||||
|
if (add_bridge() < 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Here, we grep for inet because some of the IPV6 DAD stuff can be
|
||||||
|
* racy, and all we really care about is that the bridge got restored
|
||||||
|
* with the right MAC, since we know DAD will succeed eventually.
|
||||||
|
*
|
||||||
|
* (I got this race with zdtm.py, but not with zdtm.sh; not quite sure
|
||||||
|
* what the environment difference is/was.)
|
||||||
|
*/
|
||||||
|
if (system("ip addr list dev " BRIDGE_NAME " | grep inet > bridge.dump.test")) {
|
||||||
|
pr_perror("can't save net config");
|
||||||
|
fail("Can't save net config");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_daemon();
|
||||||
|
test_waitsig();
|
||||||
|
|
||||||
|
if (system("ip addr list dev " BRIDGE_NAME " | grep inet > bridge.rst.test")) {
|
||||||
|
fail("Can't get net config");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (system("diff bridge.rst.test bridge.dump.test")) {
|
||||||
|
fail("Net config differs after restore");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
pass();
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
del_bridge();
|
||||||
|
return ret;
|
||||||
|
}
|
1
test/zdtm/live/static/bridge.desc
Normal file
1
test/zdtm/live/static/bridge.desc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{'flavor': 'ns uns', 'deps': [ '/bin/sh', '/bin/grep', '/sbin/ip', '/sbin/brctl', '/sbin/ifconfig', '/usr/bin/diff'], 'flags': 'suid'}
|
Reference in New Issue
Block a user