Commit 58f0955d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: each test file name should contain a test name

It's required for per-test cleaning.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2020d395
...@@ -6,13 +6,13 @@ override CPPFLAGS += -I$(LIBDIR) ...@@ -6,13 +6,13 @@ override CPPFLAGS += -I$(LIBDIR)
CFLAGS = -g -O2 -Wall -Werror CFLAGS = -g -O2 -Wall -Werror
TST_NOFILE = \ TST_NOFILE = \
file_read \
ipc \ ipc \
ptrace \ ptrace \
epoll \ epoll \
fork \ fork \
TST_FILE = \ TST_FILE = \
file_read \
TST = $(TST_NOFILE) $(TST_FILE) TST = $(TST_NOFILE) $(TST_FILE)
SRC = $(TST:%=%.c) SRC = $(TST:%=%.c)
...@@ -74,7 +74,7 @@ cleandep: clean ...@@ -74,7 +74,7 @@ cleandep: clean
$(RM) -f $(DEP) $(RM) -f $(DEP)
%.cleanout: % %.cleanout: %
$(RM) -f -r $<.pid $<.out* $<.test $(RM) -f -r $<.pid $<.out* $<.test chew_$<.test*
cleanout: cleanout:
$(RM) -f *.pid *.out* *.test chew* $(RM) -f *.pid *.out* *.test chew*
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <linux/limits.h>
#include "zdtmtst.h" #include "zdtmtst.h"
...@@ -44,6 +45,9 @@ static char *kids_fail_reasons[] = { ...@@ -44,6 +45,9 @@ static char *kids_fail_reasons[] = {
int scale = 13; int scale = 13;
TEST_OPTION(scale, int, "How many children should perform testing", 0); 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 int pids[MAX_SCALE];
static volatile int stop = 0; static volatile int stop = 0;
...@@ -113,8 +117,8 @@ static int check_file(int fd) ...@@ -113,8 +117,8 @@ static int check_file(int fd)
static void chew_some_file(int num) static void chew_some_file(int num)
{ {
char filename[10];
int fd, rv; int fd, rv;
char chew_file[PATH_MAX];
buf = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE, buf = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, 0, 0); MAP_PRIVATE | MAP_ANON, 0, 0);
...@@ -122,8 +126,8 @@ static void chew_some_file(int num) ...@@ -122,8 +126,8 @@ static void chew_some_file(int num)
if (buf == MAP_FAILED) if (buf == MAP_FAILED)
goto out_exit; goto out_exit;
sprintf(filename, "chew%d", num); sprintf(chew_file, "chew_%s.%d", filename, num);
fd = open(filename, O_CREAT | O_EXCL | O_RDWR, 0666); fd = open(chew_file, O_CREAT | O_EXCL | O_RDWR, 0666);
rv = OPEN_FAILED; rv = OPEN_FAILED;
if (fd == -1) if (fd == -1)
goto out_unmap; goto out_unmap;
...@@ -156,9 +160,9 @@ static void chew_some_file(int num) ...@@ -156,9 +160,9 @@ static void chew_some_file(int num)
case 1: case 1:
rv = FILE_CORRUPTED; rv = FILE_CORRUPTED;
int fd1; int fd1;
char str[32]; char str[PATH_MAX];
// create standard file // 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); fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (write(fd1, buf, FILE_SIZE) != FILE_SIZE) if (write(fd1, buf, FILE_SIZE) != FILE_SIZE)
err("can't write %s: %m\n", str); err("can't write %s: %m\n", str);
...@@ -168,7 +172,7 @@ static void chew_some_file(int num) ...@@ -168,7 +172,7 @@ static void chew_some_file(int num)
} }
rv = SUCCESS; rv = SUCCESS;
close(fd); close(fd);
unlink(filename); unlink(chew_file);
out_unmap: out_unmap:
munmap(buf, FILE_SIZE); munmap(buf, FILE_SIZE);
out_exit: out_exit:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment