summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/dev/kcov/Makefile3
-rw-r--r--regress/sys/dev/kcov/kcov.c23
2 files changed, 24 insertions, 2 deletions
diff --git a/regress/sys/dev/kcov/Makefile b/regress/sys/dev/kcov/Makefile
index 29daeb60add..5a6cd6ef285 100644
--- a/regress/sys/dev/kcov/Makefile
+++ b/regress/sys/dev/kcov/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2018/12/27 19:38:01 anton Exp $
+# $OpenBSD: Makefile,v 1.7 2019/01/16 19:28:36 anton Exp $
PROG= kcov
WARNINGS= yes
@@ -13,6 +13,7 @@ TESTS+= coverage
TESTS+= dying
TESTS+= exec
TESTS+= fork
+TESTS+= mmap
TESTS+= open
TESTS+= state
diff --git a/regress/sys/dev/kcov/kcov.c b/regress/sys/dev/kcov/kcov.c
index 28d7ee3ed3e..c12513c7603 100644
--- a/regress/sys/dev/kcov/kcov.c
+++ b/regress/sys/dev/kcov/kcov.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kcov.c,v 1.6 2019/01/03 08:51:31 anton Exp $ */
+/* $OpenBSD: kcov.c,v 1.7 2019/01/16 19:28:37 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
@@ -35,6 +35,7 @@ static int test_coverage(int, int);
static int test_dying(int, int);
static int test_exec(int, int);
static int test_fork(int, int);
+static int test_mmap(int, int);
static int test_open(int, int);
static int test_state(int, int);
@@ -62,6 +63,7 @@ main(int argc, char *argv[])
{ "dying", test_dying, 1 },
{ "exec", test_exec, 1 },
{ "fork", test_fork, 1 },
+ { "mmap", test_mmap, 1 },
{ "open", test_open, 0 },
{ "state", test_state, 1 },
{ NULL, NULL, 0 },
@@ -340,6 +342,25 @@ test_fork(int fd, int mode)
}
/*
+ * Calling mmap() after enable is not allowed.
+ */
+static int
+test_mmap(int fd, int mode)
+{
+ void *cover;
+
+ kcov_enable(fd, mode);
+ cover = mmap(NULL, bufsize * sizeof(unsigned long),
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (cover != MAP_FAILED) {
+ warnx("expected mmap to fail");
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
* Open /dev/kcov more than once.
*/
static int