summaryrefslogtreecommitdiff
path: root/usr/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/test')
-rw-r--r--usr/src/test/os-tests/runfiles/default.run5
-rw-r--r--usr/src/test/os-tests/tests/Makefile3
-rw-r--r--usr/src/test/os-tests/tests/sdevfs/Makefile47
-rw-r--r--usr/src/test/os-tests/tests/sdevfs/sdevfs_eisdir.c73
4 files changed, 127 insertions, 1 deletions
diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run
index c209180fba..d2d5f502ed 100644
--- a/usr/src/test/os-tests/runfiles/default.run
+++ b/usr/src/test/os-tests/runfiles/default.run
@@ -11,6 +11,7 @@
#
# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2016 Joyent, Inc.
#
[DEFAULT]
@@ -42,6 +43,10 @@ tests = ['secflags_aslr',
[/opt/os-tests/tests/sigqueue]
tests = ['sigqueue_queue_size']
+[/opt/os-tests/tests/sdevfs]
+user = root
+tests = ['sdevfs_eisdir']
+
[/opt/os-tests/tests/tmpfs]
user = root
tests = ['tmpfs_badmount', 'tmpfs_enospc']
diff --git a/usr/src/test/os-tests/tests/Makefile b/usr/src/test/os-tests/tests/Makefile
index 991f3fde5b..fcbab56508 100644
--- a/usr/src/test/os-tests/tests/Makefile
+++ b/usr/src/test/os-tests/tests/Makefile
@@ -11,8 +11,9 @@
#
# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2016 Joyent, Inc.
#
-SUBDIRS = poll secflags sigqueue spoof-ras tmpfs file-locking
+SUBDIRS = poll secflags sigqueue spoof-ras sdevfs tmpfs file-locking
include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/os-tests/tests/sdevfs/Makefile b/usr/src/test/os-tests/tests/sdevfs/Makefile
new file mode 100644
index 0000000000..4d72e332b7
--- /dev/null
+++ b/usr/src/test/os-tests/tests/sdevfs/Makefile
@@ -0,0 +1,47 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/os-tests
+TESTDIR = $(ROOTOPTPKG)/tests/sdevfs
+
+PROGS = sdevfs_eisdir
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROGS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) *.o
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/os-tests/tests/sdevfs/sdevfs_eisdir.c b/usr/src/test/os-tests/tests/sdevfs/sdevfs_eisdir.c
new file mode 100644
index 0000000000..a1cc386ce7
--- /dev/null
+++ b/usr/src/test/os-tests/tests/sdevfs/sdevfs_eisdir.c
@@ -0,0 +1,73 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Joyent, Inc.
+ */
+
+/*
+ * open(2) should return EISDIR when asking for write access on a dir.
+ * This test should return the same results in both GZ and NGZ contexts.
+ */
+#include <stdio.h>
+#include <strings.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/debug.h>
+#include <sys/statvfs.h>
+
+#define SD_TEST_DIR "/dev/zvol"
+
+int
+main(int argc, char *argv[])
+{
+ struct stat st;
+ struct statvfs vfs;
+ int ret;
+
+ if (stat(SD_TEST_DIR, &st) != 0) {
+ fprintf(stderr, "test failed: failed to stat %s\n",
+ SD_TEST_DIR);
+ return (1);
+ }
+
+ if ((st.st_mode & S_IFMT) != S_IFDIR) {
+ fprintf(stderr, "test failed: %s is not a dir\n", SD_TEST_DIR);
+ return (1);
+ }
+
+ if (statvfs(SD_TEST_DIR, &vfs) != 0) {
+ fprintf(stderr, "test failed: failed to stat vfs for %s: %s\n",
+ SD_TEST_DIR, strerror(errno));
+ return (1);
+ }
+
+ if (strncmp("dev", vfs.f_basetype, FSTYPSZ) != 0) {
+ fprintf(stderr, "test failed: asked to run on non-dev\n");
+ return (1);
+ }
+
+ ret = open(SD_TEST_DIR, O_RDWR, 0);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, EISDIR);
+
+ /*
+ * It's important to test both O_RDWR and O_RDWR | O_CREAT
+ * because of the different code paths taken in sdev.
+ */
+ ret = open(SD_TEST_DIR, O_RDWR | O_CREAT, 0);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, EISDIR);
+
+ return (0);
+}