From 77da516bf903f492dd1f8371fccb937112fe33c5 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 21 Oct 2020 16:26:29 +0000 Subject: On machines with a userland timecounter we bypass the gettimeofday(2) syscall. So whenever we pass a bad address we get a SIGSEGV instead of EFAULT. POSIX explicitly allows this behaviour. So adjust the test to deal with this case. ok deraadt@, millert@, guenther@ --- regress/lib/libc/sys/t_gettimeofday.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'regress/lib') diff --git a/regress/lib/libc/sys/t_gettimeofday.c b/regress/lib/libc/sys/t_gettimeofday.c index 0f874405e45..ec4a72c63e5 100644 --- a/regress/lib/libc/sys/t_gettimeofday.c +++ b/regress/lib/libc/sys/t_gettimeofday.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_gettimeofday.c,v 1.1 2019/11/19 19:57:03 bluhm Exp $ */ +/* $OpenBSD: t_gettimeofday.c,v 1.2 2020/10/21 16:26:28 kettenis Exp $ */ /* $NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ /*- @@ -41,6 +41,14 @@ __RCSID("$NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); #include #include +static void sighandler(int); + +static void +sighandler(int signo) +{ + _exit(0); +} + ATF_TC(gettimeofday_err); ATF_TC_HEAD(gettimeofday_err, tc) { @@ -50,8 +58,14 @@ ATF_TC_HEAD(gettimeofday_err, tc) ATF_TC_BODY(gettimeofday_err, tc) { - errno = 0; + /* + * With userland timecounters we will generate SIGSEGV instead + * of failing with errno so to EFAULT. POSIX explicitly + * allows this behaviour. + */ + ATF_REQUIRE(signal(SIGSEGV, sighandler) != SIG_ERR); + errno = 0; ATF_REQUIRE_ERRNO(EFAULT, gettimeofday((void *)-1, NULL) != 0); } -- cgit v1.2.3