diff options
| author | kettenis <> | 2020-10-21 16:26:28 +0000 |
|---|---|---|
| committer | kettenis <> | 2020-10-21 16:26:28 +0000 |
| commit | a9540bd67ec5f006bee47892ddd57a679b353ba3 (patch) | |
| tree | 98a785c43fc167cf1acafdd9729c83c64add8481 /src | |
| parent | 98a8d4e406fc605918198ca092f495a5800f197c (diff) | |
| download | openbsd-a9540bd67ec5f006bee47892ddd57a679b353ba3.tar.gz openbsd-a9540bd67ec5f006bee47892ddd57a679b353ba3.tar.bz2 openbsd-a9540bd67ec5f006bee47892ddd57a679b353ba3.zip | |
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 'src')
| -rw-r--r-- | src/regress/lib/libc/sys/t_gettimeofday.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/regress/lib/libc/sys/t_gettimeofday.c b/src/regress/lib/libc/sys/t_gettimeofday.c index de768b023a..ec4a72c63e 100644 --- a/src/regress/lib/libc/sys/t_gettimeofday.c +++ b/src/regress/lib/libc/sys/t_gettimeofday.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: t_gettimeofday.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ | 1 | /* $OpenBSD: t_gettimeofday.c,v 1.2 2020/10/21 16:26:28 kettenis Exp $ */ |
| 2 | /* $NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ | 2 | /* $NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ |
| 3 | 3 | ||
| 4 | /*- | 4 | /*- |
| @@ -41,6 +41,14 @@ __RCSID("$NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); | |||
| 41 | #include <errno.h> | 41 | #include <errno.h> |
| 42 | #include <string.h> | 42 | #include <string.h> |
| 43 | 43 | ||
| 44 | static void sighandler(int); | ||
| 45 | |||
| 46 | static void | ||
| 47 | sighandler(int signo) | ||
| 48 | { | ||
| 49 | _exit(0); | ||
| 50 | } | ||
| 51 | |||
| 44 | ATF_TC(gettimeofday_err); | 52 | ATF_TC(gettimeofday_err); |
| 45 | ATF_TC_HEAD(gettimeofday_err, tc) | 53 | ATF_TC_HEAD(gettimeofday_err, tc) |
| 46 | { | 54 | { |
| @@ -50,8 +58,14 @@ ATF_TC_HEAD(gettimeofday_err, tc) | |||
| 50 | ATF_TC_BODY(gettimeofday_err, tc) | 58 | ATF_TC_BODY(gettimeofday_err, tc) |
| 51 | { | 59 | { |
| 52 | 60 | ||
| 53 | errno = 0; | 61 | /* |
| 62 | * With userland timecounters we will generate SIGSEGV instead | ||
| 63 | * of failing with errno so to EFAULT. POSIX explicitly | ||
| 64 | * allows this behaviour. | ||
| 65 | */ | ||
| 66 | ATF_REQUIRE(signal(SIGSEGV, sighandler) != SIG_ERR); | ||
| 54 | 67 | ||
| 68 | errno = 0; | ||
| 55 | ATF_REQUIRE_ERRNO(EFAULT, gettimeofday((void *)-1, NULL) != 0); | 69 | ATF_REQUIRE_ERRNO(EFAULT, gettimeofday((void *)-1, NULL) != 0); |
| 56 | } | 70 | } |
| 57 | 71 | ||
