#include #include #include "unittest.h" #include "arch.h" #include "type.h" static int arch_x86_64_sizeof(void *_null) { unittest_eq(type_sizeof(&t_s8), sizeof(int8_t)); unittest_eq(type_sizeof(&t_u8), sizeof(uint8_t)); unittest_eq(type_sizeof(&t_s16), sizeof(int16_t)); unittest_eq(type_sizeof(&t_u16), sizeof(uint16_t)); unittest_eq(type_sizeof(&t_s32), sizeof(int32_t)); unittest_eq(type_sizeof(&t_u32), sizeof(uint32_t)); unittest_eq(type_sizeof(&t_s64), sizeof(int64_t)); unittest_eq(type_sizeof(&t_u64), sizeof(uint64_t)); return 0; } UNITTEST(arch_x86_64_sizeof); static int arch_x86_64_pt_regs(void *_null) { unittest_eq(type_offsetof(&t_pt_regs, "r15"), offsetof(struct pt_regs, r15)); unittest_eq(type_offsetof(&t_pt_regs, "r14"), offsetof(struct pt_regs, r14)); unittest_eq(type_offsetof(&t_pt_regs, "r13"), offsetof(struct pt_regs, r13)); unittest_eq(type_offsetof(&t_pt_regs, "r12"), offsetof(struct pt_regs, r12)); unittest_eq(type_offsetof(&t_pt_regs, "rbp"), offsetof(struct pt_regs, rbp)); unittest_eq(type_offsetof(&t_pt_regs, "rbx"), offsetof(struct pt_regs, rbx)); unittest_eq(type_offsetof(&t_pt_regs, "r11"), offsetof(struct pt_regs, r11)); unittest_eq(type_offsetof(&t_pt_regs, "r10"), offsetof(struct pt_regs, r10)); unittest_eq(type_offsetof(&t_pt_regs, "r9"), offsetof(struct pt_regs, r9)); unittest_eq(type_offsetof(&t_pt_regs, "r8"), offsetof(struct pt_regs, r8)); unittest_eq(type_offsetof(&t_pt_regs, "rax"), offsetof(struct pt_regs, rax)); unittest_eq(type_offsetof(&t_pt_regs, "rcx"), offsetof(struct pt_regs, rcx)); unittest_eq(type_offsetof(&t_pt_regs, "rdx"), offsetof(struct pt_regs, rdx)); unittest_eq(type_offsetof(&t_pt_regs, "rsi"), offsetof(struct pt_regs, rsi)); unittest_eq(type_offsetof(&t_pt_regs, "rdi"), offsetof(struct pt_regs, rdi)); unittest_eq(type_offsetof(&t_pt_regs, "orig_rax"), offsetof(struct pt_regs, orig_rax)); unittest_eq(type_offsetof(&t_pt_regs, "rip"), offsetof(struct pt_regs, rip)); unittest_eq(type_offsetof(&t_pt_regs, "cs"), offsetof(struct pt_regs, cs)); unittest_eq(type_offsetof(&t_pt_regs, "eflags"), offsetof(struct pt_regs, eflags)); unittest_eq(type_offsetof(&t_pt_regs, "rsp"), offsetof(struct pt_regs, rsp)); unittest_eq(type_offsetof(&t_pt_regs, "ss"), offsetof(struct pt_regs, ss)); unittest_eq(type_alignof(&t_pt_regs), __alignof__(struct pt_regs)); unittest_eq(type_sizeof(&t_pt_regs), sizeof(struct pt_regs)); return 0; } UNITTEST(arch_x86_64_pt_regs); int main(void) { struct unittest_ctx ctx = { .keep_going = 1, .verbose = 1, .ctx = NULL, }; return unittests_run(&ctx) ? 1 : 0; }