[CRIU] [PATCH] zdtm: each test file name should contain a test name
Andrey Vagin
avagin at openvz.org
Mon Apr 1 11:19:02 EDT 2013
It's required for per-test cleaning.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/transition/Makefile | 4 ++--
test/zdtm/live/transition/file_read.c | 16 ++++++++++------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/test/zdtm/live/transition/Makefile b/test/zdtm/live/transition/Makefile
index b864780..d8e39d6 100644
--- a/test/zdtm/live/transition/Makefile
+++ b/test/zdtm/live/transition/Makefile
@@ -6,13 +6,13 @@ override CPPFLAGS += -I$(LIBDIR)
CFLAGS = -g -O2 -Wall -Werror
TST_NOFILE = \
- file_read \
ipc \
ptrace \
epoll \
fork \
TST_FILE = \
+ file_read \
TST = $(TST_NOFILE) $(TST_FILE)
SRC = $(TST:%=%.c)
@@ -74,7 +74,7 @@ cleandep: clean
$(RM) -f $(DEP)
%.cleanout: %
- $(RM) -f -r $<.pid $<.out* $<.test
+ $(RM) -f -r $<.pid $<.out* $<.test chew_$<.test*
cleanout:
$(RM) -f *.pid *.out* *.test chew*
diff --git a/test/zdtm/live/transition/file_read.c b/test/zdtm/live/transition/file_read.c
index 41f7dca..ffcf1cd 100644
--- a/test/zdtm/live/transition/file_read.c
+++ b/test/zdtm/live/transition/file_read.c
@@ -7,6 +7,7 @@
#include <sys/mman.h>
#include <string.h>
#include <errno.h>
+#include <linux/limits.h>
#include "zdtmtst.h"
@@ -44,6 +45,9 @@ static char *kids_fail_reasons[] = {
int scale = 13;
TEST_OPTION(scale, int, "How many children should perform testing", 0);
+char *filename;
+TEST_OPTION(filename, string, "file name", 1);
+
static int pids[MAX_SCALE];
static volatile int stop = 0;
@@ -113,8 +117,8 @@ static int check_file(int fd)
static void chew_some_file(int num)
{
- char filename[10];
int fd, rv;
+ char chew_file[PATH_MAX];
buf = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, 0, 0);
@@ -122,8 +126,8 @@ static void chew_some_file(int num)
if (buf == MAP_FAILED)
goto out_exit;
- sprintf(filename, "chew%d", num);
- fd = open(filename, O_CREAT | O_EXCL | O_RDWR, 0666);
+ sprintf(chew_file, "chew_%s.%d", filename, num);
+ fd = open(chew_file, O_CREAT | O_EXCL | O_RDWR, 0666);
rv = OPEN_FAILED;
if (fd == -1)
goto out_unmap;
@@ -156,9 +160,9 @@ static void chew_some_file(int num)
case 1:
rv = FILE_CORRUPTED;
int fd1;
- char str[32];
+ char str[PATH_MAX];
// create standard file
- sprintf(str, "standard_%s", filename);
+ sprintf(str, "standard_%s.%d", filename, num);
fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (write(fd1, buf, FILE_SIZE) != FILE_SIZE)
err("can't write %s: %m\n", str);
@@ -168,7 +172,7 @@ static void chew_some_file(int num)
}
rv = SUCCESS;
close(fd);
- unlink(filename);
+ unlink(chew_file);
out_unmap:
munmap(buf, FILE_SIZE);
out_exit:
--
1.7.11.7
More information about the CRIU
mailing list