[CRIU] [PATCH] test: robustify mnt_tracefs test
Tycho Andersen
tycho.andersen at canonical.com
Thu Oct 13 09:49:45 PDT 2016
* make sure that tracefs is actually loaded, and try and access it after
restore
* don't mount debugfs in /, leaving an ugly directory in /test
* clean up the debugfs mount point (with a hook, since the test can't
unmount it due to perms)
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
test/zdtm/static/mnt_tracefs.c | 38 +++++++++++++++++++++++++++-----------
test/zdtm/static/mnt_tracefs.hook | 5 +++++
2 files changed, 32 insertions(+), 11 deletions(-)
create mode 100755 test/zdtm/static/mnt_tracefs.hook
diff --git a/test/zdtm/static/mnt_tracefs.c b/test/zdtm/static/mnt_tracefs.c
index 91d4585..968658b 100644
--- a/test/zdtm/static/mnt_tracefs.c
+++ b/test/zdtm/static/mnt_tracefs.c
@@ -19,15 +19,7 @@ TEST_OPTION(dirname, string, "directory name", 1);
int main(int argc, char ** argv)
{
- char dst[PATH_MAX], *root;
-
- root = getenv("ZDTM_ROOT");
- if (root == NULL) {
- pr_perror("root");
- return 1;
- }
-
- sprintf(dst, "%s/debugfs", getenv("ZDTM_ROOT"));
+ char dst[PATH_MAX];
if (strcmp(getenv("ZDTM_NEWNS"), "1"))
goto test;
@@ -37,21 +29,45 @@ int main(int argc, char ** argv)
return 1;
}
- mkdir(dst, 755);
+ sprintf(dst, "%s/%s", get_current_dir_name(), dirname);
+ if (mkdir(dst, 755) < 0) {
+ pr_perror("mkdir");
+ return 1;
+ }
+
if (mount("/sys/kernel/debug", dst, NULL, MS_BIND | MS_REC, NULL)) {
+ rmdir(dst);
pr_perror("mount");
return 1;
}
+ /* trigger the tracefs mount */
+ strcat(dst, "/tracing/README");
+ if (access(dst, F_OK) < 0) {
+ umount(dst);
+ rmdir(dst);
+ pr_perror("access");
+ return 1;
+ }
+
test:
test_init(argc, argv);
test_daemon();
test_waitsig();
+ sprintf(dst, "%s/%s/tracing/README", get_current_dir_name(), dirname);
- pass();
+ /* EACCES is what we expect, since users can't actually /see/ this
+ * filesystem, but CRIU needs to know how to remount it, so the restore
+ * should succeed
+ */
+ if (access(dst, F_OK) < 0 && errno != EACCES) {
+ fail("couldn't access tracefs at %s", dst);
+ return 1;
+ }
+ pass();
return 0;
}
diff --git a/test/zdtm/static/mnt_tracefs.hook b/test/zdtm/static/mnt_tracefs.hook
new file mode 100755
index 0000000..d57df0a
--- /dev/null
+++ b/test/zdtm/static/mnt_tracefs.hook
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+[ "$1" == "--clean" ] || exit 0
+
+rmdir zdtm/static/mnt_tracefs.test
--
2.7.4
More information about the CRIU
mailing list