summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/sys/dev/wscons/Makefile4
-rw-r--r--regress/sys/dev/wscons/sigio.c92
2 files changed, 66 insertions, 30 deletions
diff --git a/regress/sys/dev/wscons/Makefile b/regress/sys/dev/wscons/Makefile
index 3d74dc5b560..4072f5a46e8 100644
--- a/regress/sys/dev/wscons/Makefile
+++ b/regress/sys/dev/wscons/Makefile
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.1 2018/11/16 20:19:21 anton Exp $
+# $OpenBSD: Makefile,v 1.2 2018/11/20 18:49:42 anton Exp $
PROG= sigio
WARNINGS= yes
.for d in wskbd0 wsmouse0 wskbd
-. for t in setown spgrp sigio
+. for t in setown-fcntl setown-ioctl spgrp sigio
REGRESS_TARGETS+= $d-$t
$d-$t: ${PROG}
@echo "\n======== ${@} ========"
diff --git a/regress/sys/dev/wscons/sigio.c b/regress/sys/dev/wscons/sigio.c
index 6aed48bca64..b4b6fd33611 100644
--- a/regress/sys/dev/wscons/sigio.c
+++ b/regress/sys/dev/wscons/sigio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigio.c,v 1.1 2018/11/16 20:19:21 anton Exp $ */
+/* $OpenBSD: sigio.c,v 1.2 2018/11/20 18:49:42 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
@@ -30,10 +30,13 @@
#include <string.h>
#include <unistd.h>
-static int test_setown(int);
+static int test_setown_fcntl(int);
+static int test_setown_ioctl(int);
static int test_sigio(int);
static int test_spgrp(int);
+static int test_common_setown(int, int);
+
static void sigio(int);
static void syncrecv(int, int);
static void syncsend(int, int);
@@ -45,9 +48,10 @@ static struct {
const char *name;
int (*fn)(int);
} tests[] = {
- { "setown", test_setown },
- { "sigio", test_sigio },
- { "spgrp", test_spgrp },
+ { "setown-fcntl", test_setown_fcntl },
+ { "setown-ioctl", test_setown_ioctl },
+ { "sigio", test_sigio },
+ { "spgrp", test_spgrp },
{ NULL, NULL },
};
@@ -95,31 +99,15 @@ main(int argc, char *argv[])
}
static int
-test_setown(int fd)
+test_setown_fcntl(int fd)
{
- int arg;
-
- /* The process must be able to receive SIGIO. */
- arg = getpid();
- if (ioctl(fd, FIOSETOWN, &arg) == -1)
- errx(1, "ioctl: FIOSETOWN");
-
- /* The process group must be able to receive SIGIO. */
- arg = -getpgrp();
- if (ioctl(fd, FIOSETOWN, &arg) == -1)
- errx(1, "ioctl: FIOSETOWN");
-
- /* A bogus process must be rejected. */
- arg = 1000000;
- if (ioctl(fd, FIOSETOWN, &arg) != -1)
- errx(1, "ioctl: FIOSETOWN: bogus process accepted");
-
- /* A bogus process group must be rejected. */
- arg = -1000000;
- if (ioctl(fd, FIOSETOWN, &arg) != -1)
- errx(1, "ioctl: FIOSETOWN: bogus process group accepted");
+ return test_common_setown(fd, 1);
+}
- return 0;
+static int
+test_setown_ioctl(int fd)
+{
+ return test_common_setown(fd, 0);
}
static int
@@ -219,6 +207,54 @@ test_spgrp(int fd)
return 0;
}
+static int
+test_common_setown(int fd, int dofcntl)
+{
+ int arg;
+
+ /* The process must be able to receive SIGIO. */
+ arg = getpid();
+ if (dofcntl) {
+ if (fcntl(fd, F_SETOWN, arg) == -1)
+ errx(1, "fcntl: F_SETOWN: process rejected");
+ } else {
+ if (ioctl(fd, FIOSETOWN, &arg) == -1)
+ errx(1, "ioctl: FIOSETOWN: process rejected");
+ }
+
+ /* The process group must be able to receive SIGIO. */
+ arg = -getpgrp();
+ if (dofcntl) {
+ if (fcntl(fd, F_SETOWN, arg) == -1)
+ errx(1, "fcntl: F_SETOWN: process group rejected");
+ } else {
+ if (ioctl(fd, FIOSETOWN, &arg) == -1)
+ errx(1, "ioctl: FIOSETOWN: process group rejected");
+ }
+
+ /* A bogus process must be rejected. */
+ arg = 1000000;
+ if (dofcntl) {
+ if (fcntl(fd, F_SETOWN, arg) != -1)
+ errx(1, "fcntl: F_SETOWN: bogus process accepted");
+ } else {
+ if (ioctl(fd, FIOSETOWN, &arg) != -1)
+ errx(1, "ioctl: FIOSETOWN: bogus process accepted");
+ }
+
+ /* A bogus process group must be rejected. */
+ arg = -1000000;
+ if (dofcntl) {
+ if (fcntl(fd, F_SETOWN, arg) != -1)
+ errx(1, "fcntl: F_SETOWN: bogus process group accepted");
+ } else {
+ if (ioctl(fd, FIOSETOWN, &arg) != -1)
+ errx(1, "ioctl: FIOSETOWN: bogus process group accepted");
+ }
+
+ return 0;
+}
+
static void
sigio(int signo)
{