Index: projects/zfsd/head/etc/mtree/BSD.tests.dist =================================================================== --- projects/zfsd/head/etc/mtree/BSD.tests.dist (revision 297927) +++ projects/zfsd/head/etc/mtree/BSD.tests.dist (revision 297928) @@ -1,900 +1,902 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chown .. date .. dd .. expr .. ls .. mv .. pax .. pkill .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin zfsd .. .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. inet .. locale .. net getaddrinfo data .. .. .. regex data .. .. rpc .. ssp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcrypt .. + libdevdctl + .. libmp .. libnv .. libpam .. libproc .. librt .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. .. .. .. sys acl .. aio .. cddl zfs bin .. include .. tests acl cifs .. nontrivial .. trivial .. .. atime .. bootfs .. cache .. cachefile .. clean_mirror assertion_001 .. assertion_002 .. assertion_003 .. assertion_004 .. .. cli_root zfs_upgrade .. zfs_promote .. zfs_clone .. zfs_property .. zfs_destroy .. zpool_create .. zpool_history .. zpool_expand .. zpool_remove .. zfs_mount .. zfs_unshare .. zdb .. zpool_online .. zpool_get .. zpool_export .. zfs_copies .. zfs_get .. zfs .. zpool_clear .. zpool_import .. zpool .. zpool_offline .. zpool_replace .. zfs_rollback .. zpool_set .. zfs_send .. zfs_set .. zpool_detach .. zpool_scrub .. zfs_inherit .. zfs_snapshot .. zfs_share .. zpool_destroy .. zpool_status .. zfs_unmount .. zfs_receive .. zfs_create .. zpool_upgrade blockfiles .. .. zpool_add .. zfs_rename .. zpool_attach .. zfs_reservation .. .. cli_user misc .. zfs_list .. zpool_iostat .. zpool_list .. .. compression .. ctime .. delegate zfs_allow .. zfs_unallow .. .. devices .. exec .. grow_pool .. grow_replicas .. history .. hotplug .. hotspare .. inheritance .. interop .. inuse .. iscsi .. large_files .. largest_pool .. link_count .. mdb .. migration .. mmap mmap_read .. mmap_write .. .. mount .. mv_files .. nestedfs .. no_space .. online_offline .. pool_names .. poolversion .. privilege .. quota .. redundancy .. refquota .. refreserv .. remote cross_endian .. rebooting .. sharing .. .. rename_dirs .. replacement .. reservation .. rootpool .. rsend .. sas_phy_thrash .. scrub_mirror .. slog .. snapshot .. snapused .. sparse .. threadsappend .. truncate .. txg_integrity .. userquota .. utils_test .. write_dirs .. xattr .. zfsd .. zil .. zinject .. zones .. zvol zvol_ENOSPC .. zvol_cli .. zvol_misc .. zvol_swap .. .. zvol_thrash .. .. .. .. dtrace .. fifo .. file .. geom geom_part .. .. kern acct .. execve .. pipe .. .. kqueue .. mqueue .. net .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. calendar .. cmp .. cpio .. col .. comm .. cut .. dirname .. file2c .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. printf .. sed regress.multitest.out .. .. soelim .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. xargs .. xo .. yacc yacc .. .. .. usr.sbin etcupdate .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: projects/zfsd/head/lib/libdevdctl/tests/Makefile =================================================================== --- projects/zfsd/head/lib/libdevdctl/tests/Makefile (nonexistent) +++ projects/zfsd/head/lib/libdevdctl/tests/Makefile (revision 297928) @@ -0,0 +1,21 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/lib/libdevdctl + +.PATH: ${.CURDIR}/.. + +PLAIN_TESTS_CXX= libdevdctl_unittest + +SRCS.libdevdctl_unittest+= event_factory.cc \ + libdevdctl_unittest.cc \ + event.cc exception.cc \ + guid.cc +CFLAGS.libdevdctl_unittest+= -I ${LOCALBASE}/include -D_THREAD_SAFE -pthread +DPADD.libdevdctl_unittest+= ${LIBDEVDCTL} +LDADD.libdevdctl_unittest+= -L ${LOCALBASE}/lib -D_THREAD_SAFE -pthread -lgtest -lgtest_main + +# Googletest options +LOCALBASE?= /usr/local + +WARNS?= 3 +.include Property changes on: projects/zfsd/head/lib/libdevdctl/tests/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: projects/zfsd/head/lib/libdevdctl/tests/libdevdctl_unittest.cc =================================================================== --- projects/zfsd/head/lib/libdevdctl/tests/libdevdctl_unittest.cc (nonexistent) +++ projects/zfsd/head/lib/libdevdctl/tests/libdevdctl_unittest.cc (revision 297928) @@ -0,0 +1,113 @@ +/*- + * Copyright (c) 2016 Spectra Logic Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * Authors: Alan Somers (Spectra Logic Corporation) + */ + +#include + +#include +#include +#include + +#include +#include +#include + +using namespace DevdCtl; +using namespace std; +using namespace testing; + +#define NUM_ELEMENTS(x) (sizeof(x) / sizeof(*x)) + +class IsDiskDevTest : public TestWithParam >{ +protected: + virtual void SetUp() + { + m_factory = new EventFactory(); + } + + virtual void TearDown() + { + if (m_ev) delete m_ev; + if (m_factory) delete m_factory; + } + + EventFactory *m_factory; + Event *m_ev; + static EventFactory::Record s_registry[]; +}; + +DevdCtl::EventFactory::Record IsDiskDevTest::s_registry[] = { + { Event::NOTIFY, "DEVFS", &DevfsEvent::Builder } +}; + +TEST_P(IsDiskDevTest, TestIsDiskDev) { + pair param = GetParam(); + DevfsEvent *devfs_ev; + + m_factory->UpdateRegistry(s_registry, NUM_ELEMENTS(s_registry)); + string evString(param.second); + m_ev = Event::CreateEvent(*m_factory, evString); + devfs_ev = dynamic_cast(m_ev); + ASSERT_NE(nullptr, devfs_ev); + EXPECT_EQ(param.first, devfs_ev->IsDiskDev()); +} + +INSTANTIATE_TEST_CASE_P(IsDiskDevTestInstantiation, IsDiskDevTest, Values( + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=da6\n"), + pair(false, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=cuau0\n"), + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=ada6\n"), + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=da6p1\n"), + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=ada6p1\n"), + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=da6s0p1\n"), + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=ada6s0p1\n"), + /* + * Test physical path nodes. These are currently all set to false since + * physical path nodes are implemented with symlinks, and most CAM and + * ZFS operations can't use symlinked device nodes + */ + /* A SpectraBSD-style physical path node*/ + pair(false, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=enc@50030480019f53fd/elmtype@array_device/slot@18/da\n"), + pair(false, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=enc@50030480019f53fd/elmtype@array_device/slot@18/pass\n"), + /* A FreeBSD-style physical path node */ + pair(true, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=enc@n50030480019f53fd/type@0/slot@18/elmdesc@ArrayDevice18/da6\n"), + pair(false, + "!system=DEVFS subsystem=CDEV type=CREATE cdev=enc@n50030480019f53fd/type@0/slot@18/elmdesc@ArrayDevice18/pass6\n")); +); Property changes on: projects/zfsd/head/lib/libdevdctl/tests/libdevdctl_unittest.cc ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property