syscalls/acct02: Fix wrongfully failing sometimes
PATCH 1/1 syscalls/acct02: Fix wrongfully failing sometimes
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.
--- testcases/kernel/syscalls/acct/acct02.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/acct/acct02.c +16 -4
@@ -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, };
Signature · 1 line
2.16.4
PATCH 1/1 syscalls/acct02: Fix wrongfully failing sometimes
Hi Christian,
Quoted 7 lines
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 callacct()in order to activate process accounting before running the test program.Signed-off-by Christian Amann <[email protected]>
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