[CRIU] [PATCH] zdtm: Custom file names in binfmt_misc test

Kirill Tkhai ktkhai at virtuozzo.com
Thu Apr 21 22:43:38 PDT 2016


If several copies of binfmt_misc test are running, we may fail because of duplicate names.
Fix that by giving a custom name for registered /proc/sys/fs/binfmt_misc/xxx.

################## Test zdtm/static/binfmt_misc FAIL at start ##################
Test output: ================================
18:03:33.594: 4: string: :magic_file:M:9:\x73\x51\xff\x4a\xec\x29\xcd\xba\xab\xf2::/bin/interpreter:OCP
18:03:33.594: 4: FAIL: binfmt_misc.c:133: write magic_file (errno = 22 (Invalid argument))
18:03:33.594: 3: ERR: test.c:204: Test exited unexpectedly with code 1

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 test/zdtm/static/Makefile      |    4 ++--
 test/zdtm/static/binfmt_misc.c |    7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index d4a2978..42fcf81 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -230,12 +230,12 @@ TST_DIR		=				\
 		mnt_ext_auto			\
 		mnt_ext_master			\
 		mntns_deleted			\
-		binfmt_misc			\
 		unlink_regular00		\
 
 TST_DIR_FILE	=				\
 		chroot				\
-		chroot-file
+		chroot-file			\
+		binfmt_misc			\
 
 TST		=				\
 		$(TST_NOFILE)			\
diff --git a/test/zdtm/static/binfmt_misc.c b/test/zdtm/static/binfmt_misc.c
index 9d7394c..62b9b51 100644
--- a/test/zdtm/static/binfmt_misc.c
+++ b/test/zdtm/static/binfmt_misc.c
@@ -19,8 +19,10 @@ const char *test_author	= "Kirill Tkhai <ktkhai at odin.com";
 
 char *dirname = "binfmt_misc.dir";
 TEST_OPTION(dirname, string, "binfmt_misc mount directory name", 1);
+char *filename;
+TEST_OPTION(filename, string, "file name prefix (prefix_magic, prefix, extention)", 1);
 
-const char *NAME[2] = { "magic_file", "extension_file" };
+char NAME[2][PATH_MAX];
 
 /* :name:type:offset:magic:mask:interpreter:flags */
 
@@ -102,6 +104,9 @@ int main(int argc, char **argv)
 
 	test_init(argc, argv);
 
+	snprintf(NAME[0], PATH_MAX, "%s_magic", filename);
+	snprintf(NAME[1], PATH_MAX, "%s_extention", filename);
+
 	if (mkdir(dirname, 0777)) {
 		fail("mkdir");
 		exit(1);



More information about the CRIU mailing list