1 // SPDX-License-Identifier: GPL-2.0
3 /* kselftest for acct() system call
4 * The acct() system call enables or disables process accounting.
12 #include "../kselftest.h"
16 char filename
[] = "process_log";
21 // Setting up kselftest framework
25 // Check if test is run a root
27 ksft_test_result_skip("This test needs root to run!\n");
31 // Create file to log closed processes
32 fp
= fopen(filename
, "w");
35 ksft_test_result_error("%s.\n", strerror(errno
));
42 // Handle error conditions
44 ksft_test_result_error("%s.\n", strerror(errno
));
50 // Create child process and wait for it to terminate.
55 ksft_test_result_error("Creating a child process to log failed\n");
58 } else if (child_pid
> 0) {
60 fseek(fp
, 0L, SEEK_END
);
66 ksft_test_result_fail("Terminated child process not logged\n");
71 ksft_test_result_pass("Successfully logged terminated process.\n");