[CRIU] [PATCH 1/2] add a tracefs test
Tycho Andersen
tycho.andersen at canonical.com
Fri May 20 10:54:45 PDT 2016
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
test/zdtm/.gitignore | 1 +
test/zdtm/static/Makefile | 1 +
test/zdtm/static/mnt_tracefs.c | 64 ++++++++++++++++++++++++++++++++++
test/zdtm/static/mnt_tracefs.checkskip | 5 +++
test/zdtm/static/mnt_tracefs.desc | 1 +
5 files changed, 72 insertions(+)
create mode 100644 test/zdtm/static/mnt_tracefs.c
create mode 100755 test/zdtm/static/mnt_tracefs.checkskip
create mode 100644 test/zdtm/static/mnt_tracefs.desc
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 2e2ac2b..3c803ae 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -72,6 +72,7 @@
/static/mmx00
/static/mnt_ext_auto
/static/mnt_ext_master
+/static/mnt_tracefs
/static/mnt_ro_bind
/static/mntns_deleted
/static/mntns_link_ghost
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index c6b2cbc..5fa1d74 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -236,6 +236,7 @@ TST_DIR = \
mnt_ext_auto \
mnt_ext_master \
mnt_ext_dev \
+ mnt_tracefs \
mntns_deleted \
unlink_regular00 \
autofs \
diff --git a/test/zdtm/static/mnt_tracefs.c b/test/zdtm/static/mnt_tracefs.c
new file mode 100644
index 0000000..55a7d64
--- /dev/null
+++ b/test/zdtm/static/mnt_tracefs.c
@@ -0,0 +1,64 @@
+#include <sys/mount.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Test c/r of tracefs";
+const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+
+char *dirname = "mnt_tracefs.test";
+TEST_OPTION(dirname, string, "directory name", 1);
+
+int main(int argc, char ** argv)
+{
+ char dst[PATH_MAX], *root;
+ int status;
+ pid_t pid;
+
+ root = getenv("ZDTM_ROOT");
+ if (root == NULL) {
+ pr_perror("root");
+ return 1;
+ }
+
+ sprintf(dst, "%s/debugfs", getenv("ZDTM_ROOT"));
+
+ if (strcmp(getenv("ZDTM_NEWNS"), "1"))
+ goto test;
+
+ pid = fork();
+ if (pid < 0)
+ return 1;
+ if (pid == 0) {
+ test_ext_init(argc, argv);
+
+ mkdir(dst, 755);
+ if (mount("/sys/kernel/debug", dst, NULL, MS_BIND, NULL)) {
+ pr_perror("mount");
+ return 1;
+ }
+ return 0;
+ }
+
+ wait(&status);
+ if (status != 0)
+ return 1;
+
+test:
+ test_init(argc, argv);
+
+ test_daemon();
+ test_waitsig();
+
+
+ pass();
+
+ return 0;
+}
+
diff --git a/test/zdtm/static/mnt_tracefs.checkskip b/test/zdtm/static/mnt_tracefs.checkskip
new file mode 100755
index 0000000..0c20ec6
--- /dev/null
+++ b/test/zdtm/static/mnt_tracefs.checkskip
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# tracefs is automatically mounted under debugfs if the kernel has it, so we
+# just need to check for a file in the tracing directory.
+test -f /sys/kernel/debug/tracing/README || exit 1
diff --git a/test/zdtm/static/mnt_tracefs.desc b/test/zdtm/static/mnt_tracefs.desc
new file mode 100644
index 0000000..48ca743
--- /dev/null
+++ b/test/zdtm/static/mnt_tracefs.desc
@@ -0,0 +1 @@
+{'flavor': 'uns', 'feature': 'mnt_id', 'opts': '--ext-mount-map auto --enable-external-masters'}
--
2.7.4
More information about the CRIU
mailing list