* [LTP] [PATCH v2 0/2] pipe07: close /proc/self/fd after counting fds
@ 2023-10-02 17:34 Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 1/2] " Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes Edward Liaw via ltp
0 siblings, 2 replies; 4+ messages in thread
From: Edward Liaw via ltp @ 2023-10-02 17:34 UTC (permalink / raw)
To: ltp; +Cc: kernel-team
Leaving the directory fd open will count against the max number of fds
opened, so the final expected count will be off when (max_fds -
record_open_fds()) is even.
v1->v2:
Split patch into bugfix and refactor
Fix bug in refactor that caused exp_num_pipes to not round down to
nearest even integer
Edward Liaw (2):
pipe07: close /proc/self/fd after counting fds
pipe07: refactor exp_num_pipes
testcases/kernel/syscalls/pipe/pipe07.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--
2.42.0.582.g8ccd20d70d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2 1/2] pipe07: close /proc/self/fd after counting fds
2023-10-02 17:34 [LTP] [PATCH v2 0/2] pipe07: close /proc/self/fd after counting fds Edward Liaw via ltp
@ 2023-10-02 17:34 ` Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes Edward Liaw via ltp
1 sibling, 0 replies; 4+ messages in thread
From: Edward Liaw via ltp @ 2023-10-02 17:34 UTC (permalink / raw)
To: ltp; +Cc: kernel-team
Leaving the directory fd open will count against the max number of fds
opened, so the final expected count will be off when (max_fds -
record_open_fds()) is even.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
testcases/kernel/syscalls/pipe/pipe07.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/testcases/kernel/syscalls/pipe/pipe07.c b/testcases/kernel/syscalls/pipe/pipe07.c
index 196485684..d9b23044d 100644
--- a/testcases/kernel/syscalls/pipe/pipe07.c
+++ b/testcases/kernel/syscalls/pipe/pipe07.c
@@ -45,6 +45,8 @@ static int record_open_fds(void)
opened_fds[num_opened_fds++] = fd;
}
+ SAFE_CLOSEDIR(dir);
+
return num_opened_fds;
}
--
2.42.0.582.g8ccd20d70d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes
2023-10-02 17:34 [LTP] [PATCH v2 0/2] pipe07: close /proc/self/fd after counting fds Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 1/2] " Edward Liaw via ltp
@ 2023-10-02 17:34 ` Edward Liaw via ltp
2023-10-26 10:03 ` Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Edward Liaw via ltp @ 2023-10-02 17:34 UTC (permalink / raw)
To: ltp; +Cc: kernel-team
Move doubling the exp_num_pipes into the value.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
testcases/kernel/syscalls/pipe/pipe07.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/pipe/pipe07.c b/testcases/kernel/syscalls/pipe/pipe07.c
index d9b23044d..8098007c2 100644
--- a/testcases/kernel/syscalls/pipe/pipe07.c
+++ b/testcases/kernel/syscalls/pipe/pipe07.c
@@ -58,8 +58,8 @@ static void setup(void)
tst_res(TINFO, "getdtablesize() = %d", max_fds);
pipe_fds = SAFE_MALLOC(max_fds * sizeof(int));
- exp_num_pipes = (max_fds - record_open_fds()) / 2;
- tst_res(TINFO, "expected max fds to be opened by pipe(): %d", exp_num_pipes * 2);
+ exp_num_pipes = (max_fds - record_open_fds()) / 2 * 2;
+ tst_res(TINFO, "expected max fds to be opened by pipe(): %d", exp_num_pipes);
}
static void run(void)
@@ -75,7 +75,7 @@ static void run(void)
} while (!TST_RET);
TST_EXP_EQ_LI(errno, EMFILE);
- TST_EXP_EQ_LI(exp_num_pipes * 2, num_pipe_fds);
+ TST_EXP_EQ_LI(exp_num_pipes, num_pipe_fds);
for (int i = 0; i < num_pipe_fds; i++)
SAFE_CLOSE(pipe_fds[i]);
--
2.42.0.582.g8ccd20d70d-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes
2023-10-02 17:34 ` [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes Edward Liaw via ltp
@ 2023-10-26 10:03 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2023-10-26 10:03 UTC (permalink / raw)
To: Edward Liaw; +Cc: kernel-team, ltp
Hi Edward,
Thanks, merged.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-26 10:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 17:34 [LTP] [PATCH v2 0/2] pipe07: close /proc/self/fd after counting fds Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 1/2] " Edward Liaw via ltp
2023-10-02 17:34 ` [LTP] [PATCH v2 2/2] pipe07: refactor exp_num_pipes Edward Liaw via ltp
2023-10-26 10:03 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox