diff options
author | ngie <ngie@FreeBSD.org> | 2017-02-10 01:13:12 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-02-10 01:13:12 +0000 |
commit | 8864cde3495dbfd6b476c1b77a8bde035e1cf000 (patch) | |
tree | da558c97672e3d32f9e5551cd2daccd8684c5f03 /contrib/netbsd-tests/lib/libc/sys/t_mlock.c | |
parent | 9c6235cf2af8bdadcd0f0a80288683f0c88f3e55 (diff) | |
download | FreeBSD-src-8864cde3495dbfd6b476c1b77a8bde035e1cf000.zip FreeBSD-src-8864cde3495dbfd6b476c1b77a8bde035e1cf000.tar.gz |
MFC r305358,r305449,r305451,r306367,r306397,r309474:
This also contains a merge of ^/projects/netbsd-tests-update-12@r304035 .
This change never hit ^/head because bin/cat's behavior was changed (on ^/head)
to match NetBSD.
PR: 210607
r305358:
Update contrib/netbsd-tests with new content from NetBSD
This updates the snapshot from 09/30/2014 to 08/11/2016
This brings in a number of new testcases from upstream, most
notably:
- bin/cat
- lib/libc
- lib/msun
- lib/libthr
- usr.bin/sort
lib/libc/tests/stdio/open_memstream_test.c was moved to
lib/libc/tests/stdio/open_memstream2_test.c to accomodate
the new open_memstream test from NetBSD.
Tested on: amd64 (VMware fusion VM; various bare metal platforms); i386 (VMware fusion VM); make tinderbox
r305449:
Install h_db to unbreak some of the lib/libc/db testcases after
r305358
r305451:
Fix lib/libc/rpc test assumptions added in r305358
- Require root in the tcp/udp subtests (it's needed on FreeBSD when
registering services).
- Skip the tests if service registration fails.
r306367 (by br):
Allow up to 6 arguments only on MIPS.
r306397 (by br):
Use right piece of code for FreeBSD.
r309474:
Don't build :strvis_locale if VIS_NOLOCALE is undefined
The copy of contrib/libc-vis on ^/stable/10 doesn't contain all of the features
in the ^/stable/11 // ^/head version, including VIS_NOLOCALE. The risk is lower
in conditionally running the test instead of backporting the newer version of
libc-vis
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/sys/t_mlock.c')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/sys/t_mlock.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c index 85d82c7..2c0cdb7 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mlock.c,v 1.5 2014/02/26 20:49:26 martin Exp $ */ +/* $NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_mlock.c,v 1.5 2014/02/26 20:49:26 martin Exp $"); +__RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $"); #ifdef __FreeBSD__ #include <sys/types.h> @@ -178,6 +178,7 @@ ATF_TC_BODY(mlock_err, tc) #endif void *invalid_ptr; int null_errno = ENOMEM; /* error expected for NULL */ + void *buf; #ifdef __FreeBSD__ #ifdef VM_MIN_ADDRESS @@ -189,28 +190,48 @@ ATF_TC_BODY(mlock_err, tc) #else if (sysctlbyname("vm.minaddress", &vmin, &len, NULL, 0) != 0) atf_tc_fail("failed to read vm.minaddress"); + /* + * Any bad address must return ENOMEM (for lock & unlock) + */ + errno = 0; + ATF_REQUIRE_ERRNO(ENOMEM, mlock(NULL, page) == -1); if (vmin > 0) null_errno = EINVAL; /* NULL is not inside user VM */ #endif errno = 0; - ATF_REQUIRE_ERRNO(null_errno, mlock(NULL, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)0, page) == -1); errno = 0; - ATF_REQUIRE_ERRNO(null_errno, mlock((char *)0, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)-1, page) == -1); errno = 0; - ATF_REQUIRE_ERRNO(EINVAL, mlock((char *)-1, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, munlock(NULL, page) == -1); errno = 0; - ATF_REQUIRE_ERRNO(null_errno, munlock(NULL, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)0, page) == -1); errno = 0; - ATF_REQUIRE_ERRNO(null_errno, munlock((char *)0, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)-1, page) == -1); + + buf = malloc(page); + ATF_REQUIRE(buf != NULL); + + /* + * unlocking memory that is not locked is an error... + */ errno = 0; - ATF_REQUIRE_ERRNO(EINVAL, munlock((char *)-1, page) == -1); + ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1); + + /* + * These are permitted to fail (EINVAL) but do not on NetBSD + */ + ATF_REQUIRE(mlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); + ATF_REQUIRE(munlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); + + (void)free(buf); /* * Try to create a pointer to an unmapped page - first after current |