From 595fc10f11a216c2e7ca93c0cb3e671a2bf0091b Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 7 Feb 2016 23:28:18 +0000 Subject: [PATCH] tests: extend coverage of struct sigevent * tests/timer_create.c (main): Check decoding of NULL struct sigevent pointer. Check decoding of invalid sigev_notify value. --- tests/timer_create.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/timer_create.c b/tests/timer_create.c index 380c978d..8f7d5cd8 100644 --- a/tests/timer_create.c +++ b/tests/timer_create.c @@ -1,4 +1,6 @@ /* + * This file is part of timer_create strace test. + * * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * @@ -39,18 +41,29 @@ int main(void) { + syscall(__NR_timer_create, CLOCK_REALTIME, NULL, NULL); + printf("timer_create(CLOCK_REALTIME, NULL, NULL) = -1 EFAULT (%m)\n"); + int tid[4] = {}; struct_sigevent sev = { - .sigev_notify = SIGEV_NONE, + .sigev_notify = 0xdefaced, .sigev_signo = 0xfacefeed, .sigev_value.sival_ptr = (unsigned long) 0xdeadbeefbadc0ded }; + syscall(__NR_timer_create, CLOCK_REALTIME, &sev, NULL); + printf("timer_create(CLOCK_REALTIME, {sigev_value={int=%d, ptr=%#lx}" + ", sigev_signo=%u, sigev_notify=%#x /* SIGEV_??? */}" + ", NULL) = -1 EINVAL (%m)\n", + sev.sigev_value.sival_int, + sev.sigev_value.sival_ptr, + sev.sigev_signo, sev.sigev_notify); + + sev.sigev_notify = SIGEV_NONE; if (syscall(__NR_timer_create, CLOCK_REALTIME, &sev, &tid[0])) perror_msg_and_skip("timer_create CLOCK_REALTIME"); printf("timer_create(CLOCK_REALTIME, {sigev_value={int=%d, ptr=%#lx}" - ", sigev_signo=%u, sigev_notify=SIGEV_NONE}" - ", [%d]) = 0\n", + ", sigev_signo=%u, sigev_notify=SIGEV_NONE}, [%d]) = 0\n", sev.sigev_value.sival_int, sev.sigev_value.sival_ptr, sev.sigev_signo, tid[0]); -- 2.50.1