[CRIU] [PATCH] zdtm: don't hardcode file names in test soruces

Andrey Vagin avagin at openvz.org
Tue Dec 22 00:39:06 PST 2015


Cc: Kirill Tkhai <ktkhai at odin.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/live/static/Makefile              | 2 +-
 test/zdtm/live/static/socket_close_data01.c | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 92a96b8..42eea67 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -36,7 +36,6 @@ TST_NOFILE	=				\
 		socket_udplite			\
 		socket_aio			\
 		socket_close_data		\
-		socket_close_data01		\
 		socket_snd_addr			\
 		socket_dgram_data		\
 		packet_sock			\
@@ -191,6 +190,7 @@ TST_FILE	=				\
 		file_locks05			\
 		netns-nf			\
 		maps_file_prot			\
+		socket_close_data01		\
 
 TST_DIR		=				\
 		cwd00				\
diff --git a/test/zdtm/live/static/socket_close_data01.c b/test/zdtm/live/static/socket_close_data01.c
index f1b7743..4ca5a08 100644
--- a/test/zdtm/live/static/socket_close_data01.c
+++ b/test/zdtm/live/static/socket_close_data01.c
@@ -13,7 +13,8 @@ const char *test_doc	= "Check data of bound socket and possibility to connect";
 const char *test_author	= "Kirill Tkhai <ktkhai at virtuozzo";
 
 #define MSG "hello"
-#define NAME "socket_close_data01.sock"
+char *filename;
+TEST_OPTION(filename, string, "file name", 1);
 
 static int client(const char *iter)
 {
@@ -27,7 +28,7 @@ static int client(const char *iter)
 	}
 
 	addr.sun_family = AF_UNIX;
-	strcpy(addr.sun_path, NAME);
+	strcpy(addr.sun_path, filename);
 
 	if (connect(sk, (void *)&addr, sizeof(struct sockaddr_un)) < 0) {
 		pr_perror("connect failed %s\n", iter);
@@ -57,7 +58,7 @@ int main(int argc, char **argv)
 	}
 
 	addr.sun_family = AF_UNIX;
-	strcpy(addr.sun_path, NAME);
+	strcpy(addr.sun_path, filename);
 
 	if (bind(srv, (struct sockaddr *) &addr, sizeof(struct sockaddr_un))) {
 		pr_perror("bind srv");
@@ -106,6 +107,6 @@ int main(int argc, char **argv)
 	ret = 0;
 	pass();
 unlink:
-	unlink(NAME);
+	unlink(filename);
 	return ret;
 }
-- 
2.4.3



More information about the CRIU mailing list