diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index f6f55276284a..e216767170ab 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -1,1193 +1,1195 @@ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 tags=package=tests . bin cat .. chflags .. chmod .. cp .. date .. dd .. echo .. expr .. ln .. ls .. mkdir .. mv .. pax .. pkill .. pwait .. rm .. rmdir .. sh builtins .. errors .. execution .. expansion .. invocation .. parameters .. parser .. set-e .. .. sleep .. test .. timeout .. .. cddl lib .. sbin .. usr.bin ctfconvert .. ztest .. .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. env .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. kinst .. 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 .. sugar .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. i386 arrays .. funcs .. pid .. ustack .. .. amd64 arrays .. .. .. zfsd .. .. .. etc rc.d .. .. examples .. games .. gnu lib .. usr.bin diff .. .. .. include .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. csu dynamic .. dynamiclib .. static .. .. googletest gmock .. gmock_main .. gtest .. gtest_main .. .. libarchive .. libbe .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcam .. libcasper services cap_dns .. cap_grp .. cap_pwd .. cap_sysctl .. .. .. libcrypt .. libdevdctl .. libexecinfo .. libkvm .. libmp .. libnv .. libproc .. libregex data .. .. librt .. libsbuf .. libsysdecode .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-pytest-wrapper .. atf-sh .. .. rc .. rtld-elf .. tftpd .. .. sbin bectl .. dhclient .. devd .. growfs .. ifconfig .. ipfw .. md5 .. mdconfig .. newfs_msdos .. nvmecontrol .. pfctl files .. .. ping .. route .. sysctl .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. googletest .. plain .. tap .. .. .. zoneinfo .. .. sys acl .. aio .. audit .. auditpipe .. capsicum .. cddl zfs bin .. include .. tests acl cifs .. nontrivial .. trivial .. .. atime .. bootfs .. cache .. cachefile .. clean_mirror .. 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 blockfiles .. .. zpool .. zpool_offline .. zpool_replace .. zfs_rollback .. zpool_set .. zfs_send .. zfs_set .. zpool_detach .. zfs_diff .. 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 .. devices .. exec .. grow_pool .. grow_replicas .. history .. hotplug .. hotspare .. inheritance .. interop .. inuse .. iscsi .. large_files .. largest_pool .. link_count .. migration .. mmap .. mount .. mv_files .. nestedfs .. no_space .. online_offline .. pool_names .. poolversion .. quota .. redundancy .. refquota .. refreserv .. rename_dirs .. replacement .. reservation .. rootpool .. rsend .. 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 .. .. .. .. compat32 .. devrandom .. dtrace .. fifo .. file .. fs fusefs .. tarfs .. tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. multipath .. nop .. part .. raid3 .. shsec .. stripe .. + union + .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. mac bsdextended .. ipacl .. portacl .. .. mqueue .. net if_ovpn .. routing .. .. netgraph .. netinet .. netinet6 frag6 .. .. netipsec tunnel .. .. netlink .. netmap .. netpfil common .. ipfw .. pf ioctl .. .. .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. utimensat .. .. posixshm .. sys .. vfs .. vm stack .. .. vmm .. .. usr.bin apply .. asa .. awk bugs-fixed .. netbsd .. .. basename .. bintrans .. 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 .. .. .. bsdcat .. calendar .. cmp .. compress .. cpio .. col .. comm .. csplit .. cut .. dc .. diff .. diff3 .. dirname .. du .. factor .. file2c .. file .. find .. fold .. getconf .. gh-bc .. grep .. gzip .. head .. hexdump .. ident .. indent .. join .. jot .. lastcomm .. limits .. locale .. m4 .. mkimg .. mktemp .. ncal .. opensm .. patch .. pr .. printenv .. printf .. procstat .. renice .. rs .. sdiff .. sed regress.multitest.out .. .. seq .. soelim .. sort .. split .. stat .. tail .. tar .. tftp .. tr .. truncate .. tsort .. units .. unifdef .. uniq .. unzip .. vmstat .. wc .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin chown .. daemon .. etcupdate .. extattr .. fstyp .. jail .. makefs .. mixer .. newsyslog .. nmtree .. praudit .. pw .. rpcbind .. sa .. syslogd .. .. .. # vim: set expandtab ts=4 sw=4: diff --git a/tests/sys/geom/class/Makefile b/tests/sys/geom/class/Makefile index 4a21e039f185..10b01a043ddf 100644 --- a/tests/sys/geom/class/Makefile +++ b/tests/sys/geom/class/Makefile @@ -1,24 +1,25 @@ .include PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/geom/class TESTS_SUBDIRS+= concat .if ${MK_OPENSSL} != "no" TESTS_SUBDIRS+= eli .endif TESTS_SUBDIRS+= gate TESTS_SUBDIRS+= mirror TESTS_SUBDIRS+= multipath TESTS_SUBDIRS+= nop TESTS_SUBDIRS+= part TESTS_SUBDIRS+= raid3 TESTS_SUBDIRS+= shsec TESTS_SUBDIRS+= stripe +TESTS_SUBDIRS+= union TESTS_SUBDIRS+= uzip ${PACKAGE}FILES+= geom_subr.sh .include diff --git a/tests/sys/geom/class/union/Makefile b/tests/sys/geom/class/union/Makefile new file mode 100644 index 000000000000..5ab8055fd84c --- /dev/null +++ b/tests/sys/geom/class/union/Makefile @@ -0,0 +1,9 @@ +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T} + +ATF_TESTS_SH+= union_test + +${PACKAGE}FILES+= conf.sh + +.include diff --git a/tests/sys/geom/class/union/conf.sh b/tests/sys/geom/class/union/conf.sh new file mode 100644 index 000000000000..1150c7204ad3 --- /dev/null +++ b/tests/sys/geom/class/union/conf.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +class="union" +base=$(atf_get ident) + +attach_md() +{ + local test_md + + test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)" + echo $test_md >> $TEST_MDS_FILE || exit + echo $test_md +} + +gunion_test_cleanup() +{ + if mount | grep -q "/gunionmnt"; then + umount gunionmnt + fi + if mount | grep -q "/uppermnt"; then + umount uppermnt + fi + if mount | grep -q "/lowermnt"; then + umount lowermnt + fi + + if [ -e "guniondev" ]; then + gunion destroy "$(cat guniondev)" + fi + + geom_test_cleanup +} + +gunion_test_setup() +{ + geom_atf_test_setup +} + +ATF_TEST=true +. `dirname $0`/../geom_subr.sh diff --git a/tests/sys/geom/class/union/union_test.sh b/tests/sys/geom/class/union/union_test.sh new file mode 100644 index 000000000000..1872847bdf58 --- /dev/null +++ b/tests/sys/geom/class/union/union_test.sh @@ -0,0 +1,338 @@ +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2023 The FreeBSD Foundation +# +# This software was developed1 by Yan-Hao Wang +# under sponsorship from the FreeBSD Foundation. +# +# 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. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE. +# + +. $(atf_get_srcdir)/conf.sh + +atf_test_case create cleanup +create_head() +{ + atf_set "descr" "Test gunion create and destroy" + atf_set "require.user" "root" +} +create_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + + atf_check gunion create "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + atf_check -o inline:"/dev/${guniondev}\n" ls "/dev/${guniondev}" + atf_check -o ignore fsck -p -f "/dev/${guniondev}" + + atf_check gunion destroy "$guniondev" + atf_check -s not-exit:0 -o ignore -e ignore ls "/dev/${guniondev}" +} +create_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case basic cleanup +basic_head() +{ + atf_set "descr" "Check gunion doesn't affect lowerdev status and lowerdev can't be mounted when being in a gunion" + atf_set "require.user" "root" +} +basic_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + mkdir lowermnt + mkdir gunionmnt + + mount "/dev/${lowerdev}" lowermnt + echo "lower file" > lower_file + cp lower_file lowermnt/lower_file + sync + umount lowermnt + + gunion create "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + atf_check -s not-exit:0 -o ignore -e ignore mount "/dev/${lowerdev}" lowermnt + + mount "/dev/${guniondev}" gunionmnt + echo "update lower file" >> gunionmnt/lower_file + echo "gunion file" > gunion_file + cp gunion_file gunionmnt/gunion_file + sync + umount gunionmnt + + gunion destroy "$guniondev" + mount "/dev/${lowerdev}" lowermnt + checksum lowermnt/lower_file lower_file + atf_check -s not-exit:0 -o ignore -e ignore ls lowermnt/gunion_file +} +basic_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case commit cleanup +commit_head() +{ + atf_set "descr" "Test basic gunion commit without option" + atf_set "require.user" "root" +} +commit_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + mkdir lowermnt + mkdir gunionmnt + + mount "/dev/${lowerdev}" lowermnt + echo "lower file" > lower_file + cp lower_file lowermnt/lower_file + sync + umount lowermnt + + gunion create "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + mount "/dev/${guniondev}" gunionmnt + checksum gunionmnt/lower_file lower_file + + echo "update lower file" >> lower_file + cp -f lower_file gunionmnt/lower_file + echo "gunion file" > gunion_file + cp gunion_file gunionmnt/gunion_file + sync + umount gunionmnt + atf_check gunion commit "$guniondev" + gunion destroy "$guniondev" + + atf_check -o ignore fsck -p -f "/dev/${lowerdev}" + mount "/dev/${lowerdev}" lowermnt + checksum lowermnt/lower_file lower_file + checksum lowermnt/gunion_file gunion_file +} +commit_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case offset cleanup +offset_head() +{ + atf_set "descr" "Test gunion create with -o offset option" + atf_set "require.user" "root" +} +offset_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + gpart create -s GPT "/dev/${lowerdev}" + gpart add -t freebsd-ufs "$lowerdev" + newfs "/dev/${lowerdev}p1" + gpt_entry_1=$(gpart show "/dev/${lowerdev}") + mkdir gunionmnt + + secsize="$(diskinfo "/dev/${lowerdev}" | awk '{print $2}')" + p1_start_sector="$(gpart show -p "/dev/${lowerdev}" | grep ${lowerdev}p1 | awk '{print $1}')" + offset_size="$((secsize * p1_start_sector))" + + gunion create -o "$offset_size" "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + + atf_check -o ignore fsck -p -f "/dev/${guniondev}" + atf_check mount "/dev/${guniondev}" gunionmnt + umount gunionmnt + gunion destroy "$guniondev" + + gpt_entry_2=$(gpart show "/dev/${lowerdev}") + atf_check_equal "$gpt_entry_1" "$gpt_entry_2" +} +offset_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case size cleanup +size_head() +{ + atf_set "descr" "Test gunion create with -s size option" + atf_set "require.user" "root" +} +size_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 2m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + + gunion create -s 2m "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + echo "$guniondev" > guniondev + + size="$(diskinfo "/dev/$guniondev" | awk '{print $3}')" + atf_check_equal "2097152" "$size" # 2 MB = 2097152 bytes +} +size_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case secsize cleanup +secsize_head() +{ + atf_set "descr" "Test gunion create with -S secsize option" + atf_set "require.user" "root" +} +secsize_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -S 512 -U "/dev/${lowerdev}" + lower_secsize="$(diskinfo "/dev/${lowerdev}" | awk '{print $2}')" + atf_check_equal "512" "$lower_secsize" + + gunion create -S 1024 "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + echo "$guniondev" > guniondev + + secsize="$(diskinfo "/dev/${guniondev}" | awk '{print $2}')" + atf_check_equal "1024" "$secsize" +} +secsize_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case gunionname cleanup +gunionname_head() +{ + atf_set "descr" "Test gunion create with -Z gunionname option" + atf_set "require.user" "root" +} +gunionname_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + + gunion create -Z gunion1 "$upperdev" "$lowerdev" + echo "gunion1.union" > guniondev + atf_check -o inline:"/dev/gunion1.union\n" ls /dev/gunion1.union +} +gunionname_cleanup() +{ + gunion_test_cleanup +} + +atf_test_case revert cleanup +revert_head() +{ + atf_set "descr" "Test gunion revert" + atf_set "require.user" "root" +} +revert_body() +{ + gunion_test_setup + + upperdev="$(attach_md -s 1m)" + lowerdev="$(attach_md -s 1m)" + newfs -U "/dev/${lowerdev}" + mkdir lowermnt + mkdir gunionmnt + + mount "/dev/${lowerdev}" lowermnt + echo "lower file" > lower_file + cp lower_file lowermnt/lower_file + sync + umount lowermnt + + atf_check gunion create "$upperdev" "$lowerdev" + guniondev="${upperdev}-${lowerdev}.union" + mount "/dev/${guniondev}" gunionmnt + + echo "update lower file" >> gunionmnt/lower_file + echo "gunion file" > gunion_file + cp gunion_file gunionmnt/gunion_file + sync + umount gunionmnt + atf_check gunion revert "$guniondev" + + mount "/dev/${guniondev}" gunionmnt + checksum gunionmnt/lower_file lower_file + atf_check -s not-exit:0 -o ignore -e ignore ls gunionmnt/gunion_file + + umount gunionmnt + gunion destroy "$guniondev" +} +revert_cleanup() +{ + gunion_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case create + atf_add_test_case basic + atf_add_test_case commit + atf_add_test_case offset + atf_add_test_case size + atf_add_test_case secsize + atf_add_test_case gunionname + atf_add_test_case revert +} + +checksum() +{ + src=$1 + work=$2 + + if [ ! -e "$src" ]; then + atf_fail "file not exist" + fi + if [ ! -e "$work" ]; then + atf_fail "file not exist" + fi + + src_checksum=$(md5 -q "$src") + work_checksum=$(md5 -q "$work") + + if [ "$work_checksum" != "$src_checksum" ]; then + atf_fail "md5 checksum didn't match with ${src} and ${work}" + fi +}