1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2022 ARM Limited.
4 * Original author: Mark Brown <broonie@kernel.org>
7 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/sched.h>
10 #include <linux/wait.h>
12 #include "kselftest.h"
14 #define EXPECTED_TESTS 1
17 int verify_fork(void);
20 * If we fork the value in the parent should be unchanged and the
21 * child should start with the same value. This is called from the
22 * fork_test() asm function.
26 pid_t newpid
, waiting
;
27 int child_status
, parent_result
;
33 ksft_print_msg("ZA state invalid in child\n");
40 ksft_print_msg("fork() failed: %d\n", newpid
);
45 parent_result
= verify_fork();
47 ksft_print_msg("ZA state invalid in parent\n");
50 waiting
= waitpid(newpid
, &child_status
, 0);
55 ksft_print_msg("waitpid() failed: %d\n", errno
);
58 if (waiting
!= newpid
) {
59 ksft_print_msg("waitpid() returned wrong PID\n");
63 if (!WIFEXITED(child_status
)) {
64 ksft_print_msg("child did not exit\n");
68 return WEXITSTATUS(child_status
) && parent_result
;
72 int main(int argc
, char **argv
)
77 ksft_set_plan(EXPECTED_TESTS
);
79 ksft_print_msg("PID: %d\n", getpid());
82 * This test is run with nolibc which doesn't support hwcap and
83 * it's probably disproportionate to implement so instead check
84 * for the default vector length configuration in /proc.
86 ret
= open("/proc/sys/abi/sme_default_vector_length", O_RDONLY
, 0);
88 ksft_test_result(fork_test(), "fork_test\n");
91 ksft_print_msg("SME not supported\n");
92 for (i
= 0; i
< EXPECTED_TESTS
; i
++) {
93 ksft_test_result_skip("fork_test\n");