1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker *
4*8d67ca89SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*8d67ca89SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*8d67ca89SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*8d67ca89SAndroid Build Coastguard Worker *
8*8d67ca89SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*8d67ca89SAndroid Build Coastguard Worker *
10*8d67ca89SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*8d67ca89SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*8d67ca89SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8d67ca89SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*8d67ca89SAndroid Build Coastguard Worker * limitations under the License.
15*8d67ca89SAndroid Build Coastguard Worker */
16*8d67ca89SAndroid Build Coastguard Worker
17*8d67ca89SAndroid Build Coastguard Worker #include <gtest/gtest.h>
18*8d67ca89SAndroid Build Coastguard Worker
19*8d67ca89SAndroid Build Coastguard Worker #include <ucontext.h> // for NGREG on musl
20*8d67ca89SAndroid Build Coastguard Worker #include <sys/procfs.h>
21*8d67ca89SAndroid Build Coastguard Worker
TEST(sys_procfs,types)22*8d67ca89SAndroid Build Coastguard Worker TEST(sys_procfs, types) {
23*8d67ca89SAndroid Build Coastguard Worker elf_greg_t reg;
24*8d67ca89SAndroid Build Coastguard Worker memset(®, 0, sizeof(reg));
25*8d67ca89SAndroid Build Coastguard Worker
26*8d67ca89SAndroid Build Coastguard Worker elf_gregset_t regs;
27*8d67ca89SAndroid Build Coastguard Worker memset(®s, 0, sizeof(regs));
28*8d67ca89SAndroid Build Coastguard Worker
29*8d67ca89SAndroid Build Coastguard Worker elf_fpregset_t fp_regs;
30*8d67ca89SAndroid Build Coastguard Worker memset(&fp_regs, 0, sizeof(fp_regs));
31*8d67ca89SAndroid Build Coastguard Worker
32*8d67ca89SAndroid Build Coastguard Worker prgregset_t pr_g_regs;
33*8d67ca89SAndroid Build Coastguard Worker memset(&pr_g_regs, 0, sizeof(pr_g_regs));
34*8d67ca89SAndroid Build Coastguard Worker
35*8d67ca89SAndroid Build Coastguard Worker prfpregset_t pr_fp_regs;
36*8d67ca89SAndroid Build Coastguard Worker memset(&pr_fp_regs, 0, sizeof(pr_fp_regs));
37*8d67ca89SAndroid Build Coastguard Worker
38*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(prgregset_t) == sizeof(elf_gregset_t), "");
39*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(prfpregset_t) == sizeof(elf_fpregset_t), "");
40*8d67ca89SAndroid Build Coastguard Worker }
41*8d67ca89SAndroid Build Coastguard Worker
TEST(sys_procfs,constants)42*8d67ca89SAndroid Build Coastguard Worker TEST(sys_procfs, constants) {
43*8d67ca89SAndroid Build Coastguard Worker // NGREG != ELF_NGREG (https://github.com/android/ndk/issues/1347)
44*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(gregset_t) / sizeof(greg_t) == NGREG);
45*8d67ca89SAndroid Build Coastguard Worker
46*8d67ca89SAndroid Build Coastguard Worker #if defined(__arm__)
47*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(user_regs) / sizeof(elf_greg_t) == ELF_NGREG);
48*8d67ca89SAndroid Build Coastguard Worker #elif defined(__aarch64__)
49*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(user_pt_regs) / sizeof(elf_greg_t) == ELF_NGREG);
50*8d67ca89SAndroid Build Coastguard Worker #else
51*8d67ca89SAndroid Build Coastguard Worker static_assert(sizeof(user_regs_struct) / sizeof(elf_greg_t) == ELF_NGREG);
52*8d67ca89SAndroid Build Coastguard Worker #endif
53*8d67ca89SAndroid Build Coastguard Worker }
54