[CRIU] [crtools-bot] zdtm: Add utsname.c source code
Cyrill Gorcunov
gorcunov at openvz.org
Mon Jan 30 03:52:44 EST 2012
The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 25aa9e062caeff6360e422d3715f6174fdf943bc
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Mon Jan 30 12:52:44 2012 +0400
zdtm: Add utsname.c source code
I occasionally droppped this file but it's
a part of commit
dcd64e9d103ccf6b4c16a9c613fa371c99d0f5d2
So add it back.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
test/zdtm/live/static/utsname.c | 73 +++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/test/zdtm/live/static/utsname.c b/test/zdtm/live/static/utsname.c
new file mode 100644
index 0000000..a42f590
--- /dev/null
+++ b/test/zdtm/live/static/utsname.c
@@ -0,0 +1,73 @@
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check that utsname hasn't changed";
+const char *test_author = "Pavel Emelianov <xemul at parallels.com>";
+
+static struct utsname after;
+
+#define ZDTM_NODE "zdtm.nodename.ru"
+#define ZDTM_DOMAIN "zdtm.nodename.ru"
+
+static void test_fn(void)
+{
+ int ret;
+ int fd;
+
+ fd = open("/proc/sys/kernel/hostname", O_WRONLY);
+ if (fd < 0) {
+ err("Can't open hostname\n");
+ return;
+ }
+
+ ret = write(fd, ZDTM_NODE, sizeof(ZDTM_NODE));
+ if (ret != sizeof(ZDTM_NODE)) {
+ err("Can't write nodename\n");
+ return;
+ }
+
+ close(fd);
+
+ fd = open("/proc/sys/kernel/domainname", O_WRONLY);
+ if (fd < 0) {
+ err("Can't open domainname\n");
+ return;
+ }
+
+ ret = write(fd, ZDTM_DOMAIN, sizeof(ZDTM_DOMAIN));
+ if (ret != sizeof(ZDTM_DOMAIN)) {
+ err("Can't write domainname\n");
+ return;
+ }
+
+ close(fd);
+
+ test_daemon();
+ test_waitsig();
+
+ uname(&after);
+
+ ret = 1;
+
+ if (strcmp(ZDTM_NODE, after.nodename)) {
+ ret = 0;
+ fail("Nodename doesn't match");
+ }
+ if (strcmp(ZDTM_DOMAIN, after.__domainname)) {
+ ret = 0;
+ fail("Domainname doesn't match");
+ }
+
+ if (ret)
+ pass();
+}
+
+int main(int argc, char **argv)
+{
+ test_init_ns(argc, argv, CLONE_NEWUTS, test_fn);
+ return -1;
+}
More information about the CRIU
mailing list