Commit 324e432c authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: get a test file name from arguments

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent abdaea24
...@@ -83,8 +83,6 @@ TST_NOFILE = \ ...@@ -83,8 +83,6 @@ TST_NOFILE = \
cow00 \ cow00 \
child_opened_proc \ child_opened_proc \
posix_timers \ posix_timers \
file_locks00 \
file_locks01 \
# jobctl00 \ # jobctl00 \
TST_FILE = \ TST_FILE = \
...@@ -114,6 +112,8 @@ TST_FILE = \ ...@@ -114,6 +112,8 @@ TST_FILE = \
fdt_shared \ fdt_shared \
sockets00 \ sockets00 \
sockets_dgram \ sockets_dgram \
file_locks00 \
file_locks01 \
TST_DIR = \ TST_DIR = \
cwd00 \ cwd00 \
......
...@@ -8,14 +8,18 @@ ...@@ -8,14 +8,18 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <string.h> #include <string.h>
#include <linux/limits.h>
#include "zdtmtst.h" #include "zdtmtst.h"
const char *test_doc = "Check that posix flocks are restored"; const char *test_doc = "Check that posix flocks are restored";
const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>";
char file0[] = "/tmp/zdtm_file_locks_XXXXXX"; char *filename;
char file1[] = "/tmp/zdtm_file_locks_XXXXXX"; TEST_OPTION(filename, string, "file name", 1);
char file0[PATH_MAX];
char file1[PATH_MAX];
static int lock_reg(int fd, int cmd, int type, int whence, static int lock_reg(int fd, int cmd, int type, int whence,
off_t offset, off_t len) off_t offset, off_t len)
...@@ -130,13 +134,15 @@ int main(int argc, char **argv) ...@@ -130,13 +134,15 @@ int main(int argc, char **argv)
test_init(argc, argv); test_init(argc, argv);
fd_0 = mkstemp(file0); snprintf(file0, sizeof(file0), "%s.0", filename);
snprintf(file1, sizeof(file0), "%s.1", filename);
fd_0 = open(file0, O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd_0 < 0) { if (fd_0 < 0) {
err("Unable to open file %s", file0); err("Unable to open file %s", file0);
return -1; return -1;
} }
fd_1 = mkstemp(file1); fd_1 = open(file1, O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd_1 < 0) { if (fd_1 < 0) {
close(fd_0); close(fd_0);
unlink(file0); unlink(file0);
......
...@@ -6,25 +6,32 @@ ...@@ -6,25 +6,32 @@
#include <unistd.h> #include <unistd.h>
#include <sys/file.h> #include <sys/file.h>
#include <string.h> #include <string.h>
#include <linux/limits.h>
#include "zdtmtst.h" #include "zdtmtst.h"
const char *test_doc = "Check that flock locks are restored"; const char *test_doc = "Check that flock locks are restored";
const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>"; const char *test_author = "Qiang Huang <h.huangqiang@huawei.com>";
char file0[] = "/tmp/zdtm_file_locks_XXXXXX"; char *filename;
char file1[] = "/tmp/zdtm_file_locks_XXXXXX"; TEST_OPTION(filename, string, "file name", 1);
char file2[] = "/tmp/zdtm_file_locks_XXXXXX";
char file0[PATH_MAX];
char file1[PATH_MAX];
char file2[PATH_MAX];
static int open_all_files(int *fd_0, int *fd_1, int *fd_2) static int open_all_files(int *fd_0, int *fd_1, int *fd_2)
{ {
*fd_0 = mkstemp(file0); snprintf(file0, sizeof(file0), "%s.0", filename);
snprintf(file1, sizeof(file0), "%s.1", filename);
snprintf(file2, sizeof(file0), "%s.2", filename);
*fd_0 = open(file0, O_RDWR | O_CREAT | O_EXCL, 0666);
if (*fd_0 < 0) { if (*fd_0 < 0) {
err("Unable to open file %s", file0); err("Unable to open file %s", file0);
return -1; return -1;
} }
*fd_1 = mkstemp(file1); *fd_1 = open(file1, O_RDWR | O_CREAT | O_EXCL, 0666);
if (*fd_1 < 0) { if (*fd_1 < 0) {
close(*fd_0); close(*fd_0);
unlink(file0); unlink(file0);
...@@ -32,7 +39,7 @@ static int open_all_files(int *fd_0, int *fd_1, int *fd_2) ...@@ -32,7 +39,7 @@ static int open_all_files(int *fd_0, int *fd_1, int *fd_2)
return -1; return -1;
} }
*fd_2 = mkstemp(file2); *fd_2 = open(file2, O_RDWR | O_CREAT | O_EXCL, 0666);
if (*fd_2 < 0) { if (*fd_2 < 0) {
close(*fd_0); close(*fd_0);
close(*fd_1); close(*fd_1);
......
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