* [LTP] [PATCH v1] syscalls/acct02: Fix wrongfully failing sometimes
@ 2019-06-07 14:16 Christian Amann
2019-06-20 7:47 ` Petr Vorel
0 siblings, 1 reply; 2+ messages in thread
From: Christian Amann @ 2019-06-07 14:16 UTC (permalink / raw)
To: ltp
On some systems the process calling acct() has to end before
process accounting is started. This caused the original test
to fail on those systems.
This fix forks a child process to call acct() in order to
activate process accounting before running the test program.
Signed-off-by: Christian Amann <camann@suse.com>
---
testcases/kernel/syscalls/acct/acct02.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index 8a99bb94d..b609eec2b 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -108,13 +108,24 @@ static int verify_acct_v3(struct acct_v3 *acc)
static void run(void)
{
- int read_bytes, ret, entry_count;
+ int read_bytes, ret, entry_count, pid;
fd = SAFE_OPEN(OUTPUT_FILE, O_RDWR | O_CREAT, 0644);
- TEST(acct(OUTPUT_FILE));
- if (TST_RET == -1)
- tst_brk(TBROK | TTERRNO, "Could not set acct output file");
+ /* On some systems the process calling acct has to end
+ * before it takes effect
+ */
+ pid = SAFE_FORK();
+
+ if (pid == 0) {
+ TEST(acct(OUTPUT_FILE));
+ if (TST_RET == -1) {
+ tst_brk(TBROK | TTERRNO,
+ "Could not set acct output file");
+ }
+ return;
+ }
+ tst_reap_children();
start_time = time(NULL);
run_command();
@@ -180,4 +191,5 @@ static struct tst_test test = {
.cleanup = cleanup,
.needs_tmpdir = 1,
.needs_root = 1,
+ .forks_child = 1,
};
--
2.16.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [LTP] [PATCH v1] syscalls/acct02: Fix wrongfully failing sometimes
2019-06-07 14:16 [LTP] [PATCH v1] syscalls/acct02: Fix wrongfully failing sometimes Christian Amann
@ 2019-06-20 7:47 ` Petr Vorel
0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2019-06-20 7:47 UTC (permalink / raw)
To: ltp
Hi Christian,
> On some systems the process calling acct() has to end before
> process accounting is started. This caused the original test
> to fail on those systems.
> This fix forks a child process to call acct() in order to
> activate process accounting before running the test program.
> Signed-off-by: Christian Amann <camann@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks for you patch. Could you be please more specific?
(which kernel version / glibc)
I'm testing it on various distros, all have struct acct_v3 and all fail
(regardless this patch):
FAIL: acct() wrote incorrect file contents!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-20 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 14:16 [LTP] [PATCH v1] syscalls/acct02: Fix wrongfully failing sometimes Christian Amann
2019-06-20 7:47 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.