diff options
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libc/sys/t_gettimeofday.c | 18 |
1 files changed, 16 insertions, 2 deletions
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 <errno.h> #include <string.h> +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); } |