Introduce common generic header file
[librseq.git] / tests / unregistered_test.c
CommitLineData
01bd794d
MJ
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 available but
17 * no thread has registered.
18 */
19
20int main(void)
21{
22 struct rseq_abi *rseq_abi;
23
24 plan_tests(NR_TESTS);
25
26 if (!rseq_available(RSEQ_AVAILABLE_QUERY_KERNEL)) {
27 skip(NR_TESTS, "rseq syscall unavailable");
28 goto end;
29 }
30
31 /* The syscall is available but the current thread is not registered. */
32
33 ok(rseq_flags == 0, "rseq_flags prior to registration is 0 (%d)", rseq_flags);
34 ok(rseq_size >= 32, "rseq_size prior to registration is 32 or greater (%d)", rseq_size);
35 ok(rseq_feature_size >= 20, "rseq_feature_size prior to registration is 20 or greater (%d)", rseq_feature_size);
36 ok(rseq_offset != 0, "rseq_offset prior to registration is not 0 (%td)", rseq_offset);
37
38 rseq_abi = rseq_get_abi();
39 ok((int32_t) rseq_abi->cpu_id == RSEQ_ABI_CPU_ID_UNINITIALIZED,
40 "rseq->cpu_id is set to RSEQ_ABI_CPU_ID_UNINITIALIZED (%d)",
41 (int32_t) rseq_abi->cpu_id);
42
43end:
44 exit(exit_status());
45}
This page took 0.041654 seconds and 4 git commands to generate.