[CRIU] [RFC PATCHv2 18/32] zdtm: tests: make tests tolerant to slashes in filename arguments

Ivan Shapovalov intelfx at intelfx.name
Sat Mar 12 00:42:17 PST 2016


This is be needed to be able to launch tests from multiple directories in the
multi-test mode.

Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 test/zdtm/static/netns-nf.c      | 6 +++---
 test/zdtm/static/write_read02.c  | 2 +-
 test/zdtm/transition/file_read.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/zdtm/static/netns-nf.c b/test/zdtm/static/netns-nf.c
index 3e133b7..2bb0008 100644
--- a/test/zdtm/static/netns-nf.c
+++ b/test/zdtm/static/netns-nf.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
 		return -1;
 	}
 
-	sprintf(cmd, "iptables -L > pre-%s", filename);
+	sprintf(cmd, "iptables -L > %s.pre", filename);
 	if (system(cmd)) {
 		pr_perror("Can't save iptables");
 		return -1;
@@ -31,13 +31,13 @@ int main(int argc, char **argv)
 	test_daemon();
 	test_waitsig();
 
-	sprintf(cmd, "iptables -L > post-%s", filename);
+	sprintf(cmd, "iptables -L > %s.post", filename);
 	if (system(cmd)) {
 		fail("Can't get iptables");
 		return -1;
 	}
 
-	sprintf(cmd, "diff pre-%s post-%s", filename, filename);
+	sprintf(cmd, "diff %s.pre %s.post", filename, filename);
 	if (system(cmd)) {
 		fail("Iptables differ");
 		return -1;
diff --git a/test/zdtm/static/write_read02.c b/test/zdtm/static/write_read02.c
index b274465..8d8ffae 100644
--- a/test/zdtm/static/write_read02.c
+++ b/test/zdtm/static/write_read02.c
@@ -32,7 +32,7 @@ int main(int argc, char ** argv)
 
 	full_len = sizeof(buf);
 	// create standard file
-	sprintf(str, "standard_%s", filename);
+	sprintf(str, "%s.standard", filename);
 	fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (write(fd1, buf, full_len) != full_len) {
 		pr_perror("can't write %s", str);
diff --git a/test/zdtm/transition/file_read.c b/test/zdtm/transition/file_read.c
index 0e6a0bb..77abd77 100644
--- a/test/zdtm/transition/file_read.c
+++ b/test/zdtm/transition/file_read.c
@@ -126,7 +126,7 @@ static void chew_some_file(int num)
 	if (buf == MAP_FAILED)
 		goto out_exit;
 
-	sprintf(chew_file, "chew_%s.%d", filename, num);
+	sprintf(chew_file, "%s.chew.%d", filename, num);
 	fd = open(chew_file, O_CREAT | O_EXCL | O_RDWR, 0666);
 	rv = OPEN_FAILED;
 	if (fd == -1)
@@ -162,7 +162,7 @@ static void chew_some_file(int num)
 			int fd1;
 			char str[PATH_MAX];
 			// create standard file
-			sprintf(str, "standard_%s.%d", filename, num);
+			sprintf(str, "%s.standard.%d", filename, num);
 			fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 			if (write(fd1, buf, FILE_SIZE) != FILE_SIZE)
 				pr_perror("can't write %s", str);
-- 
2.7.2



More information about the CRIU mailing list