diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-10-21 16:26:29 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-10-21 16:26:29 +0000 |
commit | 77da516bf903f492dd1f8371fccb937112fe33c5 (patch) | |
tree | a6c6987308642e086e7aadf0d0b933e39a761081 /regress/lib | |
parent | 82626a7c2e84fe88c7cac5ba00fce839c70420bf (diff) |
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@
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); } |