Commit 34f33bd7 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

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: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8a95be06
......@@ -200,6 +200,7 @@ generate_test_list()
ns/static/sem
transition/ipc
ns/static/netns-dev
static/bridge
static/cgroup00
static/cgroup01
static/cgroup02
......@@ -361,6 +362,7 @@ different_creds
inotify01
ipc_namespace
utsname
bridge
"
TEST_EXPECTED_FAILURE="
......
......@@ -2,6 +2,7 @@
/live/static/apparmor
/live/static/arm-neon00
/live/static/bind-mount
/live/static/bridge
/live/static/busyloop00
/live/static/caps00
/live/static/cgroup00
......
......@@ -130,6 +130,7 @@ TST_NOFILE = \
seccomp_strict \
different_creds \
vsx \
bridge \
# jobctl00 \
TST_FILE = \
......
#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;
}
{'flavor': 'ns uns', 'deps': [ '/bin/sh', '/bin/grep', '/sbin/ip', '/sbin/brctl', '/sbin/ifconfig', '/usr/bin/diff'], 'flags': 'suid'}
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