From: Dmitry V. Levin Date: Sun, 3 Jan 2016 22:09:54 +0000 (+0000) Subject: tests/xet_robust_list.c: use libtests X-Git-Tag: v4.12~770 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cadf3543f7e3909940bacb836a634af7ecf7d5ea;p=strace tests/xet_robust_list.c: use libtests * tests/xet_robust_list.c: Use SKIP_MAIN_UNDEFINED. (main): Use perror_msg_and_skip and tail_alloc. --- diff --git a/tests/xet_robust_list.c b/tests/xet_robust_list.c index db2deaa3..eef31dc7 100644 --- a/tests/xet_robust_list.c +++ b/tests/xet_robust_list.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,42 +26,34 @@ */ #include "tests.h" -#include -#include -#include #include #if defined __NR_get_robust_list && defined __NR_set_robust_list +# include +# include + int main(void) { - const size_t page_len = sysconf(_SC_PAGESIZE); const pid_t pid = getpid(); const long long_pid = (unsigned long) (0xdeadbeef00000000LL | pid); - - void *p = mmap(NULL, page_len * 4, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED || - mprotect(p + page_len, page_len, PROT_NONE) || - mprotect(p + page_len * 3, page_len, PROT_NONE)) - return 77; - - void **p_head = p + page_len - sizeof(void *); - size_t *p_len = p + page_len * 3 - sizeof(size_t); + void **p_head = tail_alloc(sizeof(void *)); + size_t *p_len = tail_alloc(sizeof(size_t)); if (syscall(__NR_get_robust_list, long_pid, p_head, p_len)) - return 77; + perror_msg_and_skip("get_robust_list"); printf("get_robust_list(%d, [%#lx], [%lu]) = 0\n", (int) pid, (unsigned long) *p_head, (unsigned long) *p_len); - if (syscall(__NR_set_robust_list, p, *p_len)) - return 77; - printf("set_robust_list(%#lx, %lu) = 0\n", - (unsigned long) p, (unsigned long) *p_len); + void *head = tail_alloc(*p_len); + if (syscall(__NR_set_robust_list, head, *p_len)) + perror_msg_and_skip("set_robust_list"); + printf("set_robust_list(%p, %lu) = 0\n", + head, (unsigned long) *p_len); if (syscall(__NR_get_robust_list, long_pid, p_head, p_len)) - return 77; + perror_msg_and_skip("get_robust_list"); printf("get_robust_list(%d, [%#lx], [%lu]) = 0\n", (int) pid, (unsigned long) *p_head, (unsigned long) *p_len); @@ -71,10 +63,6 @@ main(void) #else -int -main(void) -{ - return 77; -} +SKIP_MAIN_UNDEFINED("__NR_get_robust_list && __NR_set_robust_list") #endif