1 // SPDX-License-Identifier: LGPL-2.1-only
3 * Basic test coverage for critical regions and rseq_current_cpu().
16 #include <rseq/rseq.h>
20 static void test_cpu_pointer(void)
22 cpu_set_t affinity
, test_affinity
;
25 ret
= sched_getaffinity(0, sizeof(affinity
), &affinity
);
26 ok(ret
== 0, "Get current thread affinity mask");
28 CPU_ZERO(&test_affinity
);
29 for (i
= 0; i
< CPU_SETSIZE
; i
++) {
30 if (CPU_ISSET(i
, &affinity
)) {
31 CPU_SET(i
, &test_affinity
);
33 ret
= sched_setaffinity(0, sizeof(test_affinity
),
35 ok(ret
== 0, "Set affinity mask to CPU %d exclusively", i
);
37 ok(sched_getcpu() == i
, "sched_getcpu returns CPU %d", i
);
38 ok(rseq_current_cpu() == (unsigned int) i
, "rseq_current_cpu returns CPU %d", i
);
39 ok(rseq_current_cpu_raw() == i
, "rseq_current_cpu_raw returns CPU %d", i
);
40 ok(rseq_cpu_start() == (unsigned int) i
, "rseq_cpu_start returns CPU %d", i
);
42 CPU_CLR(i
, &test_affinity
);
46 ret
= sched_setaffinity(0, sizeof(affinity
), &affinity
);
47 ok(ret
== 0, "Restore current thread initial affinity mask");
53 * Skip all tests if the rseq syscall is unavailable
55 if (rseq_available()) {
58 plan_skip_all("The rseq syscall is unavailable");
61 if (rseq_register_current_thread()) {
62 fail("rseq_register_current_thread(...) failed(%d): %s\n",
63 errno
, strerror(errno
));
66 pass("Registered current thread with rseq");
71 if (rseq_unregister_current_thread()) {
72 fail("rseq_unregister_current_thread(...) failed(%d): %s\n",
73 errno
, strerror(errno
));
76 pass("Unregistered current thread with rseq");
This page took 0.031615 seconds and 4 git commands to generate.