@@ -52,13 +52,14 @@ static struct tcase {
static void run(unsigned int i)
{
+ int fd_testfile3 = -1;
/* tesfile2 will be unlinked by test0. */
if (access(testfile2, F_OK))
SAFE_FILE_PRINTF(testfile2, testfile2);
/* testfile3 will be unlined by test1. */
if (access(testfile3, F_OK))
- SAFE_OPEN(testfile3, O_CREAT | O_RDWR, 0600);
+ fd_testfile3 = SAFE_OPEN(testfile3, O_CREAT | O_RDWR, 0600);
/* subpathdir will be unlinked by test6. */
if (access(subpathdir, F_OK))
@@ -80,6 +81,8 @@ static void run(unsigned int i)
if (!tc[i].fd)
SAFE_CLOSE(fd);
+ if (fd_testfile3 > 0)
+ SAFE_CLOSE(fd_testfile3);
}
static void setup(void)
If we run the test with the option -i 10000, and the ulimit of open files little than 10000, the test would fail and report error of EMFILE. Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com> --- testcases/kernel/syscalls/unlinkat/unlinkat01.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.17.1