diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-06 10:59:22 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-06 10:59:22 +0300 |
commit | c8d430db8eec7d4fd13a6bea27b7086a54eda6da (patch) | |
tree | 3c9b35bc9372232183e745cc2a03995a8d053ff6 /tools/testing/selftests/acct/acct_syscall.c | |
parent | 2a5fe5a01668e831af1de3951718fbf88b9a9b9c (diff) | |
parent | a1d402abf8e3ff1d821e88993fc5331784fac0da (diff) | |
download | linux-c8d430db8eec7d4fd13a6bea27b7086a54eda6da.tar.xz |
Merge tag 'kvmarm-fixes-6.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.12, take #1
- Fix pKVM error path on init, making sure we do not change critical
system registers as we're about to fail
- Make sure that the host's vector length is at capped by a value
common to all CPUs
- Fix kvm_has_feat*() handling of "negative" features, as the current
code is pretty broken
- Promote Joey to the status of official reviewer, while James steps
down -- hopefully only temporarly
Diffstat (limited to 'tools/testing/selftests/acct/acct_syscall.c')
-rw-r--r-- | tools/testing/selftests/acct/acct_syscall.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tools/testing/selftests/acct/acct_syscall.c b/tools/testing/selftests/acct/acct_syscall.c new file mode 100644 index 000000000000..e44e8fe1f4a3 --- /dev/null +++ b/tools/testing/selftests/acct/acct_syscall.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* kselftest for acct() system call + * The acct() system call enables or disables process accounting. + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <sys/wait.h> + +#include "../kselftest.h" + +int main(void) +{ + char filename[] = "process_log"; + FILE *fp; + pid_t child_pid; + int sz; + + // Setting up kselftest framework + ksft_print_header(); + ksft_set_plan(1); + + // Check if test is run a root + if (geteuid()) { + ksft_test_result_skip("This test needs root to run!\n"); + return 1; + } + + // Create file to log closed processes + fp = fopen(filename, "w"); + + if (!fp) { + ksft_test_result_error("%s.\n", strerror(errno)); + ksft_finished(); + return 1; + } + + acct(filename); + + // Handle error conditions + if (errno) { + ksft_test_result_error("%s.\n", strerror(errno)); + fclose(fp); + ksft_finished(); + return 1; + } + + // Create child process and wait for it to terminate. + + child_pid = fork(); + + if (child_pid < 0) { + ksft_test_result_error("Creating a child process to log failed\n"); + acct(NULL); + return 1; + } else if (child_pid > 0) { + wait(NULL); + fseek(fp, 0L, SEEK_END); + sz = ftell(fp); + + acct(NULL); + + if (sz <= 0) { + ksft_test_result_fail("Terminated child process not logged\n"); + ksft_exit_fail(); + return 1; + } + + ksft_test_result_pass("Successfully logged terminated process.\n"); + fclose(fp); + ksft_exit_pass(); + return 0; + } + + return 1; +} |