fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[librseq.git] / tests / no_syscall_test.c
1 // SPDX-License-Identifier: MIT
2 // SPDX-FileCopyrightText: 2024 Michael Jeanson <mjeanson@efficios.com>
3
4 #ifndef _GNU_SOURCE
5 #define _GNU_SOURCE
6 #endif
7 #include <stdint.h>
8
9 #include <rseq/rseq.h>
10
11 #include "tap.h"
12
13 #define NR_TESTS 5
14
15 /*
16 * Check the state of the public symbols when the rseq syscall is unavailable.
17 *
18 * This test must be used with an LD_PRELOAD library to deny access to the
19 * syscall, or on a kernel that doesn't implement the syscall.
20 */
21
22 int main(void)
23 {
24 struct rseq_abi *rseq_abi;
25
26 plan_tests(NR_TESTS);
27
28 if (rseq_available(RSEQ_AVAILABLE_QUERY_KERNEL)) {
29 fail("The rseq syscall should be unavailable");
30 goto end;
31 }
32
33 /* The rseq syscall is disabled, no registration is possible. */
34
35 ok(rseq_flags == 0, "rseq_flags prior to registration is 0 (%d)", rseq_flags);
36 ok(rseq_size == 0, "rseq_size prior to registration is 0 (%d)", rseq_size);
37 ok(rseq_feature_size == 0, "rseq_feature_size prior to registration is 0 (%d)", rseq_feature_size);
38 ok(rseq_offset != 0, "rseq_offset prior to registration is not 0 (%td)", rseq_offset);
39
40 rseq_abi = rseq_get_abi();
41 ok((int32_t) rseq_abi->cpu_id == RSEQ_ABI_CPU_ID_UNINITIALIZED,
42 "rseq->cpu_id is set to RSEQ_ABI_CPU_ID_UNINITIALIZED (%d)",
43 (int32_t) rseq_abi->cpu_id);
44
45 end:
46 exit(exit_status());
47 }
This page took 0.06869 seconds and 4 git commands to generate.