[CRIU] [RFC PATCHv2 19/32] zdtm: static/{bridge, netns}: support running from another cwd
Ivan Shapovalov
intelfx at intelfx.name
Sat Mar 12 00:42:18 PST 2016
Pass dump file prefix as argument (cwd-compensated via the Makefiles) instead
of hardcoding the test to dump its data into the current working directory.
Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
test/zdtm/static/Makefile | 4 ++--
test/zdtm/static/bridge.c | 14 +++++++++++---
test/zdtm/static/netns.c | 15 +++++++++++----
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 9af625c..97898ec 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -98,7 +98,6 @@ TST_NOFILE = \
tty03 \
poll \
mountpoints \
- netns \
netns-dev \
session01 \
session02 \
@@ -136,7 +135,6 @@ TST_NOFILE = \
seccomp_filter_inheritance \
different_creds \
vsx \
- bridge \
vfork00 \
oom_score_adj \
loginuid \
@@ -189,6 +187,8 @@ TST_FILE = \
socket_close_data01 \
chroot \
chroot-file \
+ bridge \
+ netns \
TST_DIR = \
cwd00 \
diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c
index 983c262..e1beef8 100644
--- a/test/zdtm/static/bridge.c
+++ b/test/zdtm/static/bridge.c
@@ -15,6 +15,9 @@
const char *test_doc = "check that empty bridges are c/r'd correctly";
const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+static char *filename;
+TEST_OPTION(filename, string, "dump file name prefix", 1);
+
#define BRIDGE_NAME "zdtmbr0"
int add_bridge(void)
@@ -51,6 +54,7 @@ int main(int argc, char **argv)
int ret = 1;
struct sockaddr_in6 addr;
int sk;
+ char buf[1024];
test_init(argc, argv);
@@ -84,7 +88,9 @@ int main(int argc, char **argv)
* (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 | sort > bridge.dump.test")) {
+
+ sprintf(buf, "ip addr list dev " BRIDGE_NAME " | grep inet | sort > %s.dump", filename);
+ if (system(buf)) {
pr_perror("can't save net config");
fail("Can't save net config");
goto out;
@@ -93,12 +99,14 @@ int main(int argc, char **argv)
test_daemon();
test_waitsig();
- if (system("ip addr list dev " BRIDGE_NAME " | grep inet | sort > bridge.rst.test")) {
+ sprintf(buf, "ip addr list dev " BRIDGE_NAME " | grep inet | sort > %s.rst", filename);
+ if (system(buf)) {
fail("Can't get net config");
goto out;
}
- if (system("diff bridge.rst.test bridge.dump.test")) {
+ sprintf(buf, "diff %s.rst %s.dump", filename, filename);
+ if (system(buf)) {
fail("Net config differs after restore");
goto out;
}
diff --git a/test/zdtm/static/netns.c b/test/zdtm/static/netns.c
index b7a75b6..fc0e47d 100644
--- a/test/zdtm/static/netns.c
+++ b/test/zdtm/static/netns.c
@@ -7,8 +7,13 @@
const char *test_doc = "Check that network environment (links, addresses and routes) are preserved";
const char *test_author = "Pavel Emelianov <xemul at parallels.com>";
+static char *filename;
+TEST_OPTION(filename, string, "dump file name prefix", 1);
+
int main(int argc, char **argv)
{
+ char buf[1024];
+
test_init(argc, argv);
if (system("ip link set lo up")) {
@@ -31,8 +36,8 @@ int main(int argc, char **argv)
return -1;
}
- if (system("ip link > netns.dump.test && ip addr >> netns.dump.test && ip route >> netns.dump.test")) {
- sleep(1000);
+ sprintf(buf, "{ ip link; ip addr; ip route; } > %s.dump", filename);
+ if (system(buf)) {
fail("Can't save net config");
return -1;
}
@@ -40,12 +45,14 @@ int main(int argc, char **argv)
test_daemon();
test_waitsig();
- if (system("ip link > netns.rst.test && ip addr >> netns.rst.test && ip route >> netns.rst.test")) {
+ sprintf(buf, "{ ip link; ip addr; ip route; } > %s.rst", filename);
+ if (system(buf)) {
fail("Can't get net config");
return -1;
}
- if (system("diff netns.rst.test netns.dump.test")) {
+ sprintf(buf, "diff %s.rst %s.dump", filename, filename);
+ if (system(buf)) {
fail("Net config differs after restore");
return -1;
}
--
2.7.2
More information about the CRIU
mailing list