Dan Albert | bf18c61 | 2015-03-04 10:31:29 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <gtest/gtest.h> |
| 18 | |
Colin Cross | 7da2034 | 2021-07-28 11:18:11 -0700 | [diff] [blame] | 19 | #include <ucontext.h> // for NGREG on musl |
Dan Albert | bf18c61 | 2015-03-04 10:31:29 -0800 | [diff] [blame] | 20 | #include <sys/procfs.h> |
| 21 | |
Elliott Hughes | 8e5fc5b | 2020-09-03 12:31:07 -0700 | [diff] [blame] | 22 | TEST(sys_procfs, types) { |
Christopher Ferris | 2a39188 | 2024-12-19 13:44:35 -0800 | [diff] [blame] | 23 | elf_greg_t reg = {}; |
| 24 | elf_gregset_t regs = {}; |
| 25 | elf_fpregset_t fp_regs = {}; |
| 26 | prgregset_t pr_g_regs = {}; |
| 27 | prfpregset_t pr_fp_regs = {}; |
Dan Albert | bf18c61 | 2015-03-04 10:31:29 -0800 | [diff] [blame] | 28 | |
| 29 | static_assert(sizeof(prgregset_t) == sizeof(elf_gregset_t), ""); |
| 30 | static_assert(sizeof(prfpregset_t) == sizeof(elf_fpregset_t), ""); |
| 31 | } |
Elliott Hughes | 8e5fc5b | 2020-09-03 12:31:07 -0700 | [diff] [blame] | 32 | |
| 33 | TEST(sys_procfs, constants) { |
| 34 | // NGREG != ELF_NGREG (https://github.com/android/ndk/issues/1347) |
| 35 | static_assert(sizeof(gregset_t) / sizeof(greg_t) == NGREG); |
| 36 | |
| 37 | #if defined(__arm__) |
| 38 | static_assert(sizeof(user_regs) / sizeof(elf_greg_t) == ELF_NGREG); |
| 39 | #elif defined(__aarch64__) |
| 40 | static_assert(sizeof(user_pt_regs) / sizeof(elf_greg_t) == ELF_NGREG); |
| 41 | #else |
| 42 | static_assert(sizeof(user_regs_struct) / sizeof(elf_greg_t) == ELF_NGREG); |
| 43 | #endif |
| 44 | } |