Skip to content

Commit

Permalink
tmpdir: rename tst_tmpdir_mkpath to tst_tmpdir_genpath
Browse files Browse the repository at this point in the history
When I reviewed the rename15 patch I felt confused a while on
function like tst_tmpdir_mkpath (reminds me of: mkdir).

Because the name could be misleading since it suggests that a
file or directory is being created, when in fact it is simply
constructing a path inside a temporary directory without
actually creating any files.

To make the function's purpose clearer, the name should reflect
that it is only constructing or generating a path, not creating
any files or directories.

So I think either 'tst_tmpdir_genpath' or 'tst_tmpdir_buildpath'
would be concise and clear options.

Signed-off-by: Li Wang <[email protected]>
Acked-by: Jan Stancek <[email protected]>
Acked-by: Cyril Hrubis <[email protected]>
  • Loading branch information
wangli5665 committed Sep 12, 2024
1 parent c56f59c commit 0ae6bcc
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions include/tst_tmpdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void tst_purge_dir(const char *path);
char *tst_tmpdir_path(void);

/**
* tst_tmpdir_mkpath - Construct an absolute path pointing to a file inside tmpdir.
* tst_tmpdir_genpath - Construct an absolute path pointing to a file inside tmpdir.
*
* Constructs a path inside tmpdir i.e. adds a prefix pointing to the current
* test tmpdir to the string build by the printf-like format.
Expand All @@ -41,7 +41,7 @@ char *tst_tmpdir_path(void);
* of the test. If allocation fails the function calls tst_brk() and exits the
* test.
*/
char *tst_tmpdir_mkpath(const char *fmt, ...)
char *tst_tmpdir_genpath(const char *fmt, ...)
__attribute__((format(printf, 1, 2)));

/*
Expand Down
2 changes: 1 addition & 1 deletion lib/newlib_tests/tst_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void setup(void)
{
int fd;

mntpoint = tst_tmpdir_mkpath("mnt");
mntpoint = tst_tmpdir_genpath("mnt");

fd = SAFE_OPEN(tst_device->dev, O_RDONLY);

Expand Down
2 changes: 1 addition & 1 deletion lib/tst_tmpdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ char *tst_tmpdir_path(void)
return tmpdir;
}

char *tst_tmpdir_mkpath(const char *fmt, ...)
char *tst_tmpdir_genpath(const char *fmt, ...)
{
size_t testdir_len, path_len;
va_list va, vac;
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/faccessat/faccessat01.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void verify_faccessat(unsigned int i)

static void setup(void)
{
abs_path = tst_tmpdir_mkpath(FILEPATH);
abs_path = tst_tmpdir_genpath(FILEPATH);

SAFE_MKDIR(TESTDIR, 0700);
dir_fd = SAFE_OPEN(TESTDIR, O_DIRECTORY);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/faccessat2/faccessat201.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void verify_faccessat2(unsigned int i)

static void setup(void)
{
abs_path = tst_tmpdir_mkpath(RELPATH);
abs_path = tst_tmpdir_genpath(RELPATH);

SAFE_MKDIR(TESTDIR, 0777);
dir_fd = SAFE_OPEN(TESTDIR, O_DIRECTORY);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/fchmodat/fchmodat01.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void verify_fchmodat(unsigned int i)

static void setup(void)
{
abs_path = tst_tmpdir_mkpath(FILEPATH);
abs_path = tst_tmpdir_genpath(FILEPATH);

SAFE_MKDIR(TESTDIR, 0700);
dir_fd = SAFE_OPEN(TESTDIR, O_DIRECTORY);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_loop01.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void setup(void)
sprintf(autoclear_path, "/sys/block/loop%d/loop/autoclear", dev_num);
sprintf(backing_path, "/sys/block/loop%d/loop/backing_file", dev_num);
sprintf(sys_loop_partpath, "/sys/block/loop%d/loop%dp1", dev_num, dev_num);
backing_file_path = tst_tmpdir_mkpath("test.img");
backing_file_path = tst_tmpdir_genpath("test.img");
sprintf(loop_partpath, "%sp1", dev_path);
dev_fd = SAFE_OPEN(dev_path, O_RDWR);
}
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/syscalls/ioctl/ioctl_loop02.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ static void setup(void)
tst_fill_file("test2.img", 0, 2048, 20);

sprintf(backing_path, "/sys/block/loop%d/loop/backing_file", dev_num);
backing_file_path = tst_tmpdir_mkpath("test.img");
backing_file_change_path = tst_tmpdir_mkpath("test1.img");
backing_file_path = tst_tmpdir_genpath("test.img");
backing_file_change_path = tst_tmpdir_genpath("test1.img");
sprintf(loop_ro_path, "/sys/block/loop%d/ro", dev_num);

file_change_fd = SAFE_OPEN("test1.img", O_RDWR);
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/ioctl/ioctl_loop05.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void setup(void)
* size of loop is bigger than the backing device's and the loop
* needn't transform transfer.
*/
backing_file_path = tst_tmpdir_mkpath("test.img");
backing_file_path = tst_tmpdir_genpath("test.img");
tst_find_backing_dev(backing_file_path, bd_path, sizeof(bd_path));
block_devfd = SAFE_OPEN(bd_path, O_RDWR);
SAFE_IOCTL(block_devfd, BLKSSZGET, &logical_block_size);
Expand Down
8 changes: 4 additions & 4 deletions testcases/kernel/syscalls/mount/mount06.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ static void setup(void)
SAFE_MOUNT(tmppath, tmppath, "none", MS_BIND, NULL);
SAFE_MOUNT("none", tmppath, "none", MS_PRIVATE, NULL);

mntpoint_src = tst_tmpdir_mkpath(MNTPOINT_SRC);
mntpoint_dst = tst_tmpdir_mkpath(MNTPOINT_DST);
tstfiles_src = tst_tmpdir_mkpath("%s/testfile", MNTPOINT_SRC);
tstfiles_dst = tst_tmpdir_mkpath("%s/testfile", MNTPOINT_DST);
mntpoint_src = tst_tmpdir_genpath(MNTPOINT_SRC);
mntpoint_dst = tst_tmpdir_genpath(MNTPOINT_DST);
tstfiles_src = tst_tmpdir_genpath("%s/testfile", MNTPOINT_SRC);
tstfiles_dst = tst_tmpdir_genpath("%s/testfile", MNTPOINT_DST);

SAFE_MKDIR(mntpoint_dst, 0750);
}
Expand Down
6 changes: 3 additions & 3 deletions testcases/kernel/syscalls/mount/mount07.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ static void test_statfs(bool nosymfollow)

static void setup(void)
{
test_file = tst_tmpdir_mkpath("%s/test_file", MNTPOINT);
link_file = tst_tmpdir_mkpath("%s/link_file", MNTPOINT);
temp_link_file = tst_tmpdir_mkpath("%s/temp_link_file", MNTPOINT);
test_file = tst_tmpdir_genpath("%s/test_file", MNTPOINT);
link_file = tst_tmpdir_genpath("%s/link_file", MNTPOINT);
temp_link_file = tst_tmpdir_genpath("%s/temp_link_file", MNTPOINT);
}

static void cleanup(void)
Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/pathconf/pathconf02.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void setup(void)

SAFE_TOUCH("testfile", 0777, NULL);

abs_path = tst_tmpdir_mkpath(FILEPATH);
abs_path = tst_tmpdir_genpath(FILEPATH);

SAFE_CHMOD(tst_tmpdir_path(), 0);

Expand Down
2 changes: 1 addition & 1 deletion testcases/kernel/syscalls/readlinkat/readlinkat01.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void verify_readlinkat(unsigned int i)

static void setup(void)
{
abspath = tst_tmpdir_mkpath(TEST_SYMLINK);
abspath = tst_tmpdir_genpath(TEST_SYMLINK);

file_fd = SAFE_OPEN(TEST_FILE, O_CREAT, 0600);
SAFE_SYMLINK(TEST_FILE, TEST_SYMLINK);
Expand Down
4 changes: 2 additions & 2 deletions testcases/kernel/syscalls/stat/stat04.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ static void setup(void)
int pagesize;
int fd;

file_path = tst_tmpdir_mkpath(FILENAME);
symb_path = tst_tmpdir_mkpath(SYMBNAME);
file_path = tst_tmpdir_genpath(FILENAME);
symb_path = tst_tmpdir_genpath(SYMBNAME);

/* change st_blksize / st_dev */
SAFE_STAT(".", &sb);
Expand Down

0 comments on commit 0ae6bcc

Please sign in to comment.