Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Add the error in syscall failure.
details: https://anonhg.NetBSD.org/src/rev/497fb616f4b4
branches: trunk
changeset: 353804:497fb616f4b4
user: christos <christos%NetBSD.org@localhost>
date: Tue May 23 16:01:46 2017 +0000
description:
Add the error in syscall failure.
diffstat:
tests/lib/libc/sys/t_mincore.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diffs (81 lines):
diff -r 71a68bf8003a -r 497fb616f4b4 tests/lib/libc/sys/t_mincore.c
--- a/tests/lib/libc/sys/t_mincore.c Tue May 23 15:56:55 2017 +0000
+++ b/tests/lib/libc/sys/t_mincore.c Tue May 23 16:01:46 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $ */
+/* $NetBSD: t_mincore.c,v 1.11 2017/05/23 16:01:46 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $");
+__RCSID("$NetBSD: t_mincore.c,v 1.11 2017/05/23 16:01:46 christos Exp $");
#include <sys/mman.h>
#include <sys/stat.h>
@@ -79,6 +79,8 @@
static const char path[] = "mincore";
static size_t check_residency(void *, size_t);
+#define ATF_REQUIRE_STRERROR(a) ATF_REQUIRE_MSG(a, " (%s)", strerror(errno))
+
static size_t
check_residency(void *addr, size_t npgs)
{
@@ -238,18 +240,18 @@
ATF_REQUIRE(check_residency(addr2, npgs) == npgs);
ATF_REQUIRE(check_residency(addr3, npgs) == 0);
- ATF_REQUIRE(mprotect(addr3, npgs * page, PROT_READ) == 0);
+ ATF_REQUIRE_STRERROR(mprotect(addr3, npgs * page, PROT_READ) == 0);
ATF_REQUIRE(check_residency(addr, npgs) == npgs);
ATF_REQUIRE(check_residency(addr2, npgs) == npgs);
(void)munlockall();
- ATF_REQUIRE(madvise(addr2, npgs * page, MADV_FREE) == 0);
+ ATF_REQUIRE_STRERROR(madvise(addr2, npgs * page, MADV_FREE) == 0);
ATF_REQUIRE(check_residency(addr2, npgs) == 0);
(void)memset(addr, 0, npgs * page);
- ATF_REQUIRE(madvise(addr, npgs * page, MADV_FREE) == 0);
+ ATF_REQUIRE_STRERROR(madvise(addr, npgs * page, MADV_FREE) == 0);
ATF_REQUIRE(check_residency(addr, npgs) == 0);
(void)munmap(addr, npgs * page);
@@ -279,17 +281,17 @@
shmid = shmget(IPC_PRIVATE, npgs * page,
IPC_CREAT | S_IRUSR | S_IWUSR);
- ATF_REQUIRE(shmid != -1);
+ ATF_REQUIRE_STRERROR(shmid != -1);
addr = shmat(shmid, NULL, 0);
- ATF_REQUIRE(addr != NULL);
+ ATF_REQUIRE_STRERROR(addr != NULL);
ATF_REQUIRE(check_residency(addr, npgs) == 0);
(void)memset(addr, 0xff, npgs * page);
ATF_REQUIRE(check_residency(addr, npgs) == npgs);
- ATF_REQUIRE(madvise(addr, npgs * page, MADV_FREE) == 0);
+ ATF_REQUIRE_STRERROR(madvise(addr, npgs * page, MADV_FREE) == 0);
/*
* NOTE! Even though we have MADV_FREE'd the range,
@@ -308,8 +310,8 @@
(void)fprintf(stderr, "%zu pages still resident\n", npgs);
- ATF_REQUIRE(shmdt(addr) == 0);
- ATF_REQUIRE(shmctl(shmid, IPC_RMID, NULL) == 0);
+ ATF_REQUIRE_STRERROR(shmdt(addr) == 0);
+ ATF_REQUIRE_STRERROR(shmctl(shmid, IPC_RMID, NULL) == 0);
}
ATF_TP_ADD_TCS(tp)
Home |
Main Index |
Thread Index |
Old Index