summaryrefslogtreecommitdiff
path: root/usr/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/test')
-rw-r--r--usr/src/test/Readme.smartos80
-rw-r--r--usr/src/test/libc-tests/runfiles/default.run2
-rw-r--r--usr/src/test/libc-tests/tests/Makefile1
-rw-r--r--usr/src/test/libc-tests/tests/env-OS-4089.c73
-rw-r--r--usr/src/test/libc-tests/tests/random/Makefile10
-rw-r--r--usr/src/test/os-tests/runfiles/default.run15
-rw-r--r--usr/src/test/os-tests/tests/Makefile61
-rw-r--r--usr/src/test/os-tests/tests/OS-6097.c74
-rw-r--r--usr/src/test/os-tests/tests/file-locking/Makefile9
-rw-r--r--usr/src/test/os-tests/tests/poll/Makefile4
-rw-r--r--usr/src/test/os-tests/tests/timer/Makefile50
-rw-r--r--usr/src/test/os-tests/tests/timer/timer_limit.c83
-rw-r--r--usr/src/test/os-tests/tests/tmpfs/Makefile52
-rw-r--r--usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh114
-rw-r--r--usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh74
-rw-r--r--usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c94
-rw-r--r--usr/src/test/test-runner/cmd/run54
-rw-r--r--usr/src/test/util-tests/runfiles/default.run10
-rw-r--r--usr/src/test/util-tests/tests/Makefile2
-rw-r--r--usr/src/test/util-tests/tests/bunyan/Makefile68
-rw-r--r--usr/src/test/util-tests/tests/bunyan/btest.c312
-rw-r--r--usr/src/test/util-tests/tests/bunyan/bunyan.ksh26
-rw-r--r--usr/src/test/util-tests/tests/dis/i386/32.avx512.out192
-rwxr-xr-xusr/src/test/util-tests/tests/dis/i386/32.avx512.s162
-rw-r--r--usr/src/test/util-tests/tests/dis/i386/64.avx512.out192
-rwxr-xr-xusr/src/test/util-tests/tests/dis/i386/64.avx512.s163
-rw-r--r--usr/src/test/util-tests/tests/dladm/Makefile6
-rw-r--r--usr/src/test/util-tests/tests/dladm/set-linkprop.ksh208
-rw-r--r--usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh82
-rw-r--r--usr/src/test/util-tests/tests/dladm/vnic-mtu.ksh116
-rw-r--r--usr/src/test/util-tests/tests/libnvpair_json/Makefile21
-rw-r--r--usr/src/test/util-tests/tests/libnvpair_json/json_08_large_data.ksh37
-rw-r--r--usr/src/test/util-tests/tests/libsff/Makefile81
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff.ksh61
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8472.c61
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8472.out255
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_diag.c61
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_diag.out2
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.c62
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.out255
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c79
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_tech.out96
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_temp.c61
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_8636_temp.out255
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_br.c133
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_br.out8
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_compliance.c124
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_compliance.out130
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_conn.c89
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_conn.out514
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_efault.c54
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_einval.c88
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_enc.c89
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_enc.out514
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_ident.c60
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_ident.out255
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_lengths.c133
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_lengths.out15
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_opts.c98
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_opts.out50
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_strings.c133
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_wave.c177
-rw-r--r--usr/src/test/util-tests/tests/libsff/libsff_wave.out11
-rw-r--r--usr/src/test/util-tests/tests/mergeq/Makefile64
-rw-r--r--usr/src/test/util-tests/tests/mergeq/mqt.c217
-rw-r--r--usr/src/test/util-tests/tests/workq/Makefile64
-rw-r--r--usr/src/test/util-tests/tests/workq/wqt.c196
67 files changed, 6953 insertions, 39 deletions
diff --git a/usr/src/test/Readme.smartos b/usr/src/test/Readme.smartos
new file mode 100644
index 0000000000..9c413aba2f
--- /dev/null
+++ b/usr/src/test/Readme.smartos
@@ -0,0 +1,80 @@
+#
+# 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 2017, Joyent, Inc.
+#
+
+I) Introduction
+
+The procedure to run the illumos tests under SmartOS is unlike that for
+other distributions because of the zone-centric nature of the distribution,
+and because there is no built-in package management for the global zone.
+
+This Readme assumes you will run the tests in the global zone, as root.
+Although it is possible to run some of the tests within a non-global zone, as a
+user configured within that zone, that approach is not described here.
+
+Some test suites, such as the ZFS tests, assume there are available disks to
+use for the test run. This configuration is not currently available on a
+standard SmartOS installation, where all of the disks are already setup in the
+"zones" zpool, so these tests are not runnable at this time. The ZFS tests
+also are required to run as a non-root user, and that is non-standard for a
+SmartOS global zone, where any user created is lost on reboot.
+
+II) Setup to Run the Tests
+
+1) The tests currently require python27 to run, so you need to install this in
+ the global zone. The easiest way to do this is with pkgsrc using the
+ following procedure:
+
+ a) Get a copy of the following bootstrap tarball onto the test machine:
+ https://pkgsrc.joyent.com/packages/SmartOS/bootstrap/bootstrap-2014Q4-multiarch.tar.gz
+
+ b) Install the bootstrap tarball:
+ # gzcat bootstrap-2014Q4-multiarch.tar.gz | (cd /; tar -xpf -)
+
+ c) Install python27:
+ pkgin in python27
+
+2) You need to get the tests from your build machine onto the test machine's
+ global zone. This can be done in whatever way is easiest for you. Here is
+ one simple way:
+
+ a) On your build machine, in your fully built smartos-live proto area,
+ create a tarball of the test directory:
+ % cd proto/opt
+ % tar czf ../opt.tgz *
+
+
+ b) Copy the tarball from the build machine to the test machine running
+ SmartOS (the next step assumes you placed the tarball into the /zones
+ directory).
+
+3) In the global zone on your test machine, install the tests.
+
+ # cd /opt
+ # tar xf /zones/opt.tgz
+
+III) Run the Tests
+
+Now that setup is complete, you can run the tests using the normal procedure.
+For example:
+
+ # /opt/util-tests/bin/utiltest
+or
+ # /opt/os-tests/bin/ostest
+
+IV) Running New Tests
+
+During development, if you are creating or updating new tests, you can repeat
+steps 2 and 3 as often as necessary to make the new tests available on the test
+machine.
diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run
index 93a394782b..b18622c607 100644
--- a/usr/src/test/libc-tests/runfiles/default.run
+++ b/usr/src/test/libc-tests/runfiles/default.run
@@ -71,6 +71,8 @@ timeout = 600
[/opt/libc-tests/tests/call_once.32]
[/opt/libc-tests/tests/call_once.64]
[/opt/libc-tests/tests/catopen]
+[/opt/libc-tests/tests/env-OS-4089.32]
+[/opt/libc-tests/tests/env-OS-4089.64]
[/opt/libc-tests/tests/env-7076.32]
[/opt/libc-tests/tests/env-7076.64]
[/opt/libc-tests/tests/endian.32]
diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile
index 160e9a9383..e3105cf36b 100644
--- a/usr/src/test/libc-tests/tests/Makefile
+++ b/usr/src/test/libc-tests/tests/Makefile
@@ -31,6 +31,7 @@ SUBDIRS = \
wctype
PROGS = \
+ env-OS-4089 \
aligned_alloc \
c11_threads \
c11_tss \
diff --git a/usr/src/test/libc-tests/tests/env-OS-4089.c b/usr/src/test/libc-tests/tests/env-OS-4089.c
new file mode 100644
index 0000000000..0f52201c79
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/env-OS-4089.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.
+ */
+
+/*
+ * Regression test for OS-4089 where doing a putenv() call without an '=' sign
+ * may lead to a segmentation fault when doing a getenv() depending on the
+ * circumstances of the environment's layout. Verify putenv() mimics
+ * unsetenv().
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/debug.h>
+
+int
+main(void)
+{
+ if (putenv("FOO=bar") != 0) {
+ fprintf(stderr, "failed to put FOO into the environment: %s\n",
+ strerror(errno));
+ return (1);
+ }
+
+ if (getenv("FOO") == NULL) {
+ fprintf(stderr, "failed to retrieve FOO from the "
+ "environment!\n");
+ return (1);
+ }
+
+ VERIFY0(unsetenv("FOO"));
+
+ if (getenv("FOO") != NULL) {
+ fprintf(stderr, "Somehow retrieved FOO from the "
+ "environment after unsetenv()!\n");
+ return (1);
+ }
+
+ if (putenv("FOO=bar") != 0) {
+ fprintf(stderr, "failed to put FOO into the environment: %s\n",
+ strerror(errno));
+ return (1);
+ }
+
+ if (getenv("FOO") == NULL) {
+ fprintf(stderr, "failed to retrieve FOO from the "
+ "environment!\n");
+ return (1);
+ }
+
+ VERIFY0(putenv("FOO"));
+
+ if (getenv("FOO") != NULL) {
+ fprintf(stderr, "Somehow retrieved FOO from the "
+ "environment after putenv()!\n");
+ return (1);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/libc-tests/tests/random/Makefile b/usr/src/test/libc-tests/tests/random/Makefile
index ed480dacb9..c1a1a18e1f 100644
--- a/usr/src/test/libc-tests/tests/random/Makefile
+++ b/usr/src/test/libc-tests/tests/random/Makefile
@@ -17,7 +17,6 @@ include $(SRC)/Makefile.master
ROOTOPTPKG = $(ROOT)/opt/libc-tests
TESTDIR = $(ROOTOPTPKG)/tests/random
-ROOTBINDIR = $(ROOTOPTPKG)/bin
PROGS = arc4random \
arc4random_prefork \
@@ -74,17 +73,12 @@ arc4random_preforksig: arc4random_forksig.c
$(POST_PROCESS)
chacha: chacha_tv.c
- $(COMPILE.c) -DKEYSTREAM_ONLY -I$(SRC)/common/crypto/chacha -o chacha.o -c $(SRC)/common/crypto/chacha/chacha.c
+ $(COMPILE.c) -DKEYSTREAM_ONLY -I$(SRC)/common/crypto/chacha \
+ -o chacha.o -c $(SRC)/common/crypto/chacha/chacha.c
$(COMPILE.c) -I$(SRC)/common/crypto/chacha -o chacha_tv.o -c chacha_tv.c
$(LINK.c) -o $@ chacha_tv.o chacha.o $(LDLIBS)
$(POST_PROCESS)
-$(ROOTBINDIR):
- $(INS.dir)
-
-$(ROOTBINDIR)/%: %
- $(INS.file)
-
$(TESTDIR):
$(INS.dir)
diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run
index 9f3c83b874..2d99f9ae94 100644
--- a/usr/src/test/os-tests/runfiles/default.run
+++ b/usr/src/test/os-tests/runfiles/default.run
@@ -11,7 +11,7 @@
#
# Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2017 Joyent, Inc.
#
[DEFAULT]
@@ -22,7 +22,7 @@ timeout = 60
post =
outputdir = /var/tmp/test_results
-[/opt/os-tests/tests/poll_test]
+[/opt/os-tests/tests/poll]
user = root
tests = ['poll_test', 'epoll_test']
@@ -48,6 +48,14 @@ tests = ['sigqueue_queue_size']
user = root
tests = ['sdevfs_eisdir']
+[/opt/os-tests/tests/timer]
+user = root
+tests = ['timer_limit']
+
+[/opt/os-tests/tests/tmpfs]
+user = root
+tests = ['tmpfs_badmount', 'tmpfs_enospc']
+
[/opt/os-tests/tests/stress]
user = root
tests = ['dladm-kstat']
@@ -58,3 +66,6 @@ tests = ['runtests.32', 'runtests.64']
[/opt/os-tests/tests/sockfs]
user = root
tests = ['conn', 'dgram', 'drop_priv', 'sockpair']
+
+[/opt/os-tests/tests/OS-6097.32]
+[/opt/os-tests/tests/OS-6097.64]
diff --git a/usr/src/test/os-tests/tests/Makefile b/usr/src/test/os-tests/tests/Makefile
index 77af406120..cb792c7a23 100644
--- a/usr/src/test/os-tests/tests/Makefile
+++ b/usr/src/test/os-tests/tests/Makefile
@@ -11,8 +11,65 @@
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+# Copyright 2016 Joyent, Inc.
#
-SUBDIRS = poll secflags sigqueue spoof-ras sdevfs sockfs stress file-locking
+SUBDIRS = poll secflags sigqueue spoof-ras sdevfs sockfs stress timer tmpfs \
+ file-locking
-include $(SRC)/test/Makefile.com
+PROGS = \
+ OS-6097
+
+PROGS32 = $(PROGS:%=%.32)
+PROGS64 = $(PROGS:%=%.64)
+
+OS-6097.32 := LDLIBS += -ldlpi
+OS-6097.64 := LDLIBS64 += -ldlpi
+
+ROOTOPTDIR = $(ROOT)/opt/os-tests/tests
+ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTDIR)/%) \
+ $(PROGS64:%=$(ROOTOPTDIR)/%) \
+ $(SCRIPTS:%=$(ROOTOPTDIR)/%)
+
+include $(SRC)/cmd/Makefile.cmd
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+install: $(SUBDIRS) $(ROOTOPTPROGS)
+
+all: $(SUBDIRS) $(PROGS32) $(PROGS64)
+
+clean lint: $(SUBDIRS)
+
+$(ROOTOPTPROGS): $(PROGS32) $(PROGS64) $(ROOTOPTDIR)
+
+$(ROOTOPTDIR):
+ $(INS.dir)
+
+$(ROOTOPTDIR)/%: %
+ $(INS.file)
+
+$(ROOTOPTDIR)/%: %.ksh
+ $(INS.rename)
+
+%.64: %.c
+ $(LINK64.c) -o $@ $< $(LDLIBS64)
+ $(POST_PROCESS)
+
+%.32: %.c
+ $(LINK.c) -o $@ $< $(LDLIBS)
+ $(POST_PROCESS)
+
+clobber: $(SUBDIRS)
+ $(RM) $(PROGS32) $(PROGS64)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
diff --git a/usr/src/test/os-tests/tests/OS-6097.c b/usr/src/test/os-tests/tests/OS-6097.c
new file mode 100644
index 0000000000..160c01e9c7
--- /dev/null
+++ b/usr/src/test/os-tests/tests/OS-6097.c
@@ -0,0 +1,74 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Regression test for OS-6097.
+ */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <libdlpi.h>
+#include <sys/debug.h>
+
+int
+main(void)
+{
+ int ret;
+ char path[4096];
+ uint_t num = 4294967294U;
+ dlpi_handle_t dh;
+
+ /*
+ * First, we need to determine a path that doesn't exist to trigger this
+ * bug. We start with the highest possible number and just decrement
+ * until we find something.
+ */
+
+ while (num > 0) {
+ struct stat st;
+
+ (void) snprintf(path, sizeof (path), "/dev/net/net%u", num);
+
+ ret = stat(path, &st);
+ if (ret == -1 && errno == ENOENT)
+ break;
+ if (ret == -1) {
+ (void) fprintf(stderr, "test failed: unexpected error "
+ "running stat(2) on %s: %s\n", path,
+ strerror(errno));
+ return (1);
+ }
+ num--;
+ }
+
+ /*
+ * While technically this is a valid entry that we could try, at this
+ * point we've exhausted so many NICs, there's likely a bug.
+ */
+ if (num == 0) {
+ (void) fprintf(stderr, "failed to construct a non-existent "
+ "NIC with a name starting with 'net'\n");
+ return (1);
+ }
+
+ (void) snprintf(path, sizeof (path), "net%u", num);
+ ret = dlpi_open(path, &dh, 0);
+ VERIFY3U(ret, ==, DLPI_ENOLINK);
+ return (0);
+}
diff --git a/usr/src/test/os-tests/tests/file-locking/Makefile b/usr/src/test/os-tests/tests/file-locking/Makefile
index d85b20c365..1773f652a5 100644
--- a/usr/src/test/os-tests/tests/file-locking/Makefile
+++ b/usr/src/test/os-tests/tests/file-locking/Makefile
@@ -28,6 +28,9 @@ SRCS = $(PROGS:%=%.c) $(UTILS)
PROGS32 = $(PROGS:%=%.32)
PROGS64 = $(PROGS:%=%.64)
+runtests.32 := LDLIBS += -lgen
+runtests.64 := LDLIBS64 += -lgen
+
LINTS = $(PROGS:%=%.ln)
LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
@@ -36,6 +39,12 @@ ROOTOPTDIR = $(ROOT)/opt/os-tests/tests/file-locking
ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTDIR)/%) \
$(PROGS64:%=$(ROOTOPTDIR)/%)
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
.KEEP_STATE:
install: $(ROOTOPTPROGS)
diff --git a/usr/src/test/os-tests/tests/poll/Makefile b/usr/src/test/os-tests/tests/poll/Makefile
index 14cc28b056..378b7e7490 100644
--- a/usr/src/test/os-tests/tests/poll/Makefile
+++ b/usr/src/test/os-tests/tests/poll/Makefile
@@ -11,7 +11,7 @@
#
# Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2017 Joyent, Inc.
#
include $(SRC)/cmd/Makefile.cmd
@@ -26,7 +26,7 @@ poll_test.ln := LDLIBS += -lsocket
C99MODE = -xc99=%all
ROOTOPTPKG = $(ROOT)/opt/os-tests
-TESTDIR = $(ROOTOPTPKG)/tests
+TESTDIR = $(ROOTOPTPKG)/tests/poll
CMDS = $(PROG:%=$(TESTDIR)/%)
$(CMDS) := FILEMODE = 0555
diff --git a/usr/src/test/os-tests/tests/timer/Makefile b/usr/src/test/os-tests/tests/timer/Makefile
new file mode 100644
index 0000000000..dd85b0caf8
--- /dev/null
+++ b/usr/src/test/os-tests/tests/timer/Makefile
@@ -0,0 +1,50 @@
+#
+# 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/timer
+
+PROGS = timer_limit
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+C99MODE = -xc99=%all
+
+
+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/timer/timer_limit.c b/usr/src/test/os-tests/tests/timer/timer_limit.c
new file mode 100644
index 0000000000..77473c806f
--- /dev/null
+++ b/usr/src/test/os-tests/tests/timer/timer_limit.c
@@ -0,0 +1,83 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <time.h>
+#include <limits.h>
+#include <assert.h>
+#include <sys/sysconfig.h>
+#include <sys/sysmacros.h>
+
+/* Need direct access to _sysconfig to query NCPU */
+extern long _sysconfig(int);
+
+
+static int
+mktimer(timer_t *timer)
+{
+ struct sigevent sev;
+ sev.sigev_notify = SIGEV_SIGNAL;
+ sev.sigev_signo = SIGRTMIN;
+ sev.sigev_value.sival_ptr = timer;
+
+ return (timer_create(CLOCK_MONOTONIC, &sev, timer));
+}
+
+int
+main()
+{
+ long ncpu;
+ size_t limit;
+ timer_t *timers, timer_overage;
+
+ /* Query NCPU with private sysconfig param */
+ ncpu = _sysconfig(_CONFIG_NPROC_NCPU);
+ assert(ncpu > 0 && ncpu < INT32_MAX);
+
+ /* Current specified limit is 4 * NCPU */
+ limit = 4 * ncpu;
+ timers = calloc(limit + 1, sizeof (timer_t));
+ assert(timers != NULL);
+
+ /* Slowly walk up to the limit doing creations/deletions */
+ for (int i = 1; i <= limit; i = MIN(limit, i*2)) {
+ for (int j = 0; j < i; j++) {
+ assert(mktimer(&timers[j]) == 0);
+ }
+
+ /*
+ * Attempt to allocate one additional timer if we've reached
+ * the assumed limit.
+ */
+ if (i == limit) {
+ assert(mktimer(&timer_overage) == -1);
+ }
+
+ for (int j = 0; j < i; j++) {
+ assert(timer_delete(timers[j]) == 0);
+ }
+
+ /* Bail out if we've finished at the limit */
+ if (i == limit)
+ break;
+ }
+
+
+ return (0);
+}
diff --git a/usr/src/test/os-tests/tests/tmpfs/Makefile b/usr/src/test/os-tests/tests/tmpfs/Makefile
new file mode 100644
index 0000000000..d6515b38fa
--- /dev/null
+++ b/usr/src/test/os-tests/tests/tmpfs/Makefile
@@ -0,0 +1,52 @@
+#
+# 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/tmpfs
+
+PROGS = tmpfs_full
+SCRIPTS = tmpfs_badmount \
+ tmpfs_enospc
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%) $(SCRIPTS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+all: $(PROGS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) *.o
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %.ksh
+ $(INS.rename)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh b/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh
new file mode 100644
index 0000000000..7e2c4a6095
--- /dev/null
+++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh
@@ -0,0 +1,114 @@
+#!/usr/bin/ksh
+#
+# 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.
+#
+
+#
+# Test various options to try and mount a tmpfs. Aside from the first to
+# verify that we can mount tmpfs at all, these should all fail.
+#
+
+tb_arg0=$(basename $0)
+tb_mountpoint="/var/tmp/$0.$$"
+tb_mount=/usr/sbin/mount
+tb_umount=/usr/sbin/umount
+
+function fatal
+{
+ rmdir $tb_mountpoint
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="test failed"
+ echo "$tb_arg0: test failed $msg" >&2
+ exit 1
+}
+
+function check_mount
+{
+ mkdir -p $tb_mountpoint || fatal \
+ "failed to make mountpoint $tb_mountpoint"
+ $tb_mount -F tmpfs swap $tb_mountpoint || fatal \
+ "failed to mount tmpfs, check user perms"
+ $tb_umount $tb_mountpoint || fatal \
+ "failed to unmount test point"
+}
+
+function test_one
+{
+ typeset opts=$1
+
+ [[ -z "$opts" ]] && fatal "missing required opts"
+ $tb_mount -F tmpfs -o $opts swap $tb_mountpoint 2>/dev/null
+ if [[ $? -eq 0 ]]; then
+ $tb_umount $tb_mountpoint
+ fatal "successfully mounted with opts $opts, expected failure"
+ fi
+}
+
+check_mount
+
+#
+# Test invalid percentages.
+#
+test_one "size=-5%"
+test_one "size=200%"
+test_one "size=55.55555%"
+test_one "size=100.0%"
+test_one "size=bad%"
+test_one "size=30g%"
+test_one "size=%"
+test_one "size=%wat"
+
+#
+# Test invalid sizes. Only kmg are valid prefixes.
+#
+test_one "size=hello;world"
+test_one "size=0xnope"
+test_one "size=3.14g"
+test_one "size=3;14"
+test_one "size=thisisanormalsize"
+test_one "size="
+test_one "size=100mtry"
+
+#
+# Now, we need to try and trigger a bunch of overflow. We're going to do
+# this assuming we're on a 64-bit kernel (which will always overflow a
+# 32-bit kernel).
+#
+test_one "size=20000000000000000000"
+test_one "size=1ggggggggggggggggggg"
+test_one "size=1mmmmmmmmmmmmmmmmmmm"
+test_one "size=1kkkkkkkkkkkkkkkkkkk"
+test_one "size=1kkkkkkkkkkkkkkkkkkk"
+test_one "size=18014398509481983k"
+test_one "size=17592186044416m"
+test_one "size=17179869185g"
+test_one "size=17179869184g"
+
+#
+# Let's throw a couple bad modes around while we're here.
+#
+test_one "mode=17777"
+test_one "mode=27777"
+test_one "mode=37777"
+test_one "mode=47777"
+test_one "mode=57777"
+test_one "mode=67777"
+test_one "mode=77777"
+test_one "mode=87777"
+test_one "mode=97777"
+test_one "mode=asdf"
+test_one "mode=deadbeef"
+test_one "mode=kefka"
+
+rmdir $tb_mountpoint
diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh b/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh
new file mode 100644
index 0000000000..a285f306e2
--- /dev/null
+++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh
@@ -0,0 +1,74 @@
+#!/usr/bin/ksh
+#
+# 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.
+#
+
+#
+# Verify that if we fill up a tmpfs that we can't then perform
+# additional things to it that would result in the creation or use of
+# kernel memory.
+#
+
+te_arg0=$(basename $0)
+te_root=$(dirname $0)
+te_bin=$te_root/tmpfs_full
+te_mountpoint="/var/tmp/$0.$$"
+te_mount=/usr/sbin/mount
+te_umount=/usr/sbin/umount
+te_testfile=1m
+te_mounted=
+te_exit=1
+
+function fatal
+{
+ [[ -n "$te_mounted" ]] && $te_umount $te_mountpoint
+ rmdir $te_mountpoint
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="test failed"
+ echo "$te_arg0: test failed $msg" >&2
+ exit 1
+}
+
+function setup
+{
+ typeset ofile=$te_mountpoint/$te_testfile
+
+ mkdir -p $te_mountpoint || fatal \
+ "failed to make mountpoint $te_mountpoint"
+ $te_mount -F tmpfs swap $te_mountpoint || fatal \
+ "failed to mount tmpfs, check user perms"
+ te_mounted=1
+ dd if=/dev/zero of=$ofile bs=1M count=1 2>/dev/null || fatal \
+ "failed to create a 1 MB file"
+ $te_mount -F tmpfs -o remount,size=512k swap $te_mountpoint ||
+ fatal "failed to remount tmpfs"
+}
+
+function run_test
+{
+ $te_bin $te_mountpoint $te_testfile || fatal "$te_bin failed"
+}
+
+function cleanup
+{
+ te_mounted=
+ $te_umount $te_mountpoint || fatal "failed to unmount $te_mountpoint"
+ rmdir $te_mountpoint || fatal "failed to remove $te_mountpoint"
+}
+
+setup
+run_test
+cleanup
+
+exit 0
diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c b/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c
new file mode 100644
index 0000000000..6c6037710b
--- /dev/null
+++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/*
+ * Given a path to a tmpfs that has already been marked as full, attempt to
+ * perform certain activities on it, all of which should fail with ENOSPC.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <strings.h>
+#include <sys/debug.h>
+#include <unistd.h>
+
+int
+main(int argc, const char *argv[])
+{
+ int fd, ret;
+ struct statvfs vfs;
+
+ if (argc != 3) {
+ fprintf(stderr, "test failed: missing path or file\n");
+ return (1);
+ }
+
+ if ((fd = open(argv[1], O_RDONLY)) < 0) {
+ fprintf(stderr, "test failed: failed to open root %s: %s\n",
+ argv[1], strerror(errno));
+ return (1);
+ }
+
+ if (fstatvfs(fd, &vfs) != 0) {
+ fprintf(stderr, "test failed: failed to stat vfs for %s: %s\n",
+ argv[1], strerror(errno));
+ return (1);
+ }
+
+ if (strncmp("tmpfs", vfs.f_basetype, FSTYPSZ) != 0) {
+ fprintf(stderr, "test failed: asked to run on non-tmpfs\n");
+ return (1);
+ }
+
+ /*
+ * Once a few additional bugs in tmpfs are fixed, we should double check
+ * and make sure that the free space here is actually zero before
+ * continuing.
+ */
+
+ /*
+ * Go through operations that would create nodes and make sure that they
+ * all fail.
+ */
+
+ ret = openat(fd, "Mnemosyne", O_RDWR | O_CREAT, 0755);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, ENOSPC);
+
+ ret = mkdirat(fd, "Euterpe", 0775);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, ENOSPC);
+
+ ret = symlinkat("/dev/null", fd, "Melpomene");
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, ENOSPC);
+
+ ret = linkat(fd, argv[2], fd, "Urania", 0);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, ENOSPC);
+
+ /*
+ * Make sure we can't create open extended attributes.
+ */
+ ret = openat(fd, "Lethe", O_RDWR | O_CREAT | O_XATTR);
+ VERIFY3S(ret, ==, -1);
+ VERIFY3S(errno, ==, ENOSPC);
+
+ return (0);
+}
diff --git a/usr/src/test/test-runner/cmd/run b/usr/src/test/test-runner/cmd/run
index 306f382e4a..bc7ce6734e 100644
--- a/usr/src/test/test-runner/cmd/run
+++ b/usr/src/test/test-runner/cmd/run
@@ -12,6 +12,7 @@
#
#
+# Copyright 2017 Joyent, Inc.
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
@@ -35,6 +36,7 @@ BASEDIR = '/var/tmp/test_results'
KILL = '/usr/bin/kill'
TRUE = '/usr/bin/true'
SUDO = '/usr/bin/sudo'
+SU = '/usr/bin/su'
# Custom class to reopen the log file in case it is forcibly closed by a test.
class WatchedFileHandlerClosed(WatchedFileHandler):
@@ -162,7 +164,21 @@ class Cmd(object):
sudo is required, this user was verified previously.
"""
self.killed = True
- do_sudo = len(self.user) != 0
+ cur_user = getpwuid(os.getuid()).pw_name
+
+ #
+ # The test runs in a child process of the process performing
+ # the kill and this child process may be owned by a different
+ # user (specified by self.user). If this is the case, and the
+ # parent process is not running as root, then sudo must be
+ # used. The verify_user function should prevent us from ever
+ # getting here on a system which doesn't have sudo.
+ #
+ if len(self.user) != 0 and self.user != cur_user and cur_user != 'root':
+ do_sudo = True
+ else:
+ do_sudo = False
+
signal = '-TERM'
cmd = [SUDO, KILL, signal, str(proc.pid)]
@@ -178,15 +194,23 @@ class Cmd(object):
def update_cmd_privs(self, cmd, user):
"""
If a user has been specified to run this Cmd and we're not already
- running as that user, prepend the appropriate sudo command to run
- as that user.
+ running as that user, prepend the appropriate sudo command to
+ run as that user. If running as root use su instead. The
+ verify_user function should prevent us from ever getting here
+ on a system which doesn't have sudo.
+
"""
- me = getpwuid(os.getuid())
- if not user or user is me:
+ cur_user = getpwuid(os.getuid()).pw_name
+
+ if not user or user == cur_user:
return cmd
- ret = '%s -E -u %s %s' % (SUDO, user, cmd)
+ if cur_user == 'root':
+ ret = '%s %s -c %s' % (SU, user, cmd)
+ else:
+ ret = '%s -E -u %s %s' % (SUDO, user, cmd)
+
return ret.split(' ')
def collect_output(self, proc):
@@ -741,14 +765,28 @@ def verify_file(pathname):
def verify_user(user, logger):
"""
- Verify that the specified user exists on this system, and can execute
- sudo without being prompted for a password.
+ Verify that the specified user exists on this system, and can
+ execute sudo without being prompted for a password. If the user
+ executing the test is the same as the requested user then this
+ check is skipped. If the user executing the test is root this
+ check is skipped as su can be used instead.
"""
+
testcmd = [SUDO, '-n', '-u', user, TRUE]
if user in Cmd.verified_users:
return True
+ cur_user = getpwuid(os.getuid()).pw_name
+
+ if user == cur_user or cur_user == 'root':
+ Cmd.verified_users.append(user)
+ return True
+
+ if not os.path.isfile(SUDO):
+ logger.info("Warning: this test requires sudo but it doesn't exist.")
+ return False
+
try:
_ = getpwnam(user)
except KeyError:
diff --git a/usr/src/test/util-tests/runfiles/default.run b/usr/src/test/util-tests/runfiles/default.run
index 3f7498e23b..e40b486a85 100644
--- a/usr/src/test/util-tests/runfiles/default.run
+++ b/usr/src/test/util-tests/runfiles/default.run
@@ -24,9 +24,19 @@ outputdir = /var/tmp/test_results
[/opt/util-tests/tests/printf_test]
[/opt/util-tests/tests/allowed-ips]
+[/opt/util-tests/tests/set-linkprop]
+[/opt/util-tests/tests/show-overlay-exit]
+[/opt/util-tests/tests/vnic-mtu]
+[/opt/util-tests/tests/bunyan/bunyan]
+[/opt/util-tests/tests/libsff/libsff]
[/opt/util-tests/tests/xargs_test]
+[/opt/util-tests/tests/mergeq/mqt]
+[/opt/util-tests/tests/mergeq/wqt]
+
+[/opt/util-tests/tests/dis/distest]
+
[/opt/util-tests/tests/libnvpair_json]
tests = ['json_00_blank', 'json_01_boolean', 'json_02_numbers',
'json_03_empty_arrays', 'json_04_number_arrays', 'json_05_strings',
diff --git a/usr/src/test/util-tests/tests/Makefile b/usr/src/test/util-tests/tests/Makefile
index 9cfa699093..f4b7b90daf 100644
--- a/usr/src/test/util-tests/tests/Makefile
+++ b/usr/src/test/util-tests/tests/Makefile
@@ -14,6 +14,6 @@
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
#
-SUBDIRS = dis dladm iconv libnvpair_json printf xargs
+SUBDIRS = dis dladm iconv libnvpair_json libsff printf xargs bunyan mergeq workq
include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/util-tests/tests/bunyan/Makefile b/usr/src/test/util-tests/tests/bunyan/Makefile
new file mode 100644
index 0000000000..5f58bf1614
--- /dev/null
+++ b/usr/src/test/util-tests/tests/bunyan/Makefile
@@ -0,0 +1,68 @@
+#
+# 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 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/util-tests
+TESTDIR = $(ROOTOPTPKG)/tests/bunyan
+TESTBIN = $(ROOTOPTPKG)/bin
+
+PROG = btest
+
+SCRIPTS = \
+ bunyan
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+OBJS = $(PROG:%=%.o)
+SRCS = $(OBJS:%.o=%.c)
+
+CMDS = $(PROG:%=$(TESTBIN)/%) $(SCRIPTS:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+DIRS = $(TESTDIR) $(TESTBIN)
+
+LDLIBS += -lbunyan
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+ $(POST_PROCESS)
+
+install: all $(CMDS)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(OBJS)
+
+$(CMDS): $(DIRS)
+
+$(DIRS):
+ $(INS.dir)
+
+$(TESTDIR)/%: %.ksh
+ $(INS.rename)
+
+$(TESTDIR)/%: %
+ $(INS.file)
+
+$(TESTBIN)/%: %
+ $(INS.file)
diff --git a/usr/src/test/util-tests/tests/bunyan/btest.c b/usr/src/test/util-tests/tests/bunyan/btest.c
new file mode 100644
index 0000000000..5239e91f1e
--- /dev/null
+++ b/usr/src/test/util-tests/tests/bunyan/btest.c
@@ -0,0 +1,312 @@
+/*
+ * 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 (c) 2014, Joyent, Inc.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <bunyan.h>
+#include <netinet/in.h>
+#include <strings.h>
+
+static void
+create_handles(void)
+{
+ bunyan_logger_t *a, *b, *c;
+
+ assert(bunyan_init("foo", &a) == 0);
+ assert(bunyan_init("foo", &b) == 0);
+ assert(bunyan_init("foo", &c) == 0);
+ bunyan_fini(a);
+ bunyan_fini(b);
+ bunyan_fini(c);
+}
+
+static void
+create_stream(void)
+{
+ bunyan_logger_t *a;
+
+ assert(bunyan_init("foo", &a) == 0);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "baz", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == EEXIST);
+ assert(bunyan_stream_add(a, "baz", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == EEXIST);
+ assert(bunyan_stream_remove(a, "baz") == 0);
+ assert(bunyan_stream_remove(a, "baz") == ENOENT);
+ assert(bunyan_stream_remove(a, "foobaz") == ENOENT);
+ assert(bunyan_stream_remove(a, "blah") == ENOENT);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == EEXIST);
+ assert(bunyan_stream_add(a, "baz", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "debug", BUNYAN_L_DEBUG,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "info", BUNYAN_L_INFO,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "warn", BUNYAN_L_WARN,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "error", BUNYAN_L_ERROR,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_stream_add(a, "fatal", BUNYAN_L_FATAL,
+ bunyan_stream_fd, (void *)1) == 0);
+
+ bunyan_fini(a);
+}
+
+static void
+create_key(void)
+{
+ bunyan_logger_t *a;
+ struct in_addr v4;
+ struct in6_addr v6;
+
+ assert(bunyan_init("foo", &a) == 0);
+ assert(bunyan_key_remove(a, "blah") == ENOENT);
+ assert(bunyan_key_add(a, BUNYAN_T_END) == 0);
+
+ assert(bunyan_key_add(a, BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+
+ assert(bunyan_key_remove(a, "s") == 0);
+ assert(bunyan_key_remove(a, "s") == ENOENT);
+ assert(bunyan_key_remove(a, "p") == 0);
+ assert(bunyan_key_remove(a, "p") == ENOENT);
+ assert(bunyan_key_remove(a, "v4") == 0);
+ assert(bunyan_key_remove(a, "v4") == ENOENT);
+ assert(bunyan_key_remove(a, "v6") == 0);
+ assert(bunyan_key_remove(a, "v6") == ENOENT);
+ assert(bunyan_key_remove(a, "b") == 0);
+ assert(bunyan_key_remove(a, "b") == ENOENT);
+ assert(bunyan_key_remove(a, "i32") == 0);
+ assert(bunyan_key_remove(a, "i32") == ENOENT);
+ assert(bunyan_key_remove(a, "i64") == 0);
+ assert(bunyan_key_remove(a, "i64") == ENOENT);
+ assert(bunyan_key_remove(a, "u32") == 0);
+ assert(bunyan_key_remove(a, "u32") == ENOENT);
+ assert(bunyan_key_remove(a, "u64") == 0);
+ assert(bunyan_key_remove(a, "u64") == ENOENT);
+ assert(bunyan_key_remove(a, "d") == 0);
+ assert(bunyan_key_remove(a, "d") == ENOENT);
+ assert(bunyan_key_remove(a, "i64s") == 0);
+ assert(bunyan_key_remove(a, "i64s") == ENOENT);
+ assert(bunyan_key_remove(a, "u64s") == 0);
+ assert(bunyan_key_remove(a, "u64s") == ENOENT);
+
+ bunyan_fini(a);
+}
+
+static void
+bad_level(void)
+{
+ bunyan_logger_t *a;
+
+ assert(bunyan_init("bad level", &a) == 0);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_TRACE - 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_TRACE + 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_DEBUG - 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_INFO + 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_WARN - 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_ERROR + 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", BUNYAN_L_FATAL - 1,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+ assert(bunyan_stream_add(a, "bar", -5,
+ bunyan_stream_fd, (void *)1) == EINVAL);
+
+ bunyan_fini(a);
+}
+
+static void
+basic_log(void)
+{
+ bunyan_logger_t *a;
+
+ assert(bunyan_init("basic", &a) == 0);
+ assert(bunyan_stream_add(a, "foo", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_trace(a, "trace", BUNYAN_T_END) == 0);
+ assert(bunyan_debug(a, "debug", BUNYAN_T_END) == 0);
+ assert(bunyan_info(a, "info", BUNYAN_T_END) == 0);
+ assert(bunyan_warn(a, "warn", BUNYAN_T_END) == 0);
+ assert(bunyan_error(a, "error", BUNYAN_T_END) == 0);
+ assert(bunyan_fatal(a, "fatal", BUNYAN_T_END) == 0);
+
+ bunyan_fini(a);
+}
+
+static void
+crazy_log(void)
+{
+ bunyan_logger_t *a;
+ struct in_addr v4;
+ struct in6_addr v6;
+
+ bzero(&v4, sizeof (struct in_addr));
+ bzero(&v6, sizeof (struct in6_addr));
+
+ assert(bunyan_init("basic", &a) == 0);
+ assert(bunyan_stream_add(a, "foo", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_trace(a, "trace", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_debug(a, "debug", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_info(a, "info", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_warn(a, "warn", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_error(a, "error", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_fatal(a, "fatal", BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+
+ bunyan_fini(a);
+}
+
+static void
+child_log(void)
+{
+ bunyan_logger_t *a, *child;
+ struct in_addr v4;
+ struct in6_addr v6;
+
+ bzero(&v4, sizeof (struct in_addr));
+ bzero(&v6, sizeof (struct in6_addr));
+
+ assert(bunyan_init("child", &a) == 0);
+ assert(bunyan_stream_add(a, "foo", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_child(a, &child, BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+
+ bunyan_fini(a);
+ assert(bunyan_trace(child, "trace", BUNYAN_T_END) == 0);
+ assert(bunyan_debug(child, "debug", BUNYAN_T_END) == 0);
+ assert(bunyan_info(child, "info", BUNYAN_T_END) == 0);
+ assert(bunyan_warn(child, "warn", BUNYAN_T_END) == 0);
+ assert(bunyan_error(child, "error", BUNYAN_T_END) == 0);
+ assert(bunyan_fatal(child, "fatal", BUNYAN_T_END) == 0);
+
+ bunyan_fini(child);
+}
+
+static void
+crazy_child(void)
+{
+ bunyan_logger_t *a, *child;
+ struct in_addr v4;
+ struct in6_addr v6;
+
+ bzero(&v4, sizeof (struct in_addr));
+ bzero(&v6, sizeof (struct in6_addr));
+
+ assert(bunyan_init("crazy child", &a) == 0);
+ assert(bunyan_stream_add(a, "foo", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_key_add(a, BUNYAN_T_STRING, "s", "foo",
+ BUNYAN_T_POINTER, "p", (void *)a, BUNYAN_T_IP, "v4", &v4,
+ BUNYAN_T_IP6, "v6", &v6, BUNYAN_T_BOOLEAN, "b", B_TRUE,
+ BUNYAN_T_INT32, "i32", 69, BUNYAN_T_INT64, "i64", (uint64_t)6969,
+ BUNYAN_T_UINT32, "u32", 23, BUNYAN_T_UINT64, "u64", (uint64_t)2323,
+ BUNYAN_T_DOUBLE, "d", 3.14,
+ BUNYAN_T_INT64STR, "i64s", (uint64_t)12345,
+ BUNYAN_T_UINT64STR, "u64s", (uint64_t)54321, BUNYAN_T_END) == 0);
+ assert(bunyan_child(a, &child, BUNYAN_T_END) == 0);
+ bunyan_fini(a);
+
+ assert(bunyan_stream_remove(child, "foo") == 0);
+ assert(bunyan_stream_add(child, "bar", BUNYAN_L_TRACE,
+ bunyan_stream_fd, (void *)1) == 0);
+ assert(bunyan_key_remove(child, "u64s") == 0);
+ assert(bunyan_trace(child, "trace", BUNYAN_T_END) == 0);
+ assert(bunyan_debug(child, "debug", BUNYAN_T_END) == 0);
+ assert(bunyan_info(child, "info", BUNYAN_T_END) == 0);
+ assert(bunyan_warn(child, "warn", BUNYAN_T_END) == 0);
+ assert(bunyan_error(child, "error", BUNYAN_T_END) == 0);
+ assert(bunyan_fatal(child, "fatal", BUNYAN_T_END) == 0);
+
+ bunyan_fini(child);
+}
+
+int
+main(void)
+{
+ create_handles();
+ create_stream();
+ create_key();
+ bad_level();
+ basic_log();
+ crazy_log();
+ child_log();
+ crazy_child();
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/bunyan/bunyan.ksh b/usr/src/test/util-tests/tests/bunyan/bunyan.ksh
new file mode 100644
index 0000000000..4ec0f4bd62
--- /dev/null
+++ b/usr/src/test/util-tests/tests/bunyan/bunyan.ksh
@@ -0,0 +1,26 @@
+#! /usr/bin/ksh
+#
+# 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 (c) 2014, Joyent, Inc.
+#
+
+#
+# Simple wrapper for the classic test.out
+#
+
+set -o errexit
+
+btest_root=$(dirname $0)/../..
+btest_bin=$btest_root/bin/btest
+
+LD_PRELOAD=libumem.so UMEM_DEBUG=default $btest_bin >/dev/null
diff --git a/usr/src/test/util-tests/tests/dis/i386/32.avx512.out b/usr/src/test/util-tests/tests/dis/i386/32.avx512.out
index 9eb45c38cd..b49b738c14 100644
--- a/usr/src/test/util-tests/tests/dis/i386/32.avx512.out
+++ b/usr/src/test/util-tests/tests/dis/i386/32.avx512.out
@@ -95,3 +95,195 @@
24
libdis_test+0x1ab: 62 f1 fe 48 6f 04 vmovdqu64 (%esp),%zmm0
24
+ libdis_test+0x1b2: 62 f1 f5 88 55 d0 vandnpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x1b8: 62 f1 e5 88 55 20 vandnpd (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x1be: 62 f1 d5 88 55 b1 vandnpd 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x1c8: 62 f1 f5 a8 55 d0 vandnpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x1ce: 62 f1 e5 a8 55 23 vandnpd (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x1d4: 62 f1 d5 a8 55 b2 vandnpd 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x1de: 62 f1 f5 48 55 d0 vandnpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x1e4: 62 f1 e5 48 55 23 vandnpd (%ebx),%zmm3,%zmm4
+ libdis_test+0x1ea: 62 f1 d5 48 55 b2 vandnpd 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x1f4: 62 f1 74 88 55 d0 vandnps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x1fa: 62 f1 64 88 55 20 vandnps (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x200: 62 f1 54 88 55 b1 vandnps 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x20a: 62 f1 74 a8 55 d0 vandnps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x210: 62 f1 64 a8 55 23 vandnps (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x216: 62 f1 54 a8 55 b2 vandnps 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x220: 62 f1 74 48 55 d0 vandnps %zmm0,%zmm1,%zmm2
+ libdis_test+0x226: 62 f1 64 48 55 23 vandnps (%ebx),%zmm3,%zmm4
+ libdis_test+0x22c: 62 f1 54 48 55 b2 vandnps 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x236: 62 f1 f5 88 54 d0 vandpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x23c: 62 f1 e5 88 54 20 vandpd (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x242: 62 f1 d5 88 54 b1 vandpd 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x24c: 62 f1 f5 a8 54 d0 vandpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x252: 62 f1 e5 a8 54 23 vandpd (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x258: 62 f1 d5 a8 54 b2 vandpd 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x262: 62 f1 f5 48 54 d0 vandpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x268: 62 f1 e5 48 54 23 vandpd (%ebx),%zmm3,%zmm4
+ libdis_test+0x26e: 62 f1 d5 48 54 b2 vandpd 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x278: 62 f1 74 88 54 d0 vandps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x27e: 62 f1 64 88 54 20 vandps (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x284: 62 f1 54 88 54 b1 vandps 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x28e: 62 f1 74 a8 54 d0 vandps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x294: 62 f1 64 a8 54 23 vandps (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x29a: 62 f1 54 a8 54 b2 vandps 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x2a4: 62 f1 74 48 54 d0 vandps %zmm0,%zmm1,%zmm2
+ libdis_test+0x2aa: 62 f1 64 48 54 23 vandps (%ebx),%zmm3,%zmm4
+ libdis_test+0x2b0: 62 f1 54 48 54 b2 vandps 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x2ba: 62 f1 75 08 db d0 vpandd %xmm0,%xmm1,%xmm2
+ libdis_test+0x2c0: 62 f1 65 08 db 20 vpandd (%eax),%xmm3,%xmm4
+ libdis_test+0x2c6: 62 f1 55 08 db b1 vpandd 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x2d0: 62 f1 75 28 db d0 vpandd %ymm0,%ymm1,%ymm2
+ libdis_test+0x2d6: 62 f1 65 28 db 23 vpandd (%ebx),%ymm3,%ymm4
+ libdis_test+0x2dc: 62 f1 55 28 db b2 vpandd 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x2e6: 62 f1 75 48 db d0 vpandd %zmm0,%zmm1,%zmm2
+ libdis_test+0x2ec: 62 f1 65 48 db 23 vpandd (%ebx),%zmm3,%zmm4
+ libdis_test+0x2f2: 62 f1 55 48 db b2 vpandd 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x2fc: 62 f1 f5 08 db d0 vpandq %xmm0,%xmm1,%xmm2
+ libdis_test+0x302: 62 f1 e5 08 db 20 vpandq (%eax),%xmm3,%xmm4
+ libdis_test+0x308: 62 f1 d5 08 db b1 vpandq 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x312: 62 f1 f5 28 db d0 vpandq %ymm0,%ymm1,%ymm2
+ libdis_test+0x318: 62 f1 e5 28 db 23 vpandq (%ebx),%ymm3,%ymm4
+ libdis_test+0x31e: 62 f1 d5 28 db b2 vpandq 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x328: 62 f1 f5 48 db d0 vpandq %zmm0,%zmm1,%zmm2
+ libdis_test+0x32e: 62 f1 e5 48 db 23 vpandq (%ebx),%zmm3,%zmm4
+ libdis_test+0x334: 62 f1 d5 48 db b2 vpandq 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x33e: 62 f1 75 08 df d0 vpandnd %xmm0,%xmm1,%xmm2
+ libdis_test+0x344: 62 f1 65 08 df 20 vpandnd (%eax),%xmm3,%xmm4
+ libdis_test+0x34a: 62 f1 55 08 df b1 vpandnd 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x354: 62 f1 75 28 df d0 vpandnd %ymm0,%ymm1,%ymm2
+ libdis_test+0x35a: 62 f1 65 28 df 23 vpandnd (%ebx),%ymm3,%ymm4
+ libdis_test+0x360: 62 f1 55 28 df b2 vpandnd 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x36a: 62 f1 75 48 df d0 vpandnd %zmm0,%zmm1,%zmm2
+ libdis_test+0x370: 62 f1 65 48 df 23 vpandnd (%ebx),%zmm3,%zmm4
+ libdis_test+0x376: 62 f1 55 48 df b2 vpandnd 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x380: 62 f1 f5 08 df d0 vpandnq %xmm0,%xmm1,%xmm2
+ libdis_test+0x386: 62 f1 e5 08 df 20 vpandnq (%eax),%xmm3,%xmm4
+ libdis_test+0x38c: 62 f1 d5 08 df b1 vpandnq 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x396: 62 f1 f5 28 df d0 vpandnq %ymm0,%ymm1,%ymm2
+ libdis_test+0x39c: 62 f1 e5 28 df 23 vpandnq (%ebx),%ymm3,%ymm4
+ libdis_test+0x3a2: 62 f1 d5 28 df b2 vpandnq 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x3ac: 62 f1 f5 48 df d0 vpandnq %zmm0,%zmm1,%zmm2
+ libdis_test+0x3b2: 62 f1 e5 48 df 23 vpandnq (%ebx),%zmm3,%zmm4
+ libdis_test+0x3b8: 62 f1 d5 48 df b2 vpandnq 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x3c2: 62 f1 f5 88 56 d0 vorpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x3c8: 62 f1 e5 88 56 20 vorpd (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x3ce: 62 f1 d5 88 56 b1 vorpd 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x3d8: 62 f1 f5 a8 56 d0 vorpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x3de: 62 f1 e5 a8 56 23 vorpd (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x3e4: 62 f1 d5 a8 56 b2 vorpd 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x3ee: 62 f1 f5 48 56 d0 vorpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x3f4: 62 f1 e5 48 56 20 vorpd (%eax),%zmm3,%zmm4
+ libdis_test+0x3fa: 62 f1 d5 48 56 b1 vorpd 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x404: 62 f1 74 88 56 d0 vorps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x40a: 62 f1 64 88 56 20 vorps (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x410: 62 f1 54 88 56 b1 vorps 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x41a: 62 f1 74 a8 56 d0 vorps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x420: 62 f1 64 a8 56 23 vorps (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x426: 62 f1 54 a8 56 b2 vorps 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x430: 62 f1 74 48 56 d0 vorps %zmm0,%zmm1,%zmm2
+ libdis_test+0x436: 62 f1 64 48 56 20 vorps (%eax),%zmm3,%zmm4
+ libdis_test+0x43c: 62 f1 54 48 56 b1 vorps 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x446: 62 f1 75 08 eb d0 vpord %xmm0,%xmm1,%xmm2
+ libdis_test+0x44c: 62 f1 65 08 eb 20 vpord (%eax),%xmm3,%xmm4
+ libdis_test+0x452: 62 f1 55 08 eb b1 vpord 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x45c: 62 f1 75 28 eb d0 vpord %ymm0,%ymm1,%ymm2
+ libdis_test+0x462: 62 f1 65 28 eb 23 vpord (%ebx),%ymm3,%ymm4
+ libdis_test+0x468: 62 f1 55 28 eb b2 vpord 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x472: 62 f1 75 48 eb d0 vpord %zmm0,%zmm1,%zmm2
+ libdis_test+0x478: 62 f1 65 48 eb 20 vpord (%eax),%zmm3,%zmm4
+ libdis_test+0x47e: 62 f1 55 48 eb b1 vpord 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x488: 62 f1 f5 08 eb d0 vporq %xmm0,%xmm1,%xmm2
+ libdis_test+0x48e: 62 f1 e5 08 eb 20 vporq (%eax),%xmm3,%xmm4
+ libdis_test+0x494: 62 f1 d5 08 eb b1 vporq 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x49e: 62 f1 f5 28 eb d0 vporq %ymm0,%ymm1,%ymm2
+ libdis_test+0x4a4: 62 f1 e5 28 eb 23 vporq (%ebx),%ymm3,%ymm4
+ libdis_test+0x4aa: 62 f1 d5 28 eb b2 vporq 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x4b4: 62 f1 f5 48 eb d0 vporq %zmm0,%zmm1,%zmm2
+ libdis_test+0x4ba: 62 f1 e5 48 eb 20 vporq (%eax),%zmm3,%zmm4
+ libdis_test+0x4c0: 62 f1 d5 48 eb b1 vporq 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x4ca: 62 f1 75 08 ef d0 vpxord %xmm0,%xmm1,%xmm2
+ libdis_test+0x4d0: 62 f1 65 08 ef 20 vpxord (%eax),%xmm3,%xmm4
+ libdis_test+0x4d6: 62 f1 55 08 ef b1 vpxord 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x4e0: 62 f1 75 28 ef d0 vpxord %ymm0,%ymm1,%ymm2
+ libdis_test+0x4e6: 62 f1 65 28 ef 23 vpxord (%ebx),%ymm3,%ymm4
+ libdis_test+0x4ec: 62 f1 55 28 ef b2 vpxord 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x4f6: 62 f1 75 48 ef d0 vpxord %zmm0,%zmm1,%zmm2
+ libdis_test+0x4fc: 62 f1 65 48 ef 20 vpxord (%eax),%zmm3,%zmm4
+ libdis_test+0x502: 62 f1 55 48 ef b1 vpxord 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x50c: 62 f1 f5 08 ef d0 vpxorq %xmm0,%xmm1,%xmm2
+ libdis_test+0x512: 62 f1 e5 08 ef 20 vpxorq (%eax),%xmm3,%xmm4
+ libdis_test+0x518: 62 f1 d5 08 ef b1 vpxorq 0x42(%ecx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x522: 62 f1 f5 28 ef d0 vpxorq %ymm0,%ymm1,%ymm2
+ libdis_test+0x528: 62 f1 e5 28 ef 23 vpxorq (%ebx),%ymm3,%ymm4
+ libdis_test+0x52e: 62 f1 d5 28 ef b2 vpxorq 0x42(%edx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x538: 62 f1 f5 48 ef d0 vpxorq %zmm0,%zmm1,%zmm2
+ libdis_test+0x53e: 62 f1 e5 48 ef 20 vpxorq (%eax),%zmm3,%zmm4
+ libdis_test+0x544: 62 f1 d5 48 ef b1 vpxorq 0x42(%ecx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x54e: 62 f1 f5 88 57 d0 vxorpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x554: 62 f1 e5 88 57 20 vxorpd (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x55a: 62 f1 d5 88 57 b1 vxorpd 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x564: 62 f1 f5 a8 57 d0 vxorpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x56a: 62 f1 e5 a8 57 23 vxorpd (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x570: 62 f1 d5 a8 57 b2 vxorpd 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x57a: 62 f1 f5 48 57 d0 vxorpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x580: 62 f1 e5 48 57 23 vxorpd (%ebx),%zmm3,%zmm4
+ libdis_test+0x586: 62 f1 d5 48 57 b2 vxorpd 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x590: 62 f1 74 88 57 d0 vxorps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x596: 62 f1 64 88 57 20 vxorps (%eax),%xmm3,%xmm4{z}
+ libdis_test+0x59c: 62 f1 54 88 57 b1 vxorps 0x42(%ecx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x5a6: 62 f1 74 a8 57 d0 vxorps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x5ac: 62 f1 64 a8 57 23 vxorps (%ebx),%ymm3,%ymm4{z}
+ libdis_test+0x5b2: 62 f1 54 a8 57 b2 vxorps 0x42(%edx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x5bc: 62 f1 74 48 57 d0 vxorps %zmm0,%zmm1,%zmm2
+ libdis_test+0x5c2: 62 f1 64 48 57 23 vxorps (%ebx),%zmm3,%zmm4
+ libdis_test+0x5c8: 62 f1 54 48 57 b2 vxorps 0x42(%edx),%zmm5,%zmm6
+ 42 00 00 00
diff --git a/usr/src/test/util-tests/tests/dis/i386/32.avx512.s b/usr/src/test/util-tests/tests/dis/i386/32.avx512.s
index adcdae36da..3107788a99 100755
--- a/usr/src/test/util-tests/tests/dis/i386/32.avx512.s
+++ b/usr/src/test/util-tests/tests/dis/i386/32.avx512.s
@@ -14,7 +14,7 @@
*/
/*
- * Basic test for AVX512 mov instructions
+ * Basic test for AVX512 instructions
*/
.text
@@ -97,4 +97,164 @@ libdis_test:
vmovdqu16 (%esp), %zmm0
vmovdqu32 (%esp), %zmm0
vmovdqu64 (%esp), %zmm0
+
+ vandnpd %xmm0, %xmm1, %xmm2{z}
+ vandnpd (%eax), %xmm3, %xmm4{z}
+ vandnpd 0x42(%ecx), %xmm5, %xmm6{z}
+ vandnpd %ymm0, %ymm1, %ymm2{z}
+ vandnpd (%ebx), %ymm3, %ymm4{z}
+ vandnpd 0x42(%edx), %ymm5, %ymm6{z}
+ vandnpd %zmm0, %zmm1, %zmm2
+ vandnpd (%ebx), %zmm3, %zmm4
+ vandnpd 0x42(%edx), %zmm5, %zmm6
+
+ vandnps %xmm0, %xmm1, %xmm2{z}
+ vandnps (%eax), %xmm3, %xmm4{z}
+ vandnps 0x42(%ecx), %xmm5, %xmm6{z}
+ vandnps %ymm0, %ymm1, %ymm2{z}
+ vandnps (%ebx), %ymm3, %ymm4{z}
+ vandnps 0x42(%edx), %ymm5, %ymm6{z}
+ vandnps %zmm0, %zmm1, %zmm2
+ vandnps (%ebx), %zmm3, %zmm4
+ vandnps 0x42(%edx), %zmm5, %zmm6
+
+ vandpd %xmm0, %xmm1, %xmm2{z}
+ vandpd (%eax), %xmm3, %xmm4{z}
+ vandpd 0x42(%ecx), %xmm5, %xmm6{z}
+ vandpd %ymm0, %ymm1, %ymm2{z}
+ vandpd (%ebx), %ymm3, %ymm4{z}
+ vandpd 0x42(%edx), %ymm5, %ymm6{z}
+ vandpd %zmm0, %zmm1, %zmm2
+ vandpd (%ebx), %zmm3, %zmm4
+ vandpd 0x42(%edx), %zmm5, %zmm6
+
+ vandps %xmm0, %xmm1, %xmm2{z}
+ vandps (%eax), %xmm3, %xmm4{z}
+ vandps 0x42(%ecx), %xmm5, %xmm6{z}
+ vandps %ymm0, %ymm1, %ymm2{z}
+ vandps (%ebx), %ymm3, %ymm4{z}
+ vandps 0x42(%edx), %ymm5, %ymm6{z}
+ vandps %zmm0, %zmm1, %zmm2
+ vandps (%ebx), %zmm3, %zmm4
+ vandps 0x42(%edx), %zmm5, %zmm6
+
+ vpandd %xmm0, %xmm1, %xmm2
+ vpandd (%eax), %xmm3, %xmm4
+ vpandd 0x42(%ecx), %xmm5, %xmm6
+ vpandd %ymm0, %ymm1, %ymm2
+ vpandd (%ebx), %ymm3, %ymm4
+ vpandd 0x42(%edx), %ymm5, %ymm6
+ vpandd %zmm0, %zmm1, %zmm2
+ vpandd (%ebx), %zmm3, %zmm4
+ vpandd 0x42(%edx), %zmm5, %zmm6
+
+ vpandq %xmm0, %xmm1, %xmm2
+ vpandq (%eax), %xmm3, %xmm4
+ vpandq 0x42(%ecx), %xmm5, %xmm6
+ vpandq %ymm0, %ymm1, %ymm2
+ vpandq (%ebx), %ymm3, %ymm4
+ vpandq 0x42(%edx), %ymm5, %ymm6
+ vpandq %zmm0, %zmm1, %zmm2
+ vpandq (%ebx), %zmm3, %zmm4
+ vpandq 0x42(%edx), %zmm5, %zmm6
+
+ vpandnd %xmm0, %xmm1, %xmm2
+ vpandnd (%eax), %xmm3, %xmm4
+ vpandnd 0x42(%ecx), %xmm5, %xmm6
+ vpandnd %ymm0, %ymm1, %ymm2
+ vpandnd (%ebx), %ymm3, %ymm4
+ vpandnd 0x42(%edx), %ymm5, %ymm6
+ vpandnd %zmm0, %zmm1, %zmm2
+ vpandnd (%ebx), %zmm3, %zmm4
+ vpandnd 0x42(%edx), %zmm5, %zmm6
+
+ vpandnq %xmm0, %xmm1, %xmm2
+ vpandnq (%eax), %xmm3, %xmm4
+ vpandnq 0x42(%ecx), %xmm5, %xmm6
+ vpandnq %ymm0, %ymm1, %ymm2
+ vpandnq (%ebx), %ymm3, %ymm4
+ vpandnq 0x42(%edx), %ymm5, %ymm6
+ vpandnq %zmm0, %zmm1, %zmm2
+ vpandnq (%ebx), %zmm3, %zmm4
+ vpandnq 0x42(%edx), %zmm5, %zmm6
+
+ vorpd %xmm0, %xmm1, %xmm2{z}
+ vorpd (%eax), %xmm3, %xmm4{z}
+ vorpd 0x42(%ecx), %xmm5, %xmm6{z}
+ vorpd %ymm0, %ymm1, %ymm2{z}
+ vorpd (%ebx), %ymm3, %ymm4{z}
+ vorpd 0x42(%edx), %ymm5, %ymm6{z}
+ vorpd %zmm0, %zmm1, %zmm2
+ vorpd (%eax), %zmm3, %zmm4
+ vorpd 0x42(%ecx), %zmm5, %zmm6
+
+ vorps %xmm0, %xmm1, %xmm2{z}
+ vorps (%eax), %xmm3, %xmm4{z}
+ vorps 0x42(%ecx), %xmm5, %xmm6{z}
+ vorps %ymm0, %ymm1, %ymm2{z}
+ vorps (%ebx), %ymm3, %ymm4{z}
+ vorps 0x42(%edx), %ymm5, %ymm6{z}
+ vorps %zmm0, %zmm1, %zmm2
+ vorps (%eax), %zmm3, %zmm4
+ vorps 0x42(%ecx), %zmm5, %zmm6
+
+ vpord %xmm0, %xmm1, %xmm2
+ vpord (%eax), %xmm3, %xmm4
+ vpord 0x42(%ecx), %xmm5, %xmm6
+ vpord %ymm0, %ymm1, %ymm2
+ vpord (%ebx), %ymm3, %ymm4
+ vpord 0x42(%edx), %ymm5, %ymm6
+ vpord %zmm0, %zmm1, %zmm2
+ vpord (%eax), %zmm3, %zmm4
+ vpord 0x42(%ecx), %zmm5, %zmm6
+
+ vporq %xmm0, %xmm1, %xmm2
+ vporq (%eax), %xmm3, %xmm4
+ vporq 0x42(%ecx), %xmm5, %xmm6
+ vporq %ymm0, %ymm1, %ymm2
+ vporq (%ebx), %ymm3, %ymm4
+ vporq 0x42(%edx), %ymm5, %ymm6
+ vporq %zmm0, %zmm1, %zmm2
+ vporq (%eax), %zmm3, %zmm4
+ vporq 0x42(%ecx), %zmm5, %zmm6
+
+ vpxord %xmm0, %xmm1, %xmm2
+ vpxord (%eax), %xmm3, %xmm4
+ vpxord 0x42(%ecx), %xmm5, %xmm6
+ vpxord %ymm0, %ymm1, %ymm2
+ vpxord (%ebx), %ymm3, %ymm4
+ vpxord 0x42(%edx), %ymm5, %ymm6
+ vpxord %zmm0, %zmm1, %zmm2
+ vpxord (%eax), %zmm3, %zmm4
+ vpxord 0x42(%ecx), %zmm5, %zmm6
+
+ vpxorq %xmm0, %xmm1, %xmm2
+ vpxorq (%eax), %xmm3, %xmm4
+ vpxorq 0x42(%ecx), %xmm5, %xmm6
+ vpxorq %ymm0, %ymm1, %ymm2
+ vpxorq (%ebx), %ymm3, %ymm4
+ vpxorq 0x42(%edx), %ymm5, %ymm6
+ vpxorq %zmm0, %zmm1, %zmm2
+ vpxorq (%eax), %zmm3, %zmm4
+ vpxorq 0x42(%ecx), %zmm5, %zmm6
+
+ vxorpd %xmm0, %xmm1, %xmm2{z}
+ vxorpd (%eax), %xmm3, %xmm4{z}
+ vxorpd 0x42(%ecx), %xmm5, %xmm6{z}
+ vxorpd %ymm0, %ymm1, %ymm2{z}
+ vxorpd (%ebx), %ymm3, %ymm4{z}
+ vxorpd 0x42(%edx), %ymm5, %ymm6{z}
+ vxorpd %zmm0, %zmm1, %zmm2
+ vxorpd (%ebx), %zmm3, %zmm4
+ vxorpd 0x42(%edx), %zmm5, %zmm6
+
+ vxorps %xmm0, %xmm1, %xmm2{z}
+ vxorps (%eax), %xmm3, %xmm4{z}
+ vxorps 0x42(%ecx), %xmm5, %xmm6{z}
+ vxorps %ymm0, %ymm1, %ymm2{z}
+ vxorps (%ebx), %ymm3, %ymm4{z}
+ vxorps 0x42(%edx), %ymm5, %ymm6{z}
+ vxorps %zmm0, %zmm1, %zmm2
+ vxorps (%ebx), %zmm3, %zmm4
+ vxorps 0x42(%edx), %zmm5, %zmm6
.size libdis_test, [.-libdis_test]
diff --git a/usr/src/test/util-tests/tests/dis/i386/64.avx512.out b/usr/src/test/util-tests/tests/dis/i386/64.avx512.out
index b4a325086b..e8293406e6 100644
--- a/usr/src/test/util-tests/tests/dis/i386/64.avx512.out
+++ b/usr/src/test/util-tests/tests/dis/i386/64.avx512.out
@@ -160,3 +160,195 @@
24
libdis_test+0x313: 62 e1 fe 48 6f 24 vmovdqu64 (%rsp),%zmm20
24
+ libdis_test+0x31a: 62 f1 f5 88 55 d0 vandnpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x320: 62 f1 e5 88 55 20 vandnpd (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x326: 62 f1 d5 88 55 b1 vandnpd 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x330: 62 f1 f5 a8 55 d0 vandnpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x336: 62 f1 e5 a8 55 23 vandnpd (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x33c: 62 f1 d5 a8 55 b2 vandnpd 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x346: 62 f1 f5 48 55 d0 vandnpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x34c: 62 f1 e5 48 55 23 vandnpd (%rbx),%zmm3,%zmm4
+ libdis_test+0x352: 62 f1 d5 48 55 b2 vandnpd 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x35c: 62 f1 74 88 55 d0 vandnps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x362: 62 f1 64 88 55 20 vandnps (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x368: 62 f1 54 88 55 b1 vandnps 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x372: 62 f1 74 a8 55 d0 vandnps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x378: 62 f1 64 a8 55 23 vandnps (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x37e: 62 f1 54 a8 55 b2 vandnps 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x388: 62 f1 74 48 55 d0 vandnps %zmm0,%zmm1,%zmm2
+ libdis_test+0x38e: 62 f1 64 48 55 23 vandnps (%rbx),%zmm3,%zmm4
+ libdis_test+0x394: 62 f1 54 48 55 b2 vandnps 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x39e: 62 f1 f5 88 54 d0 vandpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x3a4: 62 f1 e5 88 54 20 vandpd (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x3aa: 62 f1 d5 88 54 b1 vandpd 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x3b4: 62 f1 f5 a8 54 d0 vandpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x3ba: 62 f1 e5 a8 54 23 vandpd (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x3c0: 62 f1 d5 a8 54 b2 vandpd 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x3ca: 62 f1 f5 48 54 d0 vandpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x3d0: 62 f1 e5 48 54 23 vandpd (%rbx),%zmm3,%zmm4
+ libdis_test+0x3d6: 62 f1 d5 48 54 b2 vandpd 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x3e0: 62 f1 74 88 54 d0 vandps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x3e6: 62 f1 64 88 54 20 vandps (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x3ec: 62 f1 54 88 54 b1 vandps 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x3f6: 62 f1 74 a8 54 d0 vandps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x3fc: 62 f1 64 a8 54 23 vandps (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x402: 62 f1 54 a8 54 b2 vandps 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x40c: 62 f1 74 48 54 d0 vandps %zmm0,%zmm1,%zmm2
+ libdis_test+0x412: 62 f1 64 48 54 23 vandps (%rbx),%zmm3,%zmm4
+ libdis_test+0x418: 62 f1 54 48 54 b2 vandps 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x422: 62 f1 75 08 db d0 vpandd %xmm0,%xmm1,%xmm2
+ libdis_test+0x428: 62 f1 65 08 db 20 vpandd (%rax),%xmm3,%xmm4
+ libdis_test+0x42e: 62 f1 55 08 db b1 vpandd 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x438: 62 f1 75 28 db d0 vpandd %ymm0,%ymm1,%ymm2
+ libdis_test+0x43e: 62 f1 65 28 db 23 vpandd (%rbx),%ymm3,%ymm4
+ libdis_test+0x444: 62 f1 55 28 db b2 vpandd 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x44e: 62 f1 75 48 db d0 vpandd %zmm0,%zmm1,%zmm2
+ libdis_test+0x454: 62 f1 65 48 db 23 vpandd (%rbx),%zmm3,%zmm4
+ libdis_test+0x45a: 62 f1 55 48 db b2 vpandd 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x464: 62 f1 f5 08 db d0 vpandq %xmm0,%xmm1,%xmm2
+ libdis_test+0x46a: 62 f1 e5 08 db 20 vpandq (%rax),%xmm3,%xmm4
+ libdis_test+0x470: 62 f1 d5 08 db b1 vpandq 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x47a: 62 f1 f5 28 db d0 vpandq %ymm0,%ymm1,%ymm2
+ libdis_test+0x480: 62 f1 e5 28 db 23 vpandq (%rbx),%ymm3,%ymm4
+ libdis_test+0x486: 62 f1 d5 28 db b2 vpandq 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x490: 62 f1 f5 48 db d0 vpandq %zmm0,%zmm1,%zmm2
+ libdis_test+0x496: 62 f1 e5 48 db 23 vpandq (%rbx),%zmm3,%zmm4
+ libdis_test+0x49c: 62 f1 d5 48 db b2 vpandq 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x4a6: 62 f1 75 08 df d0 vpandnd %xmm0,%xmm1,%xmm2
+ libdis_test+0x4ac: 62 f1 65 08 df 20 vpandnd (%rax),%xmm3,%xmm4
+ libdis_test+0x4b2: 62 f1 55 08 df b1 vpandnd 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x4bc: 62 f1 75 28 df d0 vpandnd %ymm0,%ymm1,%ymm2
+ libdis_test+0x4c2: 62 f1 65 28 df 23 vpandnd (%rbx),%ymm3,%ymm4
+ libdis_test+0x4c8: 62 f1 55 28 df b2 vpandnd 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x4d2: 62 f1 75 48 df d0 vpandnd %zmm0,%zmm1,%zmm2
+ libdis_test+0x4d8: 62 f1 65 48 df 23 vpandnd (%rbx),%zmm3,%zmm4
+ libdis_test+0x4de: 62 f1 55 48 df b2 vpandnd 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x4e8: 62 f1 f5 08 df d0 vpandnq %xmm0,%xmm1,%xmm2
+ libdis_test+0x4ee: 62 f1 e5 08 df 20 vpandnq (%rax),%xmm3,%xmm4
+ libdis_test+0x4f4: 62 f1 d5 08 df b1 vpandnq 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x4fe: 62 f1 f5 28 df d0 vpandnq %ymm0,%ymm1,%ymm2
+ libdis_test+0x504: 62 f1 e5 28 df 23 vpandnq (%rbx),%ymm3,%ymm4
+ libdis_test+0x50a: 62 f1 d5 28 df b2 vpandnq 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x514: 62 f1 f5 48 df d0 vpandnq %zmm0,%zmm1,%zmm2
+ libdis_test+0x51a: 62 f1 e5 48 df 23 vpandnq (%rbx),%zmm3,%zmm4
+ libdis_test+0x520: 62 f1 d5 48 df b2 vpandnq 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x52a: 62 f1 f5 88 56 d0 vorpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x530: 62 f1 e5 88 56 20 vorpd (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x536: 62 f1 d5 88 56 b1 vorpd 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x540: 62 f1 f5 a8 56 d0 vorpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x546: 62 f1 e5 a8 56 23 vorpd (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x54c: 62 f1 d5 a8 56 b2 vorpd 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x556: 62 f1 f5 48 56 d0 vorpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x55c: 62 f1 e5 48 56 20 vorpd (%rax),%zmm3,%zmm4
+ libdis_test+0x562: 62 f1 d5 48 56 b1 vorpd 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x56c: 62 f1 74 88 56 d0 vorps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x572: 62 f1 64 88 56 20 vorps (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x578: 62 f1 54 88 56 b1 vorps 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x582: 62 f1 74 a8 56 d0 vorps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x588: 62 f1 64 a8 56 23 vorps (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x58e: 62 f1 54 a8 56 b2 vorps 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x598: 62 f1 74 48 56 d0 vorps %zmm0,%zmm1,%zmm2
+ libdis_test+0x59e: 62 f1 64 48 56 20 vorps (%rax),%zmm3,%zmm4
+ libdis_test+0x5a4: 62 f1 54 48 56 b1 vorps 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x5ae: 62 f1 75 08 eb d0 vpord %xmm0,%xmm1,%xmm2
+ libdis_test+0x5b4: 62 f1 65 08 eb 20 vpord (%rax),%xmm3,%xmm4
+ libdis_test+0x5ba: 62 f1 55 08 eb b1 vpord 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x5c4: 62 f1 75 28 eb d0 vpord %ymm0,%ymm1,%ymm2
+ libdis_test+0x5ca: 62 f1 65 28 eb 23 vpord (%rbx),%ymm3,%ymm4
+ libdis_test+0x5d0: 62 f1 55 28 eb b2 vpord 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x5da: 62 f1 75 48 eb d0 vpord %zmm0,%zmm1,%zmm2
+ libdis_test+0x5e0: 62 f1 65 48 eb 20 vpord (%rax),%zmm3,%zmm4
+ libdis_test+0x5e6: 62 f1 55 48 eb b1 vpord 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x5f0: 62 f1 f5 08 eb d0 vporq %xmm0,%xmm1,%xmm2
+ libdis_test+0x5f6: 62 f1 e5 08 eb 20 vporq (%rax),%xmm3,%xmm4
+ libdis_test+0x5fc: 62 f1 d5 08 eb b1 vporq 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x606: 62 f1 f5 28 eb d0 vporq %ymm0,%ymm1,%ymm2
+ libdis_test+0x60c: 62 f1 e5 28 eb 23 vporq (%rbx),%ymm3,%ymm4
+ libdis_test+0x612: 62 f1 d5 28 eb b2 vporq 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x61c: 62 f1 f5 48 eb d0 vporq %zmm0,%zmm1,%zmm2
+ libdis_test+0x622: 62 f1 e5 48 eb 20 vporq (%rax),%zmm3,%zmm4
+ libdis_test+0x628: 62 f1 d5 48 eb b1 vporq 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x632: 62 f1 75 08 ef d0 vpxord %xmm0,%xmm1,%xmm2
+ libdis_test+0x638: 62 f1 65 08 ef 20 vpxord (%rax),%xmm3,%xmm4
+ libdis_test+0x63e: 62 f1 55 08 ef b1 vpxord 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x648: 62 f1 75 28 ef d0 vpxord %ymm0,%ymm1,%ymm2
+ libdis_test+0x64e: 62 f1 65 28 ef 23 vpxord (%rbx),%ymm3,%ymm4
+ libdis_test+0x654: 62 f1 55 28 ef b2 vpxord 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x65e: 62 f1 75 48 ef d0 vpxord %zmm0,%zmm1,%zmm2
+ libdis_test+0x664: 62 f1 65 48 ef 20 vpxord (%rax),%zmm3,%zmm4
+ libdis_test+0x66a: 62 f1 55 48 ef b1 vpxord 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x674: 62 f1 f5 08 ef d0 vpxorq %xmm0,%xmm1,%xmm2
+ libdis_test+0x67a: 62 f1 e5 08 ef 20 vpxorq (%rax),%xmm3,%xmm4
+ libdis_test+0x680: 62 f1 d5 08 ef b1 vpxorq 0x42(%rcx),%xmm5,%xmm6
+ 42 00 00 00
+ libdis_test+0x68a: 62 f1 f5 28 ef d0 vpxorq %ymm0,%ymm1,%ymm2
+ libdis_test+0x690: 62 f1 e5 28 ef 23 vpxorq (%rbx),%ymm3,%ymm4
+ libdis_test+0x696: 62 f1 d5 28 ef b2 vpxorq 0x42(%rdx),%ymm5,%ymm6
+ 42 00 00 00
+ libdis_test+0x6a0: 62 f1 f5 48 ef d0 vpxorq %zmm0,%zmm1,%zmm2
+ libdis_test+0x6a6: 62 f1 e5 48 ef 20 vpxorq (%rax),%zmm3,%zmm4
+ libdis_test+0x6ac: 62 f1 d5 48 ef b1 vpxorq 0x42(%rcx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x6b6: 62 f1 f5 88 57 d0 vxorpd %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x6bc: 62 f1 e5 88 57 20 vxorpd (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x6c2: 62 f1 d5 88 57 b1 vxorpd 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x6cc: 62 f1 f5 a8 57 d0 vxorpd %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x6d2: 62 f1 e5 a8 57 23 vxorpd (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x6d8: 62 f1 d5 a8 57 b2 vxorpd 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x6e2: 62 f1 f5 48 57 d0 vxorpd %zmm0,%zmm1,%zmm2
+ libdis_test+0x6e8: 62 f1 e5 48 57 23 vxorpd (%rbx),%zmm3,%zmm4
+ libdis_test+0x6ee: 62 f1 d5 48 57 b2 vxorpd 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
+ libdis_test+0x6f8: 62 f1 74 88 57 d0 vxorps %xmm0,%xmm1,%xmm2{z}
+ libdis_test+0x6fe: 62 f1 64 88 57 20 vxorps (%rax),%xmm3,%xmm4{z}
+ libdis_test+0x704: 62 f1 54 88 57 b1 vxorps 0x42(%rcx),%xmm5,%xmm6{z}
+ 42 00 00 00
+ libdis_test+0x70e: 62 f1 74 a8 57 d0 vxorps %ymm0,%ymm1,%ymm2{z}
+ libdis_test+0x714: 62 f1 64 a8 57 23 vxorps (%rbx),%ymm3,%ymm4{z}
+ libdis_test+0x71a: 62 f1 54 a8 57 b2 vxorps 0x42(%rdx),%ymm5,%ymm6{z}
+ 42 00 00 00
+ libdis_test+0x724: 62 f1 74 48 57 d0 vxorps %zmm0,%zmm1,%zmm2
+ libdis_test+0x72a: 62 f1 64 48 57 23 vxorps (%rbx),%zmm3,%zmm4
+ libdis_test+0x730: 62 f1 54 48 57 b2 vxorps 0x42(%rdx),%zmm5,%zmm6
+ 42 00 00 00
diff --git a/usr/src/test/util-tests/tests/dis/i386/64.avx512.s b/usr/src/test/util-tests/tests/dis/i386/64.avx512.s
index f038534dbf..c7e25b7328 100755
--- a/usr/src/test/util-tests/tests/dis/i386/64.avx512.s
+++ b/usr/src/test/util-tests/tests/dis/i386/64.avx512.s
@@ -14,7 +14,7 @@
*/
/*
- * Basic test for AVX512 mov instructions
+ * Basic tests for AVX512 instructions
*/
.text
@@ -154,4 +154,165 @@ libdis_test:
vmovdqu16 (%rsp), %zmm20
vmovdqu32 (%rsp), %zmm20
vmovdqu64 (%rsp), %zmm20
+
+ vandnpd %xmm0, %xmm1, %xmm2{z}
+ vandnpd (%rax), %xmm3, %xmm4{z}
+ vandnpd 0x42(%rcx), %xmm5, %xmm6{z}
+ vandnpd %ymm0, %ymm1, %ymm2{z}
+ vandnpd (%rbx), %ymm3, %ymm4{z}
+ vandnpd 0x42(%rdx), %ymm5, %ymm6{z}
+ vandnpd %zmm0, %zmm1, %zmm2
+ vandnpd (%rbx), %zmm3, %zmm4
+ vandnpd 0x42(%rdx), %zmm5, %zmm6
+
+ vandnps %xmm0, %xmm1, %xmm2{z}
+ vandnps (%rax), %xmm3, %xmm4{z}
+ vandnps 0x42(%rcx), %xmm5, %xmm6{z}
+ vandnps %ymm0, %ymm1, %ymm2{z}
+ vandnps (%rbx), %ymm3, %ymm4{z}
+ vandnps 0x42(%rdx), %ymm5, %ymm6{z}
+ vandnps %zmm0, %zmm1, %zmm2
+ vandnps (%rbx), %zmm3, %zmm4
+ vandnps 0x42(%rdx), %zmm5, %zmm6
+
+ vandpd %xmm0, %xmm1, %xmm2{z}
+ vandpd (%rax), %xmm3, %xmm4{z}
+ vandpd 0x42(%rcx), %xmm5, %xmm6{z}
+ vandpd %ymm0, %ymm1, %ymm2{z}
+ vandpd (%rbx), %ymm3, %ymm4{z}
+ vandpd 0x42(%rdx), %ymm5, %ymm6{z}
+ vandpd %zmm0, %zmm1, %zmm2
+ vandpd (%rbx), %zmm3, %zmm4
+ vandpd 0x42(%rdx), %zmm5, %zmm6
+
+ vandps %xmm0, %xmm1, %xmm2{z}
+ vandps (%rax), %xmm3, %xmm4{z}
+ vandps 0x42(%rcx), %xmm5, %xmm6{z}
+ vandps %ymm0, %ymm1, %ymm2{z}
+ vandps (%rbx), %ymm3, %ymm4{z}
+ vandps 0x42(%rdx), %ymm5, %ymm6{z}
+ vandps %zmm0, %zmm1, %zmm2
+ vandps (%rbx), %zmm3, %zmm4
+ vandps 0x42(%rdx), %zmm5, %zmm6
+
+ vpandd %xmm0, %xmm1, %xmm2
+ vpandd (%rax), %xmm3, %xmm4
+ vpandd 0x42(%rcx), %xmm5, %xmm6
+ vpandd %ymm0, %ymm1, %ymm2
+ vpandd (%rbx), %ymm3, %ymm4
+ vpandd 0x42(%rdx), %ymm5, %ymm6
+ vpandd %zmm0, %zmm1, %zmm2
+ vpandd (%rbx), %zmm3, %zmm4
+ vpandd 0x42(%rdx), %zmm5, %zmm6
+
+ vpandq %xmm0, %xmm1, %xmm2
+ vpandq (%rax), %xmm3, %xmm4
+ vpandq 0x42(%rcx), %xmm5, %xmm6
+ vpandq %ymm0, %ymm1, %ymm2
+ vpandq (%rbx), %ymm3, %ymm4
+ vpandq 0x42(%rdx), %ymm5, %ymm6
+ vpandq %zmm0, %zmm1, %zmm2
+ vpandq (%rbx), %zmm3, %zmm4
+ vpandq 0x42(%rdx), %zmm5, %zmm6
+
+ vpandnd %xmm0, %xmm1, %xmm2
+ vpandnd (%rax), %xmm3, %xmm4
+ vpandnd 0x42(%rcx), %xmm5, %xmm6
+ vpandnd %ymm0, %ymm1, %ymm2
+ vpandnd (%rbx), %ymm3, %ymm4
+ vpandnd 0x42(%rdx), %ymm5, %ymm6
+ vpandnd %zmm0, %zmm1, %zmm2
+ vpandnd (%rbx), %zmm3, %zmm4
+ vpandnd 0x42(%rdx), %zmm5, %zmm6
+
+ vpandnq %xmm0, %xmm1, %xmm2
+ vpandnq (%rax), %xmm3, %xmm4
+ vpandnq 0x42(%rcx), %xmm5, %xmm6
+ vpandnq %ymm0, %ymm1, %ymm2
+ vpandnq (%rbx), %ymm3, %ymm4
+ vpandnq 0x42(%rdx), %ymm5, %ymm6
+ vpandnq %zmm0, %zmm1, %zmm2
+ vpandnq (%rbx), %zmm3, %zmm4
+ vpandnq 0x42(%rdx), %zmm5, %zmm6
+
+ vorpd %xmm0, %xmm1, %xmm2{z}
+ vorpd (%rax), %xmm3, %xmm4{z}
+ vorpd 0x42(%rcx), %xmm5, %xmm6{z}
+ vorpd %ymm0, %ymm1, %ymm2{z}
+ vorpd (%rbx), %ymm3, %ymm4{z}
+ vorpd 0x42(%rdx), %ymm5, %ymm6{z}
+ vorpd %zmm0, %zmm1, %zmm2
+ vorpd (%rax), %zmm3, %zmm4
+ vorpd 0x42(%rcx), %zmm5, %zmm6
+
+ vorps %xmm0, %xmm1, %xmm2{z}
+ vorps (%rax), %xmm3, %xmm4{z}
+ vorps 0x42(%rcx), %xmm5, %xmm6{z}
+ vorps %ymm0, %ymm1, %ymm2{z}
+ vorps (%rbx), %ymm3, %ymm4{z}
+ vorps 0x42(%rdx), %ymm5, %ymm6{z}
+ vorps %zmm0, %zmm1, %zmm2
+ vorps (%rax), %zmm3, %zmm4
+ vorps 0x42(%rcx), %zmm5, %zmm6
+
+ vpord %xmm0, %xmm1, %xmm2
+ vpord (%rax), %xmm3, %xmm4
+ vpord 0x42(%rcx), %xmm5, %xmm6
+ vpord %ymm0, %ymm1, %ymm2
+ vpord (%rbx), %ymm3, %ymm4
+ vpord 0x42(%rdx), %ymm5, %ymm6
+ vpord %zmm0, %zmm1, %zmm2
+ vpord (%rax), %zmm3, %zmm4
+ vpord 0x42(%rcx), %zmm5, %zmm6
+
+ vporq %xmm0, %xmm1, %xmm2
+ vporq (%rax), %xmm3, %xmm4
+ vporq 0x42(%rcx), %xmm5, %xmm6
+ vporq %ymm0, %ymm1, %ymm2
+ vporq (%rbx), %ymm3, %ymm4
+ vporq 0x42(%rdx), %ymm5, %ymm6
+ vporq %zmm0, %zmm1, %zmm2
+ vporq (%rax), %zmm3, %zmm4
+ vporq 0x42(%rcx), %zmm5, %zmm6
+
+ vpxord %xmm0, %xmm1, %xmm2
+ vpxord (%rax), %xmm3, %xmm4
+ vpxord 0x42(%rcx), %xmm5, %xmm6
+ vpxord %ymm0, %ymm1, %ymm2
+ vpxord (%rbx), %ymm3, %ymm4
+ vpxord 0x42(%rdx), %ymm5, %ymm6
+ vpxord %zmm0, %zmm1, %zmm2
+ vpxord (%rax), %zmm3, %zmm4
+ vpxord 0x42(%rcx), %zmm5, %zmm6
+
+ vpxorq %xmm0, %xmm1, %xmm2
+ vpxorq (%rax), %xmm3, %xmm4
+ vpxorq 0x42(%rcx), %xmm5, %xmm6
+ vpxorq %ymm0, %ymm1, %ymm2
+ vpxorq (%rbx), %ymm3, %ymm4
+ vpxorq 0x42(%rdx), %ymm5, %ymm6
+ vpxorq %zmm0, %zmm1, %zmm2
+ vpxorq (%rax), %zmm3, %zmm4
+ vpxorq 0x42(%rcx), %zmm5, %zmm6
+
+ vxorpd %xmm0, %xmm1, %xmm2{z}
+ vxorpd (%rax), %xmm3, %xmm4{z}
+ vxorpd 0x42(%rcx), %xmm5, %xmm6{z}
+ vxorpd %ymm0, %ymm1, %ymm2{z}
+ vxorpd (%rbx), %ymm3, %ymm4{z}
+ vxorpd 0x42(%rdx), %ymm5, %ymm6{z}
+ vxorpd %zmm0, %zmm1, %zmm2
+ vxorpd (%rbx), %zmm3, %zmm4
+ vxorpd 0x42(%rdx), %zmm5, %zmm6
+
+ vxorps %xmm0, %xmm1, %xmm2{z}
+ vxorps (%rax), %xmm3, %xmm4{z}
+ vxorps 0x42(%rcx), %xmm5, %xmm6{z}
+ vxorps %ymm0, %ymm1, %ymm2{z}
+ vxorps (%rbx), %ymm3, %ymm4{z}
+ vxorps 0x42(%rdx), %ymm5, %ymm6{z}
+ vxorps %zmm0, %zmm1, %zmm2
+ vxorps (%rbx), %zmm3, %zmm4
+ vxorps 0x42(%rdx), %zmm5, %zmm6
+
.size libdis_test, [.-libdis_test]
diff --git a/usr/src/test/util-tests/tests/dladm/Makefile b/usr/src/test/util-tests/tests/dladm/Makefile
index df3997656c..2ce969fcc4 100644
--- a/usr/src/test/util-tests/tests/dladm/Makefile
+++ b/usr/src/test/util-tests/tests/dladm/Makefile
@@ -10,18 +10,18 @@
#
#
-# Copyright (c) 2014 Joyent, Inc. All rights reserved.
+# Copyright 2017 Joyent, Inc.
#
include $(SRC)/cmd/Makefile.cmd
include $(SRC)/test/Makefile.com
ROOTOPTPKG = $(ROOT)/opt/util-tests/tests
-PROG = allowed-ips
+PROG = allowed-ips set-linkprop show-overlay-exit vnic-mtu
ROOTPROG = $(PROG:%=$(ROOTOPTPKG)/%)
-all:
+all:
install: $(ROOTPROG)
diff --git a/usr/src/test/util-tests/tests/dladm/set-linkprop.ksh b/usr/src/test/util-tests/tests/dladm/set-linkprop.ksh
new file mode 100644
index 0000000000..37e318fe34
--- /dev/null
+++ b/usr/src/test/util-tests/tests/dladm/set-linkprop.ksh
@@ -0,0 +1,208 @@
+#!/bin/ksh
+#
+# 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 2017 Joyent, Inc.
+#
+
+#
+# The purpose of this test is to verify that set-linkprop performs as
+# it should -- both on persistent and temporary links.
+#
+
+vm_arg0="$(basename $0)"
+vm_stub="teststub$$"
+vm_pvnic="test_pvnic$$"
+vm_tvnic="test_tvnic$$"
+
+DL_FILE=/etc/dladm/datalink.conf
+
+fatal()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST_FAIL: $vm_arg0: $msg" >&2
+
+ # Try to clean up just in case
+ dladm delete-vnic $vm_pvnic 2>/dev/null
+ dladm delete-vnic $vm_tvnic 2>/dev/null
+ dladm delete-etherstub $vm_stub 2>/dev/null
+ exit 1
+}
+
+delete_stub()
+{
+ dladm delete-etherstub $vm_stub || fatal \
+ "failed to delete stub $vm_stub"
+}
+
+create_stub()
+{
+ dladm create-etherstub $vm_stub || fatal \
+ "failed to create stub"
+}
+
+create_vnic()
+{
+ typeset dev=$1
+ typeset flags=$2
+
+ dladm create-vnic $flags -l $vm_stub $dev 2>/dev/null || fatal \
+ "failed to create vnic: $dev"
+}
+
+delete_vnic()
+{
+ typeset dev=$1
+
+ dladm delete-vnic $dev || fatal "failed to delete vnic: $dev"
+}
+
+#
+# Validate the property is reported by dladm.
+#
+validate_prop()
+{
+ typeset dev=$1
+ typeset prop=$2
+ typeset val=$3
+ typeset oval
+
+ [[ -z "$dev" ]] && fatal "missing required device"
+ [[ -z "$prop" ]] && fatal "missing required prop"
+ [[ -z "$val" ]] && fatal "missing required val"
+ oval=$(dladm show-linkprop -c -o value -p $prop $dev | tr -d ' ')
+ [[ $? -eq 0 ]] || fatal "failed to get $prop for $dev"
+ [[ "$val" == "$oval" ]] || fatal \
+ "$prop mismatch on $dev: expected $val, got $oval"
+}
+
+#
+# Validate the property is persistent.
+#
+validate_pprop()
+{
+ typeset dev=$1
+ typeset prop=$2
+ typeset val=$3
+ typeset oval
+
+ [[ -z "$dev" ]] && fatal "missing required device"
+ [[ -z "$prop" ]] && fatal "missing required prop"
+ [[ -z "$val" ]] && fatal "missing required val"
+
+ oval=$(awk "/^$dev/ { print \$2 }" $DL_FILE | \
+ awk -F, "BEGIN { RS=\";\"; } /^$prop/ { print \$2; }")
+
+ [[ $? -eq 0 ]] || fatal "failed to get persistent $prop for $dev"
+ [[ "$val" == "$oval" ]] || fatal \
+ "persistent $prop mismatch on $dev: expected $val, got $oval"
+}
+
+#
+# Validate the the property is not persistent.
+#
+validate_not_pprop()
+{
+ typeset dev=$1
+ typeset prop=$2
+
+ [[ -z "$dev" ]] && fatal "missing required device"
+ [[ -z "$prop" ]] && fatal "missing required prop"
+
+ oval=$(awk "/^$dev/ { print \$2 }" $DL_FILE | \
+ awk -F, "BEGIN { RS=\";\"; } /^$prop/ { print \$2; }")
+
+ [[ $? -eq 0 ]] || fatal "failed to search $DL_FILE"
+
+ [[ -z "$oval" ]] || fatal \
+ "found persistent $prop for $dev but didn't expect to"
+
+}
+
+set_prop_pass()
+{
+ typeset dev=$1
+ typeset flags=$2
+ typeset prop=$3
+ typeset val=$4
+ typeset msg="failed to set prop $prop on $dev"
+
+ [[ "$#" -ne 4 ]] && fatal "set_prop_pass() requires 4 args"
+ [[ -z "$dev" ]] && fatal "missing required device"
+ [[ -z "$prop" ]] && fatal "missing required prop"
+ [[ -z "$val" ]] && fatal "missing required val"
+
+ if [ -n "$flags" ]; then
+ typeset msg="failed to set temp prop $prop on $dev"
+ fi
+
+ dladm set-linkprop $flags -p $prop=$val $dev || fatal $msg
+}
+
+test_pass()
+{
+ [[ -f $DL_FILE ]] || fatal "datalink file does not exist: $DL_FILE"
+
+ create_stub
+
+ #
+ # Test setting persistent and temp properties on a persistent
+ # link.
+ #
+ create_vnic $vm_pvnic
+
+ set_prop_pass $vm_pvnic "-t" maxbw 89
+ validate_prop $vm_pvnic maxbw 89
+ validate_not_pprop $vm_pvnic maxbw 89
+ set_prop_pass $vm_pvnic "-t" priority medium
+ validate_prop $vm_pvnic priority medium
+ validate_not_pprop $vm_pvnic priority medium
+
+ set_prop_pass $vm_pvnic "" maxbw 99
+ validate_prop $vm_pvnic maxbw 99
+ validate_pprop $vm_pvnic maxbw 99
+ set_prop_pass $vm_pvnic "" priority low
+ validate_prop $vm_pvnic priority low
+ validate_pprop $vm_pvnic priority low
+
+ delete_vnic $vm_pvnic
+
+ #
+ # Test setting persistent and temp properties on a temp link.
+ # A "persistent" property on a temp link is really just a temp
+ # property. But setting a property on a temp link, without
+ # passing -t, should still work and report success to the
+ # user.
+ #
+ create_vnic $vm_tvnic "-t"
+
+ set_prop_pass $vm_tvnic "-t" maxbw 89
+ validate_prop $vm_tvnic maxbw 89
+ validate_not_pprop $vm_tvnic maxbw 89
+ set_prop_pass $vm_tvnic "-t" priority medium
+ validate_prop $vm_tvnic priority medium
+ validate_not_pprop $vm_tvnic priority medium
+
+ set_prop_pass $vm_tvnic "" maxbw 99
+ validate_prop $vm_tvnic maxbw 99
+ validate_not_pprop $vm_tvnic maxbw 99
+ set_prop_pass $vm_tvnic "" priority low
+ validate_prop $vm_tvnic priority low
+ validate_not_pprop $vm_tvnic priority low
+
+ delete_vnic $vm_tvnic
+
+ delete_stub
+}
+
+test_pass
diff --git a/usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh b/usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh
new file mode 100644
index 0000000000..8a551a8182
--- /dev/null
+++ b/usr/src/test/util-tests/tests/dladm/show-overlay-exit.ksh
@@ -0,0 +1,82 @@
+#!/bin/ksh
+#
+# 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 (c) 2017, Joyent, Inc.
+#
+
+soe_arg0="$(basename $0)"
+
+soe_overlay="soe_overlay$$"
+soe_dummy_ip="169.254.0.0"
+
+soe_port="2000"
+soe_vnetid=20
+soe_encap="vxlan"
+soe_search="direct"
+
+soe_etherstub="soe_teststub$$"
+
+function fatal
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST_FAIL: $vt_arg0: $msg" >&2
+ dladm delete-overlay $soe_overlay
+ dladm delete-etherstub $soe_etherstub
+ exit 1
+}
+
+function setup
+{
+ dladm create-overlay -v $soe_vnetid -e $soe_encap -s $soe_search \
+ -p vxlan/listen_ip=$soe_dummy_ip -p direct/dest_ip=$soe_dummy_ip \
+ -p direct/dest_port=$soe_port $soe_overlay || \
+ fatal "failed to create overlay"
+
+ dladm create-etherstub $soe_etherstub || \
+ fatal "failed to create etherstub"
+}
+
+function cleanup
+{
+ dladm delete-overlay $soe_overlay || \
+ fatal "failed to remove overlay"
+ dladm delete-etherstub $soe_etherstub || \
+ fatal "failed to remove etherstub"
+}
+
+function runtest
+{
+ dladm show-overlay $* > /dev/null 2>&1
+}
+
+function epass
+{
+ runtest $* || fatal "show-overlay=$* failed, expected success\n"
+}
+
+function efail
+{
+ runtest $* && fatal "show-overlay=$* succeeded, expected failure\n"
+}
+
+setup
+
+epass $soe_overlay
+efail $soe_etherstub
+efail $soe_etherstub $soe_overlay
+efail $soe_overlay $soe_etherstub
+
+cleanup
+
+printf "TEST PASS: $soe_arg0"
diff --git a/usr/src/test/util-tests/tests/dladm/vnic-mtu.ksh b/usr/src/test/util-tests/tests/dladm/vnic-mtu.ksh
new file mode 100644
index 0000000000..cfb48e2e65
--- /dev/null
+++ b/usr/src/test/util-tests/tests/dladm/vnic-mtu.ksh
@@ -0,0 +1,116 @@
+#!/bin/ksh
+#
+# 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 2015 Joyent, Inc.
+#
+
+#
+# The purpose of this is to test the MTU property on VNICs, using both
+# temporary and persistent properties. To do this, we create an
+# Etherstub and then create various VNICs on top of it.
+#
+
+vm_arg0="$(basename $0)"
+vm_stub="teststub$$"
+vm_vnic="testvnic$$"
+
+VM_MTU_MIN=576
+VM_MTU_MAX=9000
+
+fatal()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST_FAIL: $vm_arg0: $msg" >&2
+
+ # Try to clean up just in case
+ dladm delete-vnic $vm_vnic 2>/dev/null
+ dladm delete-etherstub $vm_stub 2>/dev/null
+ exit 1
+}
+
+#
+# Validate that the MTU of the datalink dev has the MTU that we expect
+#
+validate_mtu()
+{
+ typeset dev=$1
+ typeset mtu=$2
+ typeset val
+
+ [[ -z "$dev" ]] && fatal "missing required device"
+ [[ -z "$mtu" ]] && fatal "missing required mtu"
+ val=$(dladm show-linkprop -c -p mtu -o value $dev)
+ [[ $? -eq 0 ]] || fatal "failed to get MTU for $dev"
+ (( $val == $mtu )) || fatal \
+ "mtu mismatch on $dev: expected $mtu, got $val"
+}
+
+delete_stub()
+{
+ dladm delete-etherstub $vm_stub || fatal \
+ "failed to delete stub $vm_stub"
+}
+
+create_stub()
+{
+ dladm create-etherstub $vm_stub || fatal \
+ "failed to create stub"
+ validate_mtu $vm_stub $VM_MTU_MAX
+}
+
+delete_vnic()
+{
+ dladm delete-vnic $vm_vnic || fatal "failed to delete vnic $vm_vnic"
+}
+
+test_vnic_pass()
+{
+ typeset mtu=$1
+ typeset flags=$2
+
+ [[ -z "$mtu" ]] && fatal "missing required mtu"
+ dladm create-vnic $flags -l $vm_stub -p mtu=$mtu $vm_vnic || fatal \
+ "failed to create vnic: $vm_vnic"
+ validate_mtu "$vm_vnic" "$mtu"
+ delete_vnic
+}
+
+test_vnic_fail()
+{
+ typeset mtu=$1
+ typeset flags=$2
+
+ [[ -z "$mtu" ]] && fatal "missing required mtu"
+ dladm create-vnic $flags -l $vm_stub -p mtu=$mtu \
+ $vm_vnic 2>/dev/null && fatal \
+ "created vnic with mtu $mtu, but failure expected"
+}
+
+test_pass()
+{
+ typeset flags=$1
+
+ create_stub
+ test_vnic_pass 1500 $flags
+ test_vnic_pass 1400 $flags
+ test_vnic_pass $VM_MTU_MIN $flags
+ test_vnic_pass $VM_MTU_MAX $flags
+ test_vnic_fail $((($VM_MTU_MIN - 1))) $flags
+ test_vnic_fail $((($VM_MTU_MAX + 1))) $flags
+ delete_stub
+}
+
+test_pass "-t"
+test_pass
+echo "TEST PASS: $vm_arg0"
diff --git a/usr/src/test/util-tests/tests/libnvpair_json/Makefile b/usr/src/test/util-tests/tests/libnvpair_json/Makefile
index d1d3585b02..3b48e0b630 100644
--- a/usr/src/test/util-tests/tests/libnvpair_json/Makefile
+++ b/usr/src/test/util-tests/tests/libnvpair_json/Makefile
@@ -10,14 +10,14 @@
#
#
-# Copyright (c) 2014 Joyent, Inc.
+# Copyright 2015 Joyent, Inc.
#
include $(SRC)/Makefile.master
ROOTOPTPKG = $(ROOT)/opt/util-tests
TESTDIR = $(ROOTOPTPKG)/tests/libnvpair_json
-ROOTBINDIR = $(ROOTOPTPKG)/bin
+TESTBIN = $(ROOTOPTPKG)/bin
PROG = print_json
@@ -38,9 +38,11 @@ include $(SRC)/test/Makefile.com
OBJS = $(PROG:%=%.o)
SRCS = $(OBJS:%.o=%.c)
-CMDS = $(PROG:%=$(ROOTBINDIR)/%) $(SCRIPTS:%=$(TESTDIR)/%)
+CMDS = $(PROG:%=$(TESTBIN)/%) $(SCRIPTS:%=$(TESTDIR)/%)
$(CMDS) := FILEMODE = 0555
+DIRS = $(TESTDIR) $(TESTBIN)
+
LDLIBS += -lnvpair
LINTFLAGS += -erroff=E_FUNC_ARG_UNUSED
@@ -61,16 +63,13 @@ clobber: clean
clean:
-$(RM) $(OBJS)
-$(CMDS): $(TESTDIR) $(PROG)
+$(CMDS): $(DIRS)
-$(ROOTBINDIR):
- $(INS.dir)
-
-$(ROOTBINDIR)/%: %
- $(INS.file)
-
-$(TESTDIR):
+$(DIRS):
$(INS.dir)
$(TESTDIR)/%: %.ksh
$(INS.rename)
+
+$(TESTBIN)/%: %
+ $(INS.file)
diff --git a/usr/src/test/util-tests/tests/libnvpair_json/json_08_large_data.ksh b/usr/src/test/util-tests/tests/libnvpair_json/json_08_large_data.ksh
new file mode 100644
index 0000000000..ca19e10d06
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libnvpair_json/json_08_large_data.ksh
@@ -0,0 +1,37 @@
+#!/bin/ksh
+#
+# 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 2015, Joyent, Inc.
+#
+
+DIR=$(dirname $(whence $0))
+. ${DIR}/json_common
+
+BASELINE="$(cat <<EOF
+{\
+"o":[\
+$(for i in {1..50}; do
+ printf '"%s",' 'some_very_big_string_that_takes_up_space'
+done)\
+"end"\
+]\
+}
+EOF)"
+
+OUTPUT="$(${DIR}/../../bin/print_json <<-EOF
+add_string_array "o" $(for i in {1..50}; do
+ printf '"%s" ' 'some_very_big_string_that_takes_up_space'
+done)"end";
+EOF)"
+
+complete
diff --git a/usr/src/test/util-tests/tests/libsff/Makefile b/usr/src/test/util-tests/tests/libsff/Makefile
new file mode 100644
index 0000000000..a4134ae739
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/Makefile
@@ -0,0 +1,81 @@
+#
+# 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 (c) 2017, Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/util-tests
+TESTDIR = $(ROOTOPTPKG)/tests/libsff
+
+DIFF_PROGS = \
+ libsff_8472 \
+ libsff_8636_diag \
+ libsff_8636_extspec \
+ libsff_8636_tech \
+ libsff_8636_temp \
+ libsff_br \
+ libsff_conn \
+ libsff_compliance \
+ libsff_enc \
+ libsff_ident \
+ libsff_lengths \
+ libsff_opts \
+ libsff_wave
+
+PROGS = $(DIFF_PROGS) \
+ libsff_efault \
+ libsff_einval \
+ libsff_strings
+
+SCRIPTS = libsff
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/cmd/Makefile.ctf
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROGS:%=$(TESTDIR)/%) $(SCRIPTS:%=$(TESTDIR)/%)
+OUTFILES = $(DIFF_PROGS:%=$(TESTDIR)/%.out)
+$(CMDS) := FILEMODE = 0555
+$(OUTFILES) := FILEMODE = 0444
+
+CPPFLAGS += -I$(SRC)/lib/libsff/common
+LDLIBS += -lsff -lnvpair
+
+all: $(PROGS)
+
+install: all $(CMDS) $(OUTFILES)
+
+lint: lint_SRCS
+
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
+
+$(TESTDIR)/%: %.ksh
+ $(INS.rename)
+
+%: %.c
+ $(LINK.c) -o $@ $< $(LDLIBS)
+ $(POST_PROCESS_O)
+
+
diff --git a/usr/src/test/util-tests/tests/libsff/libsff.ksh b/usr/src/test/util-tests/tests/libsff/libsff.ksh
new file mode 100644
index 0000000000..d9974bc10c
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff.ksh
@@ -0,0 +1,61 @@
+#! /usr/bin/ksh
+#
+#
+# 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 (c) 2017, Joyent, Inc.
+#
+
+#
+# Run all of the various libsff tests.
+#
+
+unalias -a
+sff_arg0=$(basename $0)
+sff_origwd=
+sff_root=
+sff_tests="8472 br compliance conn enc ident lengths opts strings wave"
+sff_tests="$sff_tests 8636_diag 8636_extspec 8636_tech 8636_temp einval efault"
+sff_outfile="/tmp/$sff_arg0.out.$$"
+
+fatal()
+{
+ typeset msg="$*"
+ [[ -z "$msg" ]] && msg="failed"
+ echo "TEST FAILED: $sff_arg0: $msg" >&2
+ rm -f $sff_outfile
+ exit 1
+}
+
+sff_origwd=$PWD
+cd $(dirname $0) || fatal "failed to cd to test root"
+sff_root=$PWD
+cd $dt_origwd || fatal "failed to return to original dir"
+
+for t in $sff_tests; do
+ difffile=
+ testfile=$sff_root/libsff_$t
+
+ if ! $testfile > $sff_outfile; then
+ fatal "failed to run $testfile"
+ fi
+
+ if [[ -f $testfile.out ]]; then
+ if ! diff $testfile.out $sff_outfile >/dev/null; then
+ fatal "$t results differ from expected values"
+ fi
+ fi
+ printf "TEST PASSED: libsff_%s\n" $t
+done
+
+rm -f $sff_outfile || fatal "failed to remove output file"
+exit 0
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8472.c b/usr/src/test/util-tests/tests/libsff/libsff_8472.c
new file mode 100644
index 0000000000..5649faabec
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8472.c
@@ -0,0 +1,61 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF 8472 Compliance levels
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8472_SFF_8472_COMPLIANCE] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP 8472 "
+ "Compliance value %d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_COMPLIANCE_8472,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_COMPLIANCE_8472, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8472.out b/usr/src/test/util-tests/tests/libsff/libsff_8472.out
new file mode 100644
index 0000000000..f3a878f20a
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8472.out
@@ -0,0 +1,255 @@
+Not compliant
+Rev 9.3
+Rev 9.5
+Rev 10.2
+Rev 10.4
+Rev 11.0
+Rev 11.3
+Rev 11.4
+Rev 12.0
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
+Unallocated
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.c b/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.c
new file mode 100644
index 0000000000..bf84ea9f39
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.c
@@ -0,0 +1,61 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF 8636 diagnostic monitoring
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ char **vals;
+ uint_t count, i;
+ nvlist_t *nvl;
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ buf[SFF_8636_DIAG_MONITORING] = 0xff;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP diagnostics: "
+ "%s\n", strerror(errno));
+ }
+
+ if ((ret = nvlist_lookup_string_array(nvl, LIBSFF_KEY_DIAG_MONITOR,
+ &vals, &count)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s: %s ",
+ LIBSFF_KEY_EXT_SPEC, strerror(ret));
+ }
+
+ for (i = 0; i < count; i++) {
+ (void) printf("%d\t%s\n", i, vals[i]);
+ }
+
+ nvlist_free(nvl);
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.out b/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.out
new file mode 100644
index 0000000000..b7e47c349e
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_diag.out
@@ -0,0 +1,2 @@
+0 Received power measurements: Average Power
+1 Transmitter power measurement
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.c b/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.c
new file mode 100644
index 0000000000..03d58658f6
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.c
@@ -0,0 +1,62 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF 8636 / 8024 extended specification values
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8636_LINK_CODES] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP link code "
+ "%d: %s\n", i, strerror(errno));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_EXT_SPEC,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_EXT_SPEC, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.out b/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.out
new file mode 100644
index 0000000000..1c55ceb022
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_extspec.out
@@ -0,0 +1,255 @@
+Unspecified
+100G AOC or 25GAUI C2M AOC
+100GBASE-SR4 or 25GBASE-SR
+100GBASE-LR4 or 25GBASE-LR
+100GBASE-ER4 or 25GBASE-ER
+100GBASE-SR10
+100G CWDM4
+100G PSM4 Parallel SMF
+100G ACC or 25GAUI C2M ACC
+Obsolete
+Reserved
+100GBASE-CR4 or 25GBASE-CR CA-L
+25GBASE-CR CA-S
+25GBASE-CR CA-N
+Reserved
+Reserved
+40GBASE-ER4
+4 x 10GBASE-SR
+40G PSM4 Parallel SMF
+G959.1 profile P1I1-2D1
+G959.1 profile P1S1-2D2
+G959.1 profile P1L1-2D2
+10GBASE-T with SFI electrical interface
+100G CLR4
+100G AOC or 25GAUI C2M AOC
+100G ACC or 25GAUI C2M ACC
+100GE-DWDM2
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c b/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c
new file mode 100644
index 0000000000..21f02cab8c
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c
@@ -0,0 +1,79 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print SFF 8636 device tech values.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+static void
+lst_print_array(nvlist_t *nvl, const char *key)
+{
+ int ret;
+ uint_t i, count;
+ char **vals;
+
+ if ((ret = nvlist_lookup_string_array(nvl, key, &vals, &count)) != 0) {
+ errx(1, "TEST FAILED failed to find key %s: %s\n", key,
+ strerror(ret));
+ }
+
+ (void) puts(key);
+ for (i = 0; i < count; i++) {
+ (void) printf("\t%d\t%s\n", i, vals[i]);
+ }
+}
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+
+ /*
+ * The upper four bits of this value are used as a 4-bit identifier. The
+ * lower four bits are used as options.
+ */
+ for (i = 0; i < 16; i++) {
+ int ret;
+ nvlist_t *nvl;
+
+ buf[SFF_8636_DEVICE_TECH] = i << 4;
+ buf[SFF_8636_DEVICE_TECH] |= (i % 16);
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP device tech "
+ "%d: %s\n", i, strerror(errno));
+ }
+
+ lst_print_array(nvl, LIBSFF_KEY_TRAN_TECH);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.out b/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.out
new file mode 100644
index 0000000000..c8652f21fb
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.out
@@ -0,0 +1,96 @@
+Transmitter Technology
+ 0 850 nm VCSEL
+ 1 No Wavelength Control
+ 2 Uncooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 1310 nm VCSEL
+ 1 No Wavelength Control
+ 2 Uncooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 1550 nm VCSEL
+ 1 No Wavelength Control
+ 2 Uncooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 1310 nm FP
+ 1 No Wavelength Control
+ 2 Uncooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 1310 nm DFB
+ 1 No Wavelength Control
+ 2 Cooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 1550 nm DFB
+ 1 No Wavelength Control
+ 2 Cooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 1310 nm EML
+ 1 No Wavelength Control
+ 2 Cooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 1550 nm EML
+ 1 No Wavelength Control
+ 2 Cooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 Other / Undefined
+ 1 Active Wavelength Control
+ 2 Uncooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 1490 nm DFB
+ 1 Active Wavelength Control
+ 2 Uncooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 Copper cable unequalized
+ 1 Active Wavelength Control
+ 2 Uncooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 Copper cable passive equalized
+ 1 Active Wavelength Control
+ 2 Uncooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 Copper cable, near and far end limiting active equalizers
+ 1 Active Wavelength Control
+ 2 Cooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 Copper cable, far end limiting active equalizers
+ 1 Active Wavelength Control
+ 2 Cooled Transmitter
+ 3 Pin Detector
+ 4 Transmitter Tunable
+Transmitter Technology
+ 0 Copper cable, near end limiting active equalizers
+ 1 Active Wavelength Control
+ 2 Cooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Not Tunable
+Transmitter Technology
+ 0 Copper cable, linear active equalizers
+ 1 Active Wavelength Control
+ 2 Cooled Transmitter
+ 3 APD Detector
+ 4 Transmitter Tunable
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.c b/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.c
new file mode 100644
index 0000000000..5e3ba70cd4
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.c
@@ -0,0 +1,61 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all case temperature values. Remember that 0 is special.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8636_MAX_CASE_TEMP] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP connector "
+ "%d: %s\n", i, strerror(errno));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_MAX_CASE_TEMP,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find connector when "
+ "parsing key %d: %s\n", i, strerror(errno));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.out b/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.out
new file mode 100644
index 0000000000..f4838c433b
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_8636_temp.out
@@ -0,0 +1,255 @@
+70 C
+1 C
+2 C
+3 C
+4 C
+5 C
+6 C
+7 C
+8 C
+9 C
+10 C
+11 C
+12 C
+13 C
+14 C
+15 C
+16 C
+17 C
+18 C
+19 C
+20 C
+21 C
+22 C
+23 C
+24 C
+25 C
+26 C
+27 C
+28 C
+29 C
+30 C
+31 C
+32 C
+33 C
+34 C
+35 C
+36 C
+37 C
+38 C
+39 C
+40 C
+41 C
+42 C
+43 C
+44 C
+45 C
+46 C
+47 C
+48 C
+49 C
+50 C
+51 C
+52 C
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+61 C
+62 C
+63 C
+64 C
+65 C
+66 C
+67 C
+68 C
+69 C
+70 C
+71 C
+72 C
+73 C
+74 C
+75 C
+76 C
+77 C
+78 C
+79 C
+80 C
+81 C
+82 C
+83 C
+84 C
+85 C
+86 C
+87 C
+88 C
+89 C
+90 C
+91 C
+92 C
+93 C
+94 C
+95 C
+96 C
+97 C
+98 C
+99 C
+100 C
+101 C
+102 C
+103 C
+104 C
+105 C
+106 C
+107 C
+108 C
+109 C
+110 C
+111 C
+112 C
+113 C
+114 C
+115 C
+116 C
+117 C
+118 C
+119 C
+120 C
+121 C
+122 C
+123 C
+124 C
+125 C
+126 C
+127 C
+128 C
+129 C
+130 C
+131 C
+132 C
+133 C
+134 C
+135 C
+136 C
+137 C
+138 C
+139 C
+140 C
+141 C
+142 C
+143 C
+144 C
+145 C
+146 C
+147 C
+148 C
+149 C
+150 C
+151 C
+152 C
+153 C
+154 C
+155 C
+156 C
+157 C
+158 C
+159 C
+160 C
+161 C
+162 C
+163 C
+164 C
+165 C
+166 C
+167 C
+168 C
+169 C
+170 C
+171 C
+172 C
+173 C
+174 C
+175 C
+176 C
+177 C
+178 C
+179 C
+180 C
+181 C
+182 C
+183 C
+184 C
+185 C
+186 C
+187 C
+188 C
+189 C
+190 C
+191 C
+192 C
+193 C
+194 C
+195 C
+196 C
+197 C
+198 C
+199 C
+200 C
+201 C
+202 C
+203 C
+204 C
+205 C
+206 C
+207 C
+208 C
+209 C
+210 C
+211 C
+212 C
+213 C
+214 C
+215 C
+216 C
+217 C
+218 C
+219 C
+220 C
+221 C
+222 C
+223 C
+224 C
+225 C
+226 C
+227 C
+228 C
+229 C
+230 C
+231 C
+232 C
+233 C
+234 C
+235 C
+236 C
+237 C
+238 C
+239 C
+240 C
+241 C
+242 C
+243 C
+244 C
+245 C
+246 C
+247 C
+248 C
+249 C
+250 C
+251 C
+252 C
+253 C
+254 C
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_br.c b/usr/src/test/util-tests/tests/libsff/libsff_br.c
new file mode 100644
index 0000000000..f0d3f25db2
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_br.c
@@ -0,0 +1,133 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print and tests SFF BR values.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+ char *val;
+
+ /*
+ * SFF 8472 has two different modes of printing the bit rate. It has a
+ * nominal bit rate and then if 0xff is in that field it has a max and
+ * min.
+ */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_BR_NOMINAL] = 0x42;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP compliance "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_NOMINAL, &val)) !=
+ 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", LIBSFF_KEY_BR_NOMINAL,
+ strerror(ret));
+ }
+ (void) printf("nominal: %s\n", val);
+
+ /*
+ * Make sure min, max are missing.
+ */
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_MIN, &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value for key "
+ "%s: %d\n", LIBSFF_KEY_BR_MIN, ret);
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_MAX, &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value for key "
+ "%s: %d\n", LIBSFF_KEY_BR_MAX, ret);
+ }
+ nvlist_free(nvl);
+
+ /*
+ * Now the opposite.
+ */
+ buf[SFF_8472_BR_NOMINAL] = 0xff;
+ buf[SFF_8472_BR_MAX] = 0x50;
+ buf[SFF_8472_BR_MIN] = 0x10;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP compliance "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_MAX, &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", LIBSFF_KEY_BR_MAX,
+ strerror(ret));
+ }
+ (void) printf("max: %s\n", val);
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_MIN, &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", LIBSFF_KEY_BR_MIN,
+ strerror(ret));
+ }
+ (void) printf("min: %s\n", val);
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_NOMINAL, &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value for key "
+ "%s: %d\n", LIBSFF_KEY_BR_NOMINAL, ret);
+ }
+ nvlist_free(nvl);
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ buf[SFF_8636_BR_NOMINAL] = 0x42;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP BR "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_BR_NOMINAL,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", LIBSFF_KEY_BR_NOMINAL,
+ strerror(ret));
+ }
+ (void) printf("nominal: %s\n", val);
+
+ nvlist_free(nvl);
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_br.out b/usr/src/test/util-tests/tests/libsff/libsff_br.out
new file mode 100644
index 0000000000..3973fb58aa
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_br.out
@@ -0,0 +1,8 @@
+nominal: 6600 MBd
+max: 20000 MBd
+min: 4000 MBd
+
+
+QSFP
+
+nominal: 6600 Mbps
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_compliance.c b/usr/src/test/util-tests/tests/libsff/libsff_compliance.c
new file mode 100644
index 0000000000..9aeb611228
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_compliance.c
@@ -0,0 +1,124 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print and tests SFF compliance values.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+static void
+lsc_print_array(nvlist_t *nvl, const char *key)
+{
+ int ret;
+ uint_t i, count;
+ char **vals;
+
+ if ((ret = nvlist_lookup_string_array(nvl, key, &vals, &count)) != 0) {
+ errx(1, "TEST FAILED failed to find key %s: %s\n", key,
+ strerror(ret));
+ }
+
+ (void) puts(key);
+ for (i = 0; i < count; i++) {
+ (void) printf("\t%d\t%s\n", i, vals[i]);
+ }
+}
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+
+ /*
+ * Set every shared bit for compliance then print them all out. Note we
+ * include reserved bits so that way if someone ends up adding something
+ * to one of the reserved fields, we end up printing it.
+ */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_COMPLIANCE_10GE] = 0xff;
+ buf[SFF_8472_COMPLIANCE_SONET_LOW] = 0xff;
+ buf[SFF_8472_COMPLIANCE_SONET_HIGH] = 0xff;
+ buf[SFF_8472_COMPLIANCE_ETHERNET] = 0xff;
+ buf[SFF_8472_COMPLIANCE_FC_LOW] = 0xff;
+ buf[SFF_8472_COMPLIANCE_FC_HIGH] = 0xff;
+ buf[SFF_8472_COMPLIANCE_FC_MEDIA] = 0xff;
+ buf[SFF_8472_COMPLIANCE_FC_SPEED] = 0xff;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP compliance "
+ "values: %s\n", strerror(ret));
+ }
+
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_10GBE);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_IB);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_ESCON);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_SONET);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_GBE);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_LEN);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_TECH);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_SFP);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_MEDIA);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_SPEED);
+
+ nvlist_free(nvl);
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ buf[SFF_8636_COMPLIANCE_10GBEP] = 0xff;
+ buf[SFF_8636_COMPLIANCE_SONET] = 0xff;
+ buf[SFF_8636_COMPLIANCE_SAS] = 0xff;
+ buf[SFF_8636_COMPLIANCE_ETHERNET] = 0xff;
+ buf[SFF_8636_COMPLIANCE_FCLEN] = 0xff;
+ buf[SFF_8636_COMPLIANCE_FC_LOW] = 0xff;
+ buf[SFF_8636_COMPLIANCE_FC_HIGH] = 0xff;
+ buf[SFF_8636_COMPLIANCE_FC_MEDIA] = 0xff;
+ buf[SFF_8636_COMPLIANCE_FC_SPEED] = 0xff;
+ buf[SFF_8636_EXTENDED_MODULE] = 0xff;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP compliance "
+ "values: %s\n", strerror(ret));
+ }
+
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_10GBE);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_SONET);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_SAS);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_GBE);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_LEN);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_TECH);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_MEDIA);
+ lsc_print_array(nvl, LIBSFF_KEY_COMPLIANCE_FC_SPEED);
+ lsc_print_array(nvl, LIBSFF_KEY_EXT_MOD_CODES);
+
+ nvlist_free(nvl);
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_compliance.out b/usr/src/test/util-tests/tests/libsff/libsff_compliance.out
new file mode 100644
index 0000000000..6f6ec66c44
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_compliance.out
@@ -0,0 +1,130 @@
+10G+ Ethernet Compliance Codes
+ 0 10G Base-SR
+ 1 10G Base-LR
+ 2 10G Base-LRM
+ 3 10G Base-ER
+Infiniband Compliance Codes
+ 0 1X Copper Passive
+ 1 1X Copper Active
+ 2 1X LX
+ 3 1X SX
+ESCON Compliance Codes
+ 0 ESCON SMF, 1310nm Laser
+ 1 ESCON MMF, 1310nm LED
+SONET Compliance Codes
+ 0 OC-48, short reach
+ 1 OC-48, intermediate reach
+ 2 OC-48, long reach
+ 3 ONET reach specifier bit 2
+ 4 SONET reach specifier bit 1
+ 5 OC-192, short reach
+ 6 OC-3, short reach
+ 7 OC-3, single mode, inter. reach
+ 8 OC-3, single mode, long reach
+ 9 OC-12, short reach
+ 10 OC-12, single mode, inter. reach
+ 11 OC-12, single mode, long reach
+Ethernet Compliance Codes
+ 0 1000BASE-SX
+ 1 1000BASE-LX
+ 2 1000BASE-CX
+ 3 1000BASE-T
+ 4 100BASE-LX/LX10
+ 5 100BASE-FX
+ 6 BASE-BX10
+ 7 BASE-PX
+Fibre Channel Link Lengths
+ 0 medium distance (M)
+ 1 long distance (L)
+ 2 intermeddiate distance (I)
+ 3 short distance (S)
+ 4 very long distance (V)
+Fibre Channel Technology
+ 0 Electrical inter-enclosure (EL)
+ 1 Longwave laser (LC)
+ 2 Shortwave laser, linear Rx (SA)
+ 3 Longwave laser (LL)
+ 4 Shortwave laser with OFC (SL)
+ 5 Shortwave laser w/o OFC (SN)
+ 6 Electrical intra-enclosure (EL)
+SFP+ Cable Technology
+ 0 Passive Cable
+ 1 Active Cable
+Fibre Channel Transmission Media
+ 0 Single Mode (SM)
+ 1 Multimode, 50um (M5, M5E)
+ 2 Multimode, 62.5um (M6)
+ 3 Video Coax (TV)
+ 4 Miniature Coax (MI)
+ 5 Twisted Pair (TP)
+ 6 Twin Axial Pair (TW)
+Fibre Channel Speed
+ 0 100 MBytes/sec
+ 1 200 MBytes/sec
+ 2 3200 MBytes/sec
+ 3 400 MBytes/sec
+ 4 1600 MBytes/sec
+ 5 800 MBytes/sec
+ 6 1200 MBytes/sec
+
+
+QSFP
+
+10G+ Ethernet Compliance Codes
+ 0 40G Active Cable (XLPPI)
+ 1 40GBASE-LR4
+ 2 40GBASE-SR4
+ 3 40GBASE-CR4
+ 4 10GBASE-SR
+ 5 10GBASE-LR
+ 6 10GBASE-LRM
+SONET Compliance Codes
+ 0 OC 48 short reach
+ 1 OC 48, intermediate reach
+ 2 OC 48, long reach
+SAS Compliance Codes
+ 0 SAS 3.0 Gb/s
+ 1 SAS 6.0 Gb/s
+ 2 SAS 12.0 Gb/s
+ 3 SAS 24.0 Gb/s
+Ethernet Compliance Codes
+ 0 1000BASE-SX
+ 1 1000BASE-LX
+ 2 1000BASE-CX
+ 3 1000BASE-T
+Fibre Channel Link Lengths
+ 0 medium distance (M)
+ 1 long distance (L)
+ 2 intermeddiate distance (I)
+ 3 short distance (S)
+ 4 very long distance (V)
+Fibre Channel Technology
+ 0 Electrical inter-enclosure (EL)
+ 1 Longwave laser (LC)
+ 2 Longwave laser (LL)
+ 3 Shortwave laser with OFC (SL)
+ 4 Shortwave laser w/o OFC (SN)
+ 5 Electrical intra-enclosure (EL)
+Fibre Channel Transmission Media
+ 0 Single Mode (SM)
+ 1 Multimode, 50um (OM3)
+ 2 Multimode, 50m (M5)
+ 3 Multimode, 62.5um (M6)
+ 4 Video Coax (TV)
+ 5 Miniature Coax (MI)
+ 6 Twisted Pair (TP)
+ 7 Twin Axial Pair (TW)
+Fibre Channel Speed
+ 0 100 MBytes/sec
+ 1 200 MBytes/sec
+ 2 3200 MBytes/sec
+ 3 400 MBytes/sec
+ 4 1600 MBytes/sec
+ 5 800 MBytes/sec
+ 6 1200 MBytes/sec
+Extended Module Codes
+ 0 SDR
+ 1 DDR
+ 2 QDR
+ 3 FDR
+ 4 EDR
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_conn.c b/usr/src/test/util-tests/tests/libsff/libsff_conn.c
new file mode 100644
index 0000000000..778eaf1105
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_conn.c
@@ -0,0 +1,89 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF Connector values
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8472_CONNECTOR] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP connector "
+ "%d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_CONNECTOR,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_CONNECTOR, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8636_CONNECTOR] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP connector "
+ "%d: %s\n", i, strerror(errno));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_CONNECTOR,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_CONNECTOR, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_conn.out b/usr/src/test/util-tests/tests/libsff/libsff_conn.out
new file mode 100644
index 0000000000..68dfb0e4d5
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_conn.out
@@ -0,0 +1,514 @@
+Unknown
+SC (Subscriber Connector)
+Fibre Channel Style 1 copper connector
+Fibre Channel Style 2 copper connector
+BNC/TNC (Bayonet/Threaded Neill-Concelman)
+Fibre Channel coax headers
+Fiber Jack
+LC (Lucent Connector)
+MT-RJ (Mechanical Transfer - Registered Jack)
+MU (Multiple Optical)
+SG
+Optical Pigtail
+MPO 1x12 (Multifiber Parallel Optic)
+MPO 2x16
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+HSSDC II (High Speed Serial Data Connector)
+Copper pigtail
+RJ45 (Registered Jack)
+No separable connector
+MXC 2x16
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+
+
+QSFP
+
+Unknown
+SC (Subscriber Connector)
+Fibre Channel Style 1 copper connector
+Fibre Channel Style 2 copper connector
+BNC/TNC (Bayonet/Threaded Neill-Concelman)
+Fibre Channel coax headers
+Fiber Jack
+LC (Lucent Connector)
+MT-RJ (Mechanical Transfer - Registered Jack)
+MU (Multiple Optical)
+SG
+Optical Pigtail
+MPO 1x12 (Multifiber Parallel Optic)
+MPO 2x16
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+HSSDC II (High Speed Serial Data Connector)
+Copper pigtail
+RJ45 (Registered Jack)
+No separable connector
+MXC 2x16
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_efault.c b/usr/src/test/util-tests/tests/libsff/libsff_efault.c
new file mode 100644
index 0000000000..7f57529d81
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_efault.c
@@ -0,0 +1,54 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Test various error cases all of which should return EFAULT.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int
+main(void)
+{
+ int ret;
+ void *addr;
+ nvlist_t *nvl;
+ size_t len = getpagesize();
+
+ /*
+ * Get an unreadable page
+ */
+ if ((addr = mmap(NULL, len, PROT_READ, MAP_PRIVATE | MAP_ANON, -1,
+ 0)) == MAP_FAILED) {
+ err(1, "TEST FAILED: failed to mmap private page");
+ }
+
+ if (mprotect(addr, len, PROT_NONE) != 0) {
+ err(1, "TEST FAILED: failed to protect private page");
+ }
+
+ if ((ret = libsff_parse(addr, 128, 0xa0, &nvl)) != EFAULT) {
+ errx(1, "TEST FAILED: failed to return EFAULT on bad"
+ "data buffer\n");
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_einval.c b/usr/src/test/util-tests/tests/libsff/libsff_einval.c
new file mode 100644
index 0000000000..ac835f95e7
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_einval.c
@@ -0,0 +1,88 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Test various error cases all of which should return EINVAL.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+#include "sff.h"
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+
+ bzero(buf, sizeof (buf));
+ if ((ret = libsff_parse(NULL, sizeof (buf), 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on NULL buffer");
+ }
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, NULL)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on NULL nvl");
+ }
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa1, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad page");
+ }
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad page");
+ }
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xff, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad page");
+ }
+
+ if ((ret = libsff_parse(buf, 0, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
+ "size");
+ }
+
+ if ((ret = libsff_parse(buf, 50, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
+ "size");
+ }
+
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ if ((ret = libsff_parse(buf, 0, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
+ "size");
+ }
+
+ if ((ret = libsff_parse(buf, 50, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8476 "
+ "size");
+ }
+
+ if ((ret = libsff_parse(buf, 96, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "
+ "size");
+ }
+
+ if ((ret = libsff_parse(buf, 128, 0xa0, &nvl)) != EINVAL) {
+ errx(1, "TEST FAILED: failed to return EINVAL on bad 8635 "
+ "size");
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_enc.c b/usr/src/test/util-tests/tests/libsff/libsff_enc.c
new file mode 100644
index 0000000000..77ac12b2ed
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_enc.c
@@ -0,0 +1,89 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF Encoding values
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8472_ENCODING] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP connector "
+ "%d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_ENCODING,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_ENCODING, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8636_ENCODING] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP connector "
+ "%d: %s\n", i, strerror(errno));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_ENCODING,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_ENCODING, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_enc.out b/usr/src/test/util-tests/tests/libsff/libsff_enc.out
new file mode 100644
index 0000000000..b31a565e4e
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_enc.out
@@ -0,0 +1,514 @@
+Unspecified
+8B/10B
+4B/5B
+NRZ
+Manchester
+SONET Scrambled
+64B/66B
+256B/257B
+PAM4
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+
+
+QSFP
+
+Unspecified
+8B/10B
+4B/5B
+NRZ
+SONET Scrambled
+64B/66B
+Manchester
+256B/257B
+PAM4
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_ident.c b/usr/src/test/util-tests/tests/libsff/libsff_ident.c
new file mode 100644
index 0000000000..0065a6d0e0
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_ident.c
@@ -0,0 +1,60 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print all SFF Identifier values
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ uint_t i;
+ uint8_t buf[256];
+
+ bzero(buf, sizeof (buf));
+ for (i = 0; i < UINT8_MAX; i++) {
+ int ret;
+ nvlist_t *nvl;
+ char *val;
+
+ buf[SFF_8472_IDENTIFIER] = i;
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse identifier "
+ "%d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_IDENTIFIER,
+ &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find key %s with "
+ "value %d: %s", LIBSFF_KEY_IDENTIFIER, i,
+ strerror(ret));
+ }
+
+ (void) puts(val);
+ nvlist_free(nvl);
+ }
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_ident.out b/usr/src/test/util-tests/tests/libsff/libsff_ident.out
new file mode 100644
index 0000000000..360c5966f8
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_ident.out
@@ -0,0 +1,255 @@
+Unknown or Unspecified
+GBIC
+Module/connector soldered to motherboard
+SFP/SFP+/SFP28
+300 pin XBI
+XENPAK
+XFP
+XFF
+XFP-E
+XPAK
+X2
+DWDM-SFP/SFP+ (not using SFF-8472)
+QSFP
+QSFP+ or later
+CXP or later
+Shielded Mini Multilane HD 4X
+Shielded Mini Multilane HD 8X
+QSFP28 or later
+CXP2 (aka CXP28) or later
+CDFP (Style 1/Style2)
+Shielded Mini Multilane HD 4X Fanout Cable
+Shielded Mini Multilane HD 8X Fanout Cable
+CDFP (Style 3)
+microQSFP
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Reserved
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
+Vendor Specific
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_lengths.c b/usr/src/test/util-tests/tests/libsff/libsff_lengths.c
new file mode 100644
index 0000000000..f77b29a397
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_lengths.c
@@ -0,0 +1,133 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print and tests SFF length values.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+ char *val;
+ uint_t i;
+ const char *lengths_8472[] = { LIBSFF_KEY_LENGTH_SMF_KM,
+ LIBSFF_KEY_LENGTH_SMF, LIBSFF_KEY_LENGTH_OM2, LIBSFF_KEY_LENGTH_OM1,
+ LIBSFF_KEY_LENGTH_COPPER, LIBSFF_KEY_LENGTH_OM3, NULL };
+ const char *lengths_8636[] = { LIBSFF_KEY_LENGTH_SMF_KM,
+ LIBSFF_KEY_LENGTH_OM2, LIBSFF_KEY_LENGTH_OM1,
+ LIBSFF_KEY_LENGTH_COPPER, LIBSFF_KEY_LENGTH_OM3, NULL };
+
+ /*
+ * Make sure if lengths are zero that they don't show up.
+ */
+ bzero(buf, sizeof (buf));
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP length "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; lengths_8472[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, lengths_8472[i], &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value "
+ "for key %s: %d\n", lengths_8472[i], ret);
+ }
+ }
+
+ nvlist_free(nvl);
+
+ buf[SFF_8472_LENGTH_SMF_KM] = 0x23;
+ buf[SFF_8472_LENGTH_SMF] = 0x24;
+ buf[SFF_8472_LENGTH_50UM] = 0x25;
+ buf[SFF_8472_LENGTH_62UM] = 0x26;
+ buf[SFF_8472_LENGTH_COPPER] = 0x27;
+ buf[SFF_8472_LENGTH_OM3] = 0x28;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP length "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; lengths_8472[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, lengths_8472[i], &val)) !=
+ 0) {
+ errx(1, "TEST FALIED: failed to find length for key "
+ "%s: %d\n", lengths_8472[i], ret);
+ }
+ (void) printf("%s: %s\n", lengths_8472[i], val);
+ }
+
+ nvlist_free(nvl);
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP length "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; lengths_8472[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, lengths_8472[i], &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value "
+ "for key %s: %d\n", lengths_8472[i], ret);
+ }
+ }
+
+ nvlist_free(nvl);
+
+ buf[SFF_8636_LENGTH_SMF] = 0x23;
+ buf[SFF_8636_LENGTH_OM3] = 0x24;
+ buf[SFF_8636_LENGTH_OM2] = 0x25;
+ buf[SFF_8636_LENGTH_OM1] = 0x26;
+ buf[SFF_8636_LENGTH_COPPER] = 0x27;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP length "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; lengths_8636[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, lengths_8636[i], &val)) !=
+ 0) {
+ errx(1, "TEST FALIED: failed to find length for key "
+ "%s: %d\n", lengths_8472[i], ret);
+ }
+ (void) printf("%s: %s\n", lengths_8636[i], val);
+ }
+
+ nvlist_free(nvl);
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_lengths.out b/usr/src/test/util-tests/tests/libsff/libsff_lengths.out
new file mode 100644
index 0000000000..9be9d76804
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_lengths.out
@@ -0,0 +1,15 @@
+Length SMF (km): 35 km
+Length SMF (m): 3600 m
+Length 50um OM2: 370 m
+Length 62.5um OM1: 380 m
+Length Copper: 39 m
+Length OM3: 400 m
+
+
+QSFP
+
+Length SMF (km): 35 km
+Length 50um OM2: 37 m
+Length 62.5um OM1: 38 m
+Length Copper: 39 m
+Length OM3: 72 m
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_opts.c b/usr/src/test/util-tests/tests/libsff/libsff_opts.c
new file mode 100644
index 0000000000..e91365dc6a
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_opts.c
@@ -0,0 +1,98 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print and tests SFF options values.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+static void
+lso_print_array(nvlist_t *nvl, const char *key)
+{
+ int ret;
+ uint_t i, count;
+ char **vals;
+
+ if ((ret = nvlist_lookup_string_array(nvl, key, &vals, &count)) != 0) {
+ errx(1, "TEST FAILED failed to find key %s: %s\n", key,
+ strerror(ret));
+ }
+
+ (void) puts(key);
+ for (i = 0; i < count; i++) {
+ (void) printf("\t%d\t%s\n", i, vals[i]);
+ }
+}
+
+int
+main(void)
+{
+ int ret;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+
+ /*
+ * Set every shared bit for options then print them all out. Note we
+ * include reserved bits so that way if someone ends up adding something
+ * to one of the reserved fields, we end up printing it.
+ */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_OPTIONS_HI] = 0xff;
+ buf[SFF_8472_OPTIONS_LOW] = 0xff;
+ buf[SFF_8472_ENHANCED_OPTIONS] = 0xff;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP options "
+ "values: %s\n", strerror(ret));
+ }
+
+ lso_print_array(nvl, LIBSFF_KEY_OPTIONS);
+ lso_print_array(nvl, LIBSFF_KEY_EXTENDED_OPTIONS);
+
+ nvlist_free(nvl);
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ buf[SFF_8636_OPTIONS_HI] = 0xff;
+ buf[SFF_8636_OPTIONS_MID] = 0xff;
+ buf[SFF_8636_OPTIONS_LOW] = 0xff;
+ buf[SFF_8636_ENHANCED_OPTIONS] = 0xff;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP options "
+ "values: %s\n", strerror(ret));
+ }
+
+ lso_print_array(nvl, LIBSFF_KEY_OPTIONS);
+ lso_print_array(nvl, LIBSFF_KEY_ENHANCED_OPTIONS);
+
+ nvlist_free(nvl);
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_opts.out b/usr/src/test/util-tests/tests/libsff/libsff_opts.out
new file mode 100644
index 0000000000..870ea735ac
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_opts.out
@@ -0,0 +1,50 @@
+Options
+ 0 Rx_LOS implemented
+ 1 Rx_LOS inverted
+ 2 TX_FAULT implemented
+ 3 TX_DISABLE implemented
+ 4 RATE_SELECT implemented
+ 5 Tunable transmitter
+ 6 Receiver decision threshold implemented
+ 7 Linear Receiver Output Implemented
+ 8 Power Level 2 Requirement
+ 9 Cooled Transceiver Implemented
+ 10 Retimer or CDR implemented
+ 11 Paging Implemented
+ 12 Power Level 3 Requirement
+Extended Options
+ 0 Soft Rate Select Control Implemented
+ 1 Application Select implemented
+ 2 Soft RATE_SELECT implemented
+ 3 Soft RX_LOS implemented
+ 4 Soft TX_FAULT implemented
+ 5 Soft TX_DISABLE implemented
+ 6 Alarm/Warning flags implemented
+
+
+QSFP
+
+Options
+ 0 Tx Loss of Signal implemented
+ 1 Tx Squelch for Pave
+ 2 Tx_FAULT implemented
+ 3 Tx_DISABLE implemented
+ 4 Rate Select implemented
+ 5 Memory page 01h provided
+ 6 Memory page 02h provided
+ 7 Tx Squelch implemented
+ 8 Tx Squelch Disable implemented
+ 9 Rx Output Disable capable
+ 10 Rx Squelch Disable implemented
+ 11 Rx CDR Loss of Lock Flag implemented
+ 12 Tx CDR Loss of Lock Flag implemented
+ 13 RX CDR On/Off Control implemented
+ 14 TX CDR On/Off Control implemented
+ 15 RX Output Amplitude Fixed Programmable Settings
+ 16 RX Output Emphasis Fixed Programmable Settings
+ 17 TX Input Equalization Fixed Programmable
+ 18 TX Input Equalization Auto Adaptive Capable
+Enhanced Options
+ 0 Application Select Table Supported
+ 1 Extended Rate Selection Supported
+ 2 Initialization Complete Flag Implemented
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_strings.c b/usr/src/test/util-tests/tests/libsff/libsff_strings.c
new file mode 100644
index 0000000000..a9d5a2252f
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_strings.c
@@ -0,0 +1,133 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Test our ability to parse SFF string values which are space encoded. As this
+ * is shared between the SFP and QSFP logic, we end up only testing the SFP
+ * based data.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff. Strings are
+ * described as having spaces at the end of them. We mostly want to make sure
+ * that if we have strings without spaces that we parse them sanely as well as
+ * test what happens with embedded spaces and NUL characters.
+ */
+#include "sff.h"
+
+typedef struct {
+ uint8_t lss_bytes[16];
+ const char *lss_parsed;
+} lsfs_string_pair_t;
+
+static const lsfs_string_pair_t lsfs_bad_vals[] = {
+ /* All NULs */
+ { { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' },
+ "" },
+ /* Embedded NULs */
+ { { 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
+ '\0', 'a', 'a', 'a', 'a', 'a', 'a', 'a' },
+ "" },
+ /* Non-ASCII */
+ { { 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
+ 156, 'a', 'a', 'a', 'a', 'a', 'a', 'a' },
+ "" },
+ /* All padding */
+ { { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
+ "" }
+};
+#define NBAD (sizeof (lsfs_bad_vals) / sizeof (lsfs_string_pair_t))
+
+static const lsfs_string_pair_t lsfs_good_vals[] = {
+ /* Basic Name */
+ { { 'f', 'i', 'n', 'g', 'o', 'l', 'f', 'i',
+ 'n', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
+ "fingolfin" },
+ /* Non-padding Space */
+ { { 'G', 'l', 'o', 'b', 'e', 'x', ' ', 'C',
+ 'o', 'r', 'p', ' ', ' ', ' ', ' ', ' ' },
+ "Globex Corp" },
+ /* 1-character name to catch off by one */
+ { { '~', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
+ "~" },
+ /* Use all characters */
+ { { '!', '!', '!', '!', '!', '!', '!', '!',
+ '!', '!', '!', '!', '!', '!', '!', '!' },
+ "!!!!!!!!!!!!!!!!" }
+};
+#define NGOOD (sizeof (lsfs_good_vals) / sizeof (lsfs_string_pair_t))
+
+int
+main(void)
+{
+ int ret, i;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+ char *val;
+
+ for (i = 0; i < NBAD; i++) {
+ bzero(buf, sizeof (buf));
+ bcopy(lsfs_bad_vals[i].lss_bytes, &buf[SFF_8472_VENDOR],
+ SFF_8472_VENDOR_LEN);
+
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP bad string "
+ "case %d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_VENDOR,
+ &val)) != ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value "
+ "for %s: %d\n", LIBSFF_KEY_VENDOR, ret);
+ }
+ nvlist_free(nvl);
+ }
+
+ for (i = 0; i < NGOOD; i++) {
+ bzero(buf, sizeof (buf));
+ bcopy(lsfs_good_vals[i].lss_bytes, &buf[SFF_8472_VENDOR],
+ SFF_8472_VENDOR_LEN);
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP good string "
+ "case %d: %s\n", i, strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_VENDOR,
+ &val)) != 0) {
+ errx(1, "TEST FALIED: failed to find expected key "
+ "%s: %d", LIBSFF_KEY_VENDOR, ret);
+ }
+
+ if (strcmp(val, lsfs_good_vals[i].lss_parsed) != 0) {
+ errx(1, "TEST FAILED: expected string %s, found %s\n",
+ lsfs_good_vals[i].lss_parsed, val);
+ }
+
+ nvlist_free(nvl);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_wave.c b/usr/src/test/util-tests/tests/libsff/libsff_wave.c
new file mode 100644
index 0000000000..08b3637e06
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_wave.c
@@ -0,0 +1,177 @@
+/*
+ * 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 (c) 2017, Joyent, Inc.
+ */
+
+/*
+ * Print and tests SFF Wavelength values. Note that in both SFF 8472 and SFF
+ * 8636 the wavelength values also double for various copper complaince values.
+ * We check both forms here. Note that the copper compliance in SFF 8472 is
+ * currently tested in libsff_compliance.c. SFF 8636's Copper Attenuation values
+ * are tested here.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <strings.h>
+#include <err.h>
+#include <libsff.h>
+
+/*
+ * Pick up private sff header file with offsets from lib/libsff.
+ */
+#include "sff.h"
+
+int
+main(void)
+{
+ int ret, i;
+ uint8_t buf[256];
+ nvlist_t *nvl;
+ char *val;
+ char *attenuate[] = { LIBSFF_KEY_ATTENUATE_2G, LIBSFF_KEY_ATTENUATE_5G,
+ LIBSFF_KEY_ATTENUATE_7G, LIBSFF_KEY_ATTENUATE_12G, NULL };
+ char *wave[] = { LIBSFF_KEY_WAVELENGTH, LIBSFF_KEY_WAVE_TOLERANCE,
+ NULL };
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_WAVELENGTH_HI] = 0x12;
+ buf[SFF_8472_WAVELENGTH_LOW] = 0x34;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP wavelength "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_WAVELENGTH, &val)) !=
+ 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", LIBSFF_KEY_WAVELENGTH,
+ strerror(ret));
+ }
+ (void) printf("%s: %s\n", LIBSFF_KEY_WAVELENGTH, val);
+ nvlist_free(nvl);
+
+ /*
+ * Make sure wavelength is missing if we specify a copper compliance.
+ */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_COMPLIANCE_SFP] = 0x08;
+ buf[SFF_8472_WAVELENGTH_HI] = 0x12;
+ buf[SFF_8472_WAVELENGTH_LOW] = 0x34;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP wavelength "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_WAVELENGTH, &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value for key "
+ "%s: %d\n", LIBSFF_KEY_WAVELENGTH, ret);
+ }
+
+ nvlist_free(nvl);
+
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_COMPLIANCE_SFP] = 0x04;
+ buf[SFF_8472_WAVELENGTH_HI] = 0x12;
+ buf[SFF_8472_WAVELENGTH_LOW] = 0x34;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse SFP wavelength "
+ "values: %s\n", strerror(ret));
+ }
+
+ if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_WAVELENGTH, &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value for key "
+ "%s: %d\n", LIBSFF_KEY_WAVELENGTH, ret);
+ }
+
+ nvlist_free(nvl);
+
+ /*
+ * Now for QSFP+
+ */
+ (void) puts("\n\nQSFP\n");
+
+ /* First copper */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+ buf[SFF_8636_DEVICE_TECH] = 0xa0;
+
+ buf[SFF_8636_ATTENUATE_2G] = 0x42;
+ buf[SFF_8636_ATTENUATE_5G] = 0x43;
+ buf[SFF_8636_ATTENUATE_7G] = 0x44;
+ buf[SFF_8636_ATTENUATE_12G] = 0x45;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP BR "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; attenuate[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, attenuate[i], &val)) !=
+ 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", attenuate[i],
+ strerror(ret));
+ }
+ (void) printf("%s: %s\n", attenuate[i], val);
+ }
+
+ for (i = 0; wave[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, wave[i], &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value "
+ "for key %s: %d\n", attenuate[i], ret);
+ }
+
+ }
+ nvlist_free(nvl);
+
+ /* Now normal wavelengths */
+ bzero(buf, sizeof (buf));
+ buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
+
+ buf[SFF_8636_WAVELENGTH_NOMINAL_HI] = 0x12;
+ buf[SFF_8636_WAVELENGTH_NOMINAL_LOW] = 0x34;
+ buf[SFF_8636_WAVELENGTH_TOLERANCE_HI] = 0x56;
+ buf[SFF_8636_WAVELENGTH_TOLERANCE_LOW] = 0x78;
+
+ if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
+ errx(1, "TEST FAILED: failed to parse QSFP Wavelength "
+ "values: %s\n", strerror(ret));
+ }
+
+ for (i = 0; wave[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, wave[i], &val)) != 0) {
+ errx(1, "TEST FAILED: failed to find %s: %s when "
+ "parsing key %d: %s\n", wave[i], strerror(ret));
+ }
+ (void) printf("%s: %s\n", wave[i], val);
+ }
+
+ for (i = 0; attenuate[i] != NULL; i++) {
+ if ((ret = nvlist_lookup_string(nvl, attenuate[i], &val)) !=
+ ENOENT) {
+ errx(1, "TEST FALIED: found unexpected return value "
+ "for key %s: %d\n", attenuate[i], ret);
+ }
+
+ }
+ nvlist_free(nvl);
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/libsff/libsff_wave.out b/usr/src/test/util-tests/tests/libsff/libsff_wave.out
new file mode 100644
index 0000000000..190e296478
--- /dev/null
+++ b/usr/src/test/util-tests/tests/libsff/libsff_wave.out
@@ -0,0 +1,11 @@
+Laser Wavelength: 4660 nm
+
+
+QSFP
+
+Cable Attenuation at 2.5 GHz: 66 dB
+Cable Attenuation at 5.0 GHz: 67 dB
+Cable Attenuation at 7.0 GHz: 68 dB
+Cable Attenuation at 12.9 GHz: 69 dB
+Laser Wavelength: 233.000 nm
+Wavelength Tolerance: 1106.800 nm
diff --git a/usr/src/test/util-tests/tests/mergeq/Makefile b/usr/src/test/util-tests/tests/mergeq/Makefile
new file mode 100644
index 0000000000..ef6c6abb99
--- /dev/null
+++ b/usr/src/test/util-tests/tests/mergeq/Makefile
@@ -0,0 +1,64 @@
+#
+# 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 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/util-tests
+TESTDIR = $(ROOTOPTPKG)/tests/mergeq
+
+PROG = mqt
+OBJS = mqt.o mergeq.o
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/cmd/Makefile.ctf
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+CPPFLAGS += -I$(SRC)/lib/mergeq -D_REENTRANT
+LDLIBS += -lumem
+
+all: $(PROG)
+
+install: all $(CMDS)
+
+lint: lint_SRCS
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(OBJS)
+
+%.o: %.c
+ $(COMPILE.c) -o $@ -c $<
+ $(POST_PROCESS_O)
+
+%.o: $(SRC)/lib/mergeq/%.c
+ $(COMPILE.c) -o $@ -c $<
+ $(POST_PROCESS_O)
+
+$(PROG): $(OBJS)
+ $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+ $(POST_PROCESS)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/util-tests/tests/mergeq/mqt.c b/usr/src/test/util-tests/tests/mergeq/mqt.c
new file mode 100644
index 0000000000..e61e9173d2
--- /dev/null
+++ b/usr/src/test/util-tests/tests/mergeq/mqt.c
@@ -0,0 +1,217 @@
+/*
+ * 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 2015 Joyent, Inc.
+ */
+
+/*
+ * mergeq testing routines
+ */
+
+#include <mergeq.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+const char *
+_umem_debug_init()
+{
+ return ("default,verbose");
+}
+
+const char *
+_umem_logging_init(void)
+{
+ return ("fail,contents");
+}
+
+void *
+mergeq_alloc(size_t size)
+{
+ return (malloc(size));
+}
+
+/*ARGSUSED*/
+void
+mergeq_free(void *buf, size_t size)
+{
+ free(buf);
+}
+
+static int
+mqt_int(void *first, void *second, void **outp, void *arg)
+{
+ uintptr_t a, b, c;
+ a = (uintptr_t)first;
+ b = (uintptr_t)second;
+ c = a + b;
+ *outp = (void *)c;
+
+ return (0);
+}
+
+static int
+mqt_append(void *first, void *second, void **outp, void *arg)
+{
+ char *out;
+
+ /* Yes, this leaks, don't worry about it for the test */
+ if (asprintf(&out, "%s%s", first, second) != -1) {
+ *outp = out;
+ return (0);
+ }
+ return (-1);
+}
+
+static int
+mqt_fatal(void *first, void *second, void **outp, void *arg)
+{
+ return (-1);
+}
+
+/*
+ * Test structures and cases. We really want mq_args to be a flexible array
+ * member, but then we cant initialize it. Thus we set a fixed size number of
+ * entries.
+ */
+typedef struct mq_test {
+ const char *mq_desc; /* test description/name */
+ mergeq_proc_f *mq_proc; /* processing function */
+ int mq_rval; /* mergeq_merge return value */
+ int mq_uerr; /* user error, if any */
+ boolean_t mq_strcmp; /* use strcmp rather than == */
+ void *mq_result; /* expected result */
+ void **mq_args; /* argument array */
+} mq_test_t;
+
+static void *mqt_empty_args[] = { NULL };
+static void *mqt_single_args[] = { (void *)42, NULL };
+static void *mqt_double_args[] = { (void *)42, (void *)27, NULL };
+static void *mqt_wrap_args[] = {
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, NULL
+};
+static void *mqt_grow_args[] = {
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, NULL
+};
+static void *mqt_order_args[] = { "l", "e", "g", "e", "n", "d", " ", "o", "f",
+ " ", "z", "e", "l", "d", "a", NULL };
+
+
+static mq_test_t mq_tests[] = {
+ { "empty", mqt_int, 0, 0, B_FALSE, NULL, mqt_empty_args },
+ { "single", mqt_int, 0, 0, B_FALSE, (void *)42, mqt_single_args },
+ { "double", mqt_int, 0, 0, B_FALSE, (void *)69, mqt_double_args },
+ { "wrap", mqt_int, 0, 0, B_FALSE, (void *)64, mqt_wrap_args },
+ { "grow", mqt_int, 0, 0, B_FALSE, (void *)92, mqt_grow_args },
+ { "fatal", mqt_fatal, MERGEQ_UERROR, -1, B_FALSE, NULL,
+ mqt_double_args },
+ { "order", mqt_append, 0, 0, B_TRUE, "alegend of zeld", mqt_order_args }
+};
+
+#define NMQ_TESTS (sizeof (mq_tests) / sizeof (mq_test_t))
+
+static void
+mq_test_run(mergeq_t *mqp, mq_test_t *mqt)
+{
+ int ret, err;
+ void **itemp = mqt->mq_args;
+ void *out;
+
+ while (*itemp != NULL) {
+ if ((ret = mergeq_add(mqp, *itemp)) != 0) {
+ (void) fprintf(stderr,
+ "test %s: failed to add item: %s\n",
+ mqt->mq_desc, strerror(errno));
+ exit(1);
+ }
+ itemp++;
+ }
+
+ ret = mergeq_merge(mqp, mqt->mq_proc, NULL, &out, &err);
+ if (ret != mqt->mq_rval) {
+ (void) fprintf(stderr, "test %s: got incorrect rval. "
+ "Expected %d, got %d\n", mqt->mq_desc, mqt->mq_rval, ret);
+ exit(1);
+ }
+
+ if (ret == MERGEQ_UERROR && err != mqt->mq_uerr) {
+ (void) fprintf(stderr, "test %s: got incorrect user error. "
+ "Expected %d, got %d\n", mqt->mq_desc, mqt->mq_uerr, err);
+ exit(1);
+ }
+
+ if (ret == 0) {
+ if (mqt->mq_strcmp == B_TRUE &&
+ strcmp(out, mqt->mq_result) != 0) {
+ (void) fprintf(stderr, "test %s: got unexpected "
+ "result: %s, expected %s\n", mqt->mq_desc, out,
+ mqt->mq_result);
+ exit(1);
+ } else if (mqt->mq_strcmp == B_FALSE && out != mqt->mq_result) {
+ (void) fprintf(stderr, "test %s: got unexpected "
+ "result: %p, expected %p\n", mqt->mq_desc, out,
+ mqt->mq_result);
+ exit(1);
+ }
+ }
+}
+
+int
+main(void)
+{
+ int ret, i, t;
+ mergeq_t *mqp;
+ int nthreads[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, -1 };
+
+ for (t = 0; nthreads[t] != -1; t++) {
+ printf("Beginning tests with %d threads\n", nthreads[t]);
+ if ((ret = mergeq_init(&mqp, nthreads[t])) != 0) {
+ fprintf(stderr, "failed to init mergeq: %s\n",
+ strerror(errno));
+ return (1);
+ }
+
+ for (i = 0; i < NMQ_TESTS; i++) {
+ mq_test_run(mqp, &mq_tests[i]);
+ }
+
+ mergeq_fini(mqp);
+ }
+
+ return (0);
+}
diff --git a/usr/src/test/util-tests/tests/workq/Makefile b/usr/src/test/util-tests/tests/workq/Makefile
new file mode 100644
index 0000000000..ab5455fd86
--- /dev/null
+++ b/usr/src/test/util-tests/tests/workq/Makefile
@@ -0,0 +1,64 @@
+#
+# 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 2015 Joyent, Inc.
+#
+
+include $(SRC)/Makefile.master
+
+ROOTOPTPKG = $(ROOT)/opt/util-tests
+TESTDIR = $(ROOTOPTPKG)/tests/mergeq
+
+PROG = wqt
+OBJS = wqt.o workq.o
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/cmd/Makefile.ctf
+include $(SRC)/test/Makefile.com
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+CPPFLAGS += -I$(SRC)/lib/mergeq -D_REENTRANT
+LDLIBS += -lumem
+
+all: $(PROG)
+
+install: all $(CMDS)
+
+lint: lint_SRCS
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(OBJS)
+
+%.o: %.c
+ $(COMPILE.c) -o $@ -c $<
+ $(POST_PROCESS_O)
+
+%.o: $(SRC)/lib/mergeq/%.c
+ $(COMPILE.c) -o $@ -c $<
+ $(POST_PROCESS_O)
+
+$(PROG): $(OBJS)
+ $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+ $(POST_PROCESS)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/util-tests/tests/workq/wqt.c b/usr/src/test/util-tests/tests/workq/wqt.c
new file mode 100644
index 0000000000..bda0b4a9e5
--- /dev/null
+++ b/usr/src/test/util-tests/tests/workq/wqt.c
@@ -0,0 +1,196 @@
+/*
+ * 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 2015 Joyent, Inc.
+ */
+
+/*
+ * workq testing routines
+ *
+ * What we want to guarantee is that every function is executed exactly once. To
+ * that end we have the callback function basically increment a global in the
+ * test around a mutex.
+ */
+
+#include <workq.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <thread.h>
+#include <synch.h>
+
+mutex_t wqt_lock = ERRORCHECKMUTEX;
+uintptr_t wqt_count;
+
+const char *
+_umem_debug_init()
+{
+ return ("default,verbose");
+}
+
+const char *
+_umem_logging_init(void)
+{
+ return ("fail,contents");
+}
+
+void *
+workq_alloc(size_t size)
+{
+ return (malloc(size));
+}
+
+/*ARGSUSED*/
+void
+workq_free(void *buf, size_t size)
+{
+ free(buf);
+}
+
+/*ARGSUSED*/
+int
+wqt_fatal(void *item, void *arg)
+{
+ return (-1);
+}
+
+int
+wqt_add(void *item, void *arg)
+{
+ uintptr_t a = (uintptr_t)item;
+
+ mutex_enter(&wqt_lock);
+ wqt_count += a;
+ mutex_exit(&wqt_lock);
+
+ return (0);
+}
+
+typedef struct wq_test {
+ const char *wq_desc; /* test description/name */
+ workq_proc_f *wq_proc; /* processing function */
+ int wq_rval; /* workq_work return value */
+ int wq_uerr; /* user error, if any */
+ uintptr_t wq_sum; /* expected sum */
+ void **wq_args; /* argument array */
+} wq_test_t;
+
+static void *wqt_empty_args[] = { NULL };
+static void *wqt_single_args[] = { (void *)42, NULL };
+static void *wqt_double_args[] = { (void *)42, (void *)27, NULL };
+static void *wqt_wrap_args[] = {
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, NULL
+};
+static void *wqt_grow_args[] = {
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, (void *)1, (void *)1, (void *)1, (void *)1,
+ (void *)1, (void *)1, NULL
+};
+
+static wq_test_t wq_tests[] = {
+ { "empty", wqt_add, 0, 0, NULL, wqt_empty_args },
+ { "single", wqt_add, 0, 0, 42, wqt_single_args },
+ { "double", wqt_add, 0, 0, 69, wqt_double_args },
+ { "wrap", wqt_add, 0, 0, 64, wqt_wrap_args },
+ { "grow", wqt_add, 0, 0, 92, wqt_grow_args },
+ { "fatal", wqt_fatal, WORKQ_UERROR, -1, -1, wqt_double_args }
+};
+
+#define NWQ_TESTS (sizeof (wq_tests) / sizeof (wq_test_t))
+
+static void
+wq_test_run(workq_t *wqp, wq_test_t *wqt)
+{
+ int ret, err;
+ void **itemp = wqt->wq_args;
+
+ while (*itemp != NULL) {
+ if ((ret = workq_add(wqp, *itemp)) != 0) {
+ (void) fprintf(stderr, "test %s: failed to add item: "
+ "%s\n", wqt->wq_desc, strerror(errno));
+ exit(1);
+ }
+ itemp++;
+ }
+
+ wqt_count = 0;
+ ret = workq_work(wqp, wqt->wq_proc, NULL, &err);
+ if (ret != wqt->wq_rval) {
+ (void) fprintf(stderr, "test %s: got incorrect rval. "
+ "Expected %d, got %d (%d)\n", wqt->wq_desc, wqt->wq_rval,
+ ret, errno);
+ exit(1);
+ }
+
+ if (ret == WORKQ_UERROR && err != wqt->wq_uerr) {
+ (void) fprintf(stderr, "test %s: got incorrect user error. "
+ "Expected %d, got %d\n", wqt->wq_desc, wqt->wq_uerr, err);
+ exit(1);
+ }
+
+ if (ret == 0 && wqt_count != wqt->wq_sum) {
+ (void) fprintf(stderr, "test %s: got unexpected "
+ "result: %d, expected %d\n", wqt->wq_desc, wqt_count,
+ wqt->wq_sum);
+ exit(1);
+ }
+}
+
+int
+main(void)
+{
+ int ret, i, t;
+ workq_t *wqp;
+ int nthreads[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, -1 };
+
+ for (t = 0; nthreads[t] != -1; t++) {
+ printf("Beginning tests with %d threads\n", nthreads[t]);
+ if ((ret = workq_init(&wqp, nthreads[t])) != 0) {
+ fprintf(stderr, "failed to init workq: %s\n",
+ strerror(errno));
+ return (1);
+ }
+
+ for (i = 0; i < NWQ_TESTS; i++) {
+ wq_test_run(wqp, &wq_tests[i]);
+ }
+
+ workq_fini(wqp);
+ }
+
+
+ return (0);
+}