X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b226f5e54a60dc81db17b1260381d7dbfea3cdf1..0a7de7458d150b5d4dffc935ba399be265ef0a1a:/tools/tests/superpages/testsp.c diff --git a/tools/tests/superpages/testsp.c b/tools/tests/superpages/testsp.c index fc4e6e204..018a62583 100644 --- a/tools/tests/superpages/testsp.c +++ b/tools/tests/superpages/testsp.c @@ -30,8 +30,9 @@ char error[100]; jmp_buf resume; -void test_signal_handler(int signo) -{ +void +test_signal_handler(int signo) +{ longjmp(resume, signo); } @@ -46,7 +47,8 @@ typedef struct { } test_t; boolean_t -check_kr(int kr, char *fn) { +check_kr(int kr, char *fn) +{ if (kr) { sprintf(error, "%s() returned %d", fn, kr); return FALSE; @@ -55,7 +57,8 @@ check_kr(int kr, char *fn) { } boolean_t -check_addr0(mach_vm_address_t addr, char *fn) { +check_addr0(mach_vm_address_t addr, char *fn) +{ if (!addr) { sprintf(error, "%s() returned address 0", fn); return FALSE; @@ -64,7 +67,8 @@ check_addr0(mach_vm_address_t addr, char *fn) { } boolean_t -check_addr(mach_vm_address_t addr1, mach_vm_address_t addr2, char *fn) { +check_addr(mach_vm_address_t addr1, mach_vm_address_t addr2, char *fn) +{ if (addr1 != addr2) { sprintf(error, "%s() returned address %llx instead of %llx", fn, addr1, addr2); return FALSE; @@ -73,7 +77,8 @@ check_addr(mach_vm_address_t addr1, mach_vm_address_t addr2, char *fn) { } boolean_t -check_align(mach_vm_address_t addr) { +check_align(mach_vm_address_t addr) +{ if (addr & !SUPERPAGE_MASK) { sprintf(error, "address not aligned properly: 0x%llx", addr); return FALSE; @@ -82,31 +87,35 @@ check_align(mach_vm_address_t addr) { } boolean_t -check_r(mach_vm_address_t addr, mach_vm_size_t size, int *res) { +check_r(mach_vm_address_t addr, mach_vm_size_t size, int *res) +{ volatile char *data = (char*)(uintptr_t)addr; int i, sig, test; - + if ((sig = setjmp(resume)) != 0) { sprintf(error, "%s when reading", signame[sig]); return FALSE; } test = 0; - for (i=0; i1) { + if (argc > 1) { if (!strcmp(argv[1], "-h")) { printf("Usage: %s \n", argv[0]); printf("\tmode = 0: test all cases\n"); @@ -640,9 +792,9 @@ int main(int argc, char **argv) { printf("\tmode > 0: run test \n"); exit(0); } - mode=atoi(argv[1]); + mode = atoi(argv[1]); } - + /* install SIGBUS handler */ struct sigaction my_sigaction; my_sigaction.sa_handler = test_signal_handler; @@ -650,25 +802,27 @@ int main(int argc, char **argv) { my_sigaction.sa_mask = 0; sigaction( SIGBUS, &my_sigaction, NULL ); sigaction( SIGSEGV, &my_sigaction, NULL ); - - if (mode>0) /* one specific test */ - testit(mode-1); - if (mode==0) { /* test all cases */ + if (mode > 0) { /* one specific test */ + testit(mode - 1); + } + + if (mode == 0) { /* test all cases */ printf("Running %d tests:\n", TESTS); - for (i=0; i