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 A test case for serious PR kern/38889: cr...
details: https://anonhg.NetBSD.org/src/rev/bbd42c34d05f
branches: trunk
changeset: 777850:bbd42c34d05f
user: jruoho <jruoho%NetBSD.org@localhost>
date: Tue Mar 06 11:02:55 2012 +0000
description:
A test case for serious PR kern/38889: crash on open/mmap/close of block
device. The test case is skipped for the time being as it replicates the
panic described in the PR (tested on NetBSD/amd64 6.0 BETA).
diffstat:
tests/lib/libc/sys/t_mmap.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diffs (77 lines):
diff -r 525536161967 -r bbd42c34d05f tests/lib/libc/sys/t_mmap.c
--- a/tests/lib/libc/sys/t_mmap.c Tue Mar 06 10:32:15 2012 +0000
+++ b/tests/lib/libc/sys/t_mmap.c Tue Mar 06 11:02:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $ */
+/* $NetBSD: t_mmap.c,v 1.3 2012/03/06 11:02:55 jruoho Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $");
+__RCSID("$NetBSD: t_mmap.c,v 1.3 2012/03/06 11:02:55 jruoho Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -67,6 +67,7 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -152,6 +153,42 @@
_exit(signo);
}
+ATF_TC(mmap_block);
+ATF_TC_HEAD(mmap_block, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test mmap(2) with a block device");
+}
+
+ATF_TC_BODY(mmap_block, tc)
+{
+ static const char *dev[] = { "/dev/wd0c", "/dev/wd0d", "/dev/wd0g" };
+ char *map;
+ size_t i;
+ int fd;
+
+ atf_tc_skip("The test case causes a panic (PR kern/38889)");
+
+ for (i = 0; i < __arraycount(dev); i++) {
+
+ if ((fd = open(dev[i], O_RDONLY)) >= 0) {
+ (void)fprintf(stderr, "using %s\n", dev[i]);
+ break;
+ }
+ }
+
+ if (i == __arraycount(dev)) /* Skip. */
+ return;
+
+ map = mmap(NULL, 4096, PROT_READ, MAP_FILE, fd, 0);
+ ATF_REQUIRE(map != MAP_FAILED);
+
+ (void)fprintf(stderr, "first byte %x\n", *map);
+ ATF_REQUIRE(close(fd) == 0);
+ (void)fprintf(stderr, "first byte %x\n", *map);
+
+ ATF_REQUIRE(munmap(map, 4096) == 0);
+}
+
ATF_TC(mmap_err);
ATF_TC_HEAD(mmap_err, tc)
{
@@ -444,6 +481,7 @@
page = sysconf(_SC_PAGESIZE);
ATF_REQUIRE(page >= 0);
+ ATF_TP_ADD_TC(tp, mmap_block);
ATF_TP_ADD_TC(tp, mmap_err);
ATF_TP_ADD_TC(tp, mmap_loan);
ATF_TP_ADD_TC(tp, mmap_prot_1);
Home |
Main Index |
Thread Index |
Old Index