1240afd8cSMark Johnston#- 24d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 3240afd8cSMark Johnston# 49f9d18d6SMark Johnston# Copyright (c) 2022-2023 The FreeBSD Foundation 5240afd8cSMark Johnston# 6240afd8cSMark Johnston# This software was developed by Mark Johnston under sponsorship from 7240afd8cSMark Johnston# the FreeBSD Foundation. 8240afd8cSMark Johnston# 9240afd8cSMark Johnston# Redistribution and use in source and binary forms, with or without 10240afd8cSMark Johnston# modification, are permitted provided that the following conditions are 11240afd8cSMark Johnston# met: 12240afd8cSMark Johnston# 1. Redistributions of source code must retain the above copyright 13240afd8cSMark Johnston# notice, this list of conditions and the following disclaimer. 14240afd8cSMark Johnston# 2. Redistributions in binary form must reproduce the above copyright 15240afd8cSMark Johnston# notice, this list of conditions and the following disclaimer in 16240afd8cSMark Johnston# the documentation and/or other materials provided with the distribution. 17240afd8cSMark Johnston# 18240afd8cSMark Johnston# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19240afd8cSMark Johnston# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20240afd8cSMark Johnston# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21240afd8cSMark Johnston# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22240afd8cSMark Johnston# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23240afd8cSMark Johnston# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24240afd8cSMark Johnston# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25240afd8cSMark Johnston# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26240afd8cSMark Johnston# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27240afd8cSMark Johnston# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28240afd8cSMark Johnston# SUCH DAMAGE. 29240afd8cSMark Johnston# 30240afd8cSMark Johnston 31*4e15366cSMark JohnstonMAKEFS="makefs -t zfs -o verify-txgs=true" 32240afd8cSMark JohnstonZFS_POOL_NAME="makefstest$$" 33240afd8cSMark JohnstonTEST_ZFS_POOL_NAME="$TMPDIR/poolname" 34240afd8cSMark Johnston 35240afd8cSMark Johnston. "$(dirname "$0")/makefs_tests_common.sh" 36240afd8cSMark Johnston 37240afd8cSMark Johnstoncommon_cleanup() 38240afd8cSMark Johnston{ 39240afd8cSMark Johnston local pool md 40240afd8cSMark Johnston 41240afd8cSMark Johnston # Try to force a TXG, this can help catch bugs by triggering a panic. 42240afd8cSMark Johnston sync 43240afd8cSMark Johnston 44240afd8cSMark Johnston pool=$(cat $TEST_ZFS_POOL_NAME) 45240afd8cSMark Johnston if zpool list "$pool" >/dev/null; then 46240afd8cSMark Johnston zpool destroy "$pool" 47240afd8cSMark Johnston fi 48240afd8cSMark Johnston 49240afd8cSMark Johnston md=$(cat $TEST_MD_DEVICE_FILE) 50240afd8cSMark Johnston if [ -c /dev/"$md" ]; then 51240afd8cSMark Johnston mdconfig -d -u "$md" 52240afd8cSMark Johnston fi 53240afd8cSMark Johnston} 54240afd8cSMark Johnston 55240afd8cSMark Johnstonimport_image() 56240afd8cSMark Johnston{ 57240afd8cSMark Johnston atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \ 58240afd8cSMark Johnston mdconfig -a -f $TEST_IMAGE 5987534f95SMark Johnston atf_check -o ignore -e empty -s exit:0 \ 6087534f95SMark Johnston zdb -e -p /dev/$(cat $TEST_MD_DEVICE_FILE) -mmm -ddddd $ZFS_POOL_NAME 61240afd8cSMark Johnston atf_check zpool import -R $TEST_MOUNT_DIR $ZFS_POOL_NAME 62240afd8cSMark Johnston echo "$ZFS_POOL_NAME" > $TEST_ZFS_POOL_NAME 63240afd8cSMark Johnston} 64240afd8cSMark Johnston 65240afd8cSMark Johnston# 66240afd8cSMark Johnston# Test autoexpansion of the vdev. 67240afd8cSMark Johnston# 68240afd8cSMark Johnston# The pool is initially 10GB, so we get 10GB minus one metaslab's worth of 69240afd8cSMark Johnston# usable space for data. Then the pool is expanded to 50GB, and the amount of 70240afd8cSMark Johnston# usable space is 50GB minus one metaslab. 71240afd8cSMark Johnston# 72240afd8cSMark Johnstonatf_test_case autoexpand cleanup 73240afd8cSMark Johnstonautoexpand_body() 74240afd8cSMark Johnston{ 75240afd8cSMark Johnston local mssize poolsize poolsize1 newpoolsize 76240afd8cSMark Johnston 77240afd8cSMark Johnston create_test_inputs 78240afd8cSMark Johnston 79240afd8cSMark Johnston mssize=$((128 * 1024 * 1024)) 80240afd8cSMark Johnston poolsize=$((10 * 1024 * 1024 * 1024)) 81240afd8cSMark Johnston atf_check $MAKEFS -s $poolsize -o mssize=$mssize -o rootpath=/ \ 82240afd8cSMark Johnston -o poolname=$ZFS_POOL_NAME \ 83240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 84240afd8cSMark Johnston 85240afd8cSMark Johnston newpoolsize=$((50 * 1024 * 1024 * 1024)) 86240afd8cSMark Johnston truncate -s $newpoolsize $TEST_IMAGE 87240afd8cSMark Johnston 88240afd8cSMark Johnston import_image 89240afd8cSMark Johnston 90240afd8cSMark Johnston check_image_contents 91240afd8cSMark Johnston 92240afd8cSMark Johnston poolsize1=$(zpool list -Hp -o size $ZFS_POOL_NAME) 93240afd8cSMark Johnston atf_check [ $((poolsize1 + $mssize)) -eq $poolsize ] 94240afd8cSMark Johnston 95240afd8cSMark Johnston atf_check zpool online -e $ZFS_POOL_NAME /dev/$(cat $TEST_MD_DEVICE_FILE) 96240afd8cSMark Johnston 97240afd8cSMark Johnston check_image_contents 98240afd8cSMark Johnston 99240afd8cSMark Johnston poolsize1=$(zpool list -Hp -o size $ZFS_POOL_NAME) 100240afd8cSMark Johnston atf_check [ $((poolsize1 + $mssize)) -eq $newpoolsize ] 101240afd8cSMark Johnston} 102240afd8cSMark Johnstonautoexpand_cleanup() 103240afd8cSMark Johnston{ 104240afd8cSMark Johnston common_cleanup 105240afd8cSMark Johnston} 106240afd8cSMark Johnston 107240afd8cSMark Johnston# 108240afd8cSMark Johnston# Test with some default layout defined by the common code. 109240afd8cSMark Johnston# 110240afd8cSMark Johnstonatf_test_case basic cleanup 111240afd8cSMark Johnstonbasic_body() 112240afd8cSMark Johnston{ 113240afd8cSMark Johnston create_test_inputs 114240afd8cSMark Johnston 115240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 116240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 117240afd8cSMark Johnston 118240afd8cSMark Johnston import_image 119240afd8cSMark Johnston 120240afd8cSMark Johnston check_image_contents 121240afd8cSMark Johnston} 122240afd8cSMark Johnstonbasic_cleanup() 123240afd8cSMark Johnston{ 124240afd8cSMark Johnston common_cleanup 125240afd8cSMark Johnston} 126240afd8cSMark Johnston 127240afd8cSMark Johnstonatf_test_case dataset_removal cleanup 128240afd8cSMark Johnstondataset_removal_body() 129240afd8cSMark Johnston{ 130240afd8cSMark Johnston create_test_dirs 131240afd8cSMark Johnston 132240afd8cSMark Johnston cd $TEST_INPUTS_DIR 133240afd8cSMark Johnston mkdir dir 134240afd8cSMark Johnston cd - 135240afd8cSMark Johnston 136240afd8cSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 137240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir \ 138240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 139240afd8cSMark Johnston 140240afd8cSMark Johnston import_image 141240afd8cSMark Johnston 142240afd8cSMark Johnston check_image_contents 143240afd8cSMark Johnston 144240afd8cSMark Johnston atf_check zfs destroy ${ZFS_POOL_NAME}/dir 145240afd8cSMark Johnston} 146240afd8cSMark Johnstondataset_removal_cleanup() 147240afd8cSMark Johnston{ 148240afd8cSMark Johnston common_cleanup 149240afd8cSMark Johnston} 150240afd8cSMark Johnston 151240afd8cSMark Johnston# 152240afd8cSMark Johnston# Make sure that we can create and remove an empty directory. 153240afd8cSMark Johnston# 154240afd8cSMark Johnstonatf_test_case empty_dir cleanup 155240afd8cSMark Johnstonempty_dir_body() 156240afd8cSMark Johnston{ 157240afd8cSMark Johnston create_test_dirs 158240afd8cSMark Johnston 159240afd8cSMark Johnston cd $TEST_INPUTS_DIR 160240afd8cSMark Johnston mkdir dir 161240afd8cSMark Johnston cd - 162240afd8cSMark Johnston 163240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 164240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 165240afd8cSMark Johnston 166240afd8cSMark Johnston import_image 167240afd8cSMark Johnston 168240afd8cSMark Johnston check_image_contents 169240afd8cSMark Johnston 170240afd8cSMark Johnston atf_check rmdir ${TEST_MOUNT_DIR}/dir 171240afd8cSMark Johnston} 172240afd8cSMark Johnstonempty_dir_cleanup() 173240afd8cSMark Johnston{ 174240afd8cSMark Johnston common_cleanup 175240afd8cSMark Johnston} 176240afd8cSMark Johnston 177240afd8cSMark Johnstonatf_test_case empty_fs cleanup 178240afd8cSMark Johnstonempty_fs_body() 179240afd8cSMark Johnston{ 180240afd8cSMark Johnston create_test_dirs 181240afd8cSMark Johnston 182240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 183240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 184240afd8cSMark Johnston 185240afd8cSMark Johnston import_image 186240afd8cSMark Johnston 187240afd8cSMark Johnston check_image_contents 188240afd8cSMark Johnston} 189240afd8cSMark Johnstonempty_fs_cleanup() 190240afd8cSMark Johnston{ 191240afd8cSMark Johnston common_cleanup 192240afd8cSMark Johnston} 193240afd8cSMark Johnston 194b6da7f2fSMark Johnstonatf_test_case file_extend cleanup 195b6da7f2fSMark Johnstonfile_extend_body() 196b6da7f2fSMark Johnston{ 197b6da7f2fSMark Johnston local i start 198b6da7f2fSMark Johnston 199b6da7f2fSMark Johnston create_test_dirs 200b6da7f2fSMark Johnston 201b6da7f2fSMark Johnston # Create a file slightly longer than the maximum block size. 202b6da7f2fSMark Johnston start=132 203b6da7f2fSMark Johnston dd if=/dev/random of=${TEST_INPUTS_DIR}/foo bs=1k count=$start 204b6da7f2fSMark Johnston md5 -q ${TEST_INPUTS_DIR}/foo > foo.md5 205b6da7f2fSMark Johnston 206b6da7f2fSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 207b6da7f2fSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 208b6da7f2fSMark Johnston 209b6da7f2fSMark Johnston import_image 210b6da7f2fSMark Johnston 211b6da7f2fSMark Johnston check_image_contents 212b6da7f2fSMark Johnston 213b6da7f2fSMark Johnston i=0 214b6da7f2fSMark Johnston while [ $i -lt 1000 ]; do 215b6da7f2fSMark Johnston dd if=/dev/random of=${TEST_MOUNT_DIR}/foo bs=1k count=1 \ 216b6da7f2fSMark Johnston seek=$(($i + $start)) conv=notrunc 217b6da7f2fSMark Johnston # Make sure that the first $start blocks are unmodified. 218b6da7f2fSMark Johnston dd if=${TEST_MOUNT_DIR}/foo bs=1k count=$start of=foo.copy 219b6da7f2fSMark Johnston atf_check -o file:foo.md5 md5 -q foo.copy 220b6da7f2fSMark Johnston i=$(($i + 1)) 221b6da7f2fSMark Johnston done 222b6da7f2fSMark Johnston} 223b6da7f2fSMark Johnstonfile_extend_cleanup() 224b6da7f2fSMark Johnston{ 225b6da7f2fSMark Johnston common_cleanup 226b6da7f2fSMark Johnston} 227b6da7f2fSMark Johnston 228240afd8cSMark Johnstonatf_test_case file_sizes cleanup 229240afd8cSMark Johnstonfile_sizes_body() 230240afd8cSMark Johnston{ 231240afd8cSMark Johnston local i 232240afd8cSMark Johnston 233240afd8cSMark Johnston create_test_dirs 234240afd8cSMark Johnston cd $TEST_INPUTS_DIR 235240afd8cSMark Johnston 236240afd8cSMark Johnston i=1 237240afd8cSMark Johnston while [ $i -lt $((1 << 20)) ]; do 238240afd8cSMark Johnston truncate -s $i ${i}.1 239240afd8cSMark Johnston truncate -s $(($i - 1)) ${i}.2 240240afd8cSMark Johnston truncate -s $(($i + 1)) ${i}.3 241240afd8cSMark Johnston i=$(($i << 1)) 242240afd8cSMark Johnston done 243240afd8cSMark Johnston 244240afd8cSMark Johnston cd - 245240afd8cSMark Johnston 246240afd8cSMark Johnston # XXXMJ this creates sparse files, make sure makefs doesn't 247240afd8cSMark Johnston # preserve the sparseness. 248240afd8cSMark Johnston # XXXMJ need to test with larger files (at least 128MB for L2 indirs) 249240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 250240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 251240afd8cSMark Johnston 252240afd8cSMark Johnston import_image 253240afd8cSMark Johnston 254240afd8cSMark Johnston check_image_contents 255240afd8cSMark Johnston} 256240afd8cSMark Johnstonfile_sizes_cleanup() 257240afd8cSMark Johnston{ 258240afd8cSMark Johnston common_cleanup 259240afd8cSMark Johnston} 260240afd8cSMark Johnston 261240afd8cSMark Johnstonatf_test_case hard_links cleanup 262240afd8cSMark Johnstonhard_links_body() 263240afd8cSMark Johnston{ 264240afd8cSMark Johnston local f 265240afd8cSMark Johnston 266240afd8cSMark Johnston create_test_dirs 267240afd8cSMark Johnston cd $TEST_INPUTS_DIR 268240afd8cSMark Johnston 269240afd8cSMark Johnston mkdir dir 270240afd8cSMark Johnston echo "hello" > 1 271240afd8cSMark Johnston ln 1 2 272240afd8cSMark Johnston ln 1 dir/1 273240afd8cSMark Johnston 274240afd8cSMark Johnston echo "goodbye" > dir/a 275240afd8cSMark Johnston ln dir/a dir/b 276240afd8cSMark Johnston ln dir/a a 277240afd8cSMark Johnston 278240afd8cSMark Johnston cd - 279240afd8cSMark Johnston 280240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 281240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 282240afd8cSMark Johnston 283240afd8cSMark Johnston import_image 284240afd8cSMark Johnston 285240afd8cSMark Johnston check_image_contents 286240afd8cSMark Johnston 287240afd8cSMark Johnston stat -f '%i' ${TEST_MOUNT_DIR}/1 > ./ino 288240afd8cSMark Johnston stat -f '%l' ${TEST_MOUNT_DIR}/1 > ./nlink 289240afd8cSMark Johnston for f in 1 2 dir/1; do 290240afd8cSMark Johnston atf_check -o file:./nlink -e empty -s exit:0 \ 291240afd8cSMark Johnston stat -f '%l' ${TEST_MOUNT_DIR}/${f} 292240afd8cSMark Johnston atf_check -o file:./ino -e empty -s exit:0 \ 293240afd8cSMark Johnston stat -f '%i' ${TEST_MOUNT_DIR}/${f} 294240afd8cSMark Johnston atf_check cmp -s ${TEST_INPUTS_DIR}/1 ${TEST_MOUNT_DIR}/${f} 295240afd8cSMark Johnston done 296240afd8cSMark Johnston 297240afd8cSMark Johnston stat -f '%i' ${TEST_MOUNT_DIR}/dir/a > ./ino 298240afd8cSMark Johnston stat -f '%l' ${TEST_MOUNT_DIR}/dir/a > ./nlink 299240afd8cSMark Johnston for f in dir/a dir/b a; do 300240afd8cSMark Johnston atf_check -o file:./nlink -e empty -s exit:0 \ 301240afd8cSMark Johnston stat -f '%l' ${TEST_MOUNT_DIR}/${f} 302240afd8cSMark Johnston atf_check -o file:./ino -e empty -s exit:0 \ 303240afd8cSMark Johnston stat -f '%i' ${TEST_MOUNT_DIR}/${f} 304240afd8cSMark Johnston atf_check cmp -s ${TEST_INPUTS_DIR}/dir/a ${TEST_MOUNT_DIR}/${f} 305240afd8cSMark Johnston done 306240afd8cSMark Johnston} 307240afd8cSMark Johnstonhard_links_cleanup() 308240afd8cSMark Johnston{ 309240afd8cSMark Johnston common_cleanup 310240afd8cSMark Johnston} 311240afd8cSMark Johnston 312240afd8cSMark Johnston# Allocate enough dnodes from an object set that the meta dnode needs to use 313240afd8cSMark Johnston# indirect blocks. 314240afd8cSMark Johnstonatf_test_case indirect_dnode_array cleanup 315240afd8cSMark Johnstonindirect_dnode_array_body() 316240afd8cSMark Johnston{ 317240afd8cSMark Johnston local count i 318240afd8cSMark Johnston 319240afd8cSMark Johnston # How many dnodes do we need to allocate? Well, the data block size 320240afd8cSMark Johnston # for meta dnodes is always 16KB, so with a dnode size of 512B we get 321240afd8cSMark Johnston # 32 dnodes per direct block. The maximum indirect block size is 128KB 322240afd8cSMark Johnston # and that can fit 1024 block pointers, so we need at least 32 * 1024 323240afd8cSMark Johnston # files to force the use of two levels of indirection. 324240afd8cSMark Johnston # 325240afd8cSMark Johnston # Unfortunately that number of files makes the test run quite slowly, 326240afd8cSMark Johnston # so we settle for a single indirect block for now... 327240afd8cSMark Johnston count=$(jot -r 1 32 1024) 328240afd8cSMark Johnston 329240afd8cSMark Johnston create_test_dirs 330240afd8cSMark Johnston cd $TEST_INPUTS_DIR 331240afd8cSMark Johnston for i in $(seq 1 $count); do 332240afd8cSMark Johnston touch $i 333240afd8cSMark Johnston done 334240afd8cSMark Johnston cd - 335240afd8cSMark Johnston 336240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 337240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 338240afd8cSMark Johnston 339240afd8cSMark Johnston import_image 340240afd8cSMark Johnston 341240afd8cSMark Johnston check_image_contents 342240afd8cSMark Johnston} 343240afd8cSMark Johnstonindirect_dnode_array_cleanup() 344240afd8cSMark Johnston{ 345240afd8cSMark Johnston common_cleanup 346240afd8cSMark Johnston} 347240afd8cSMark Johnston 348240afd8cSMark Johnston# 349240afd8cSMark Johnston# Create some files with long names, so as to test fat ZAP handling. 350240afd8cSMark Johnston# 351240afd8cSMark Johnstonatf_test_case long_file_name cleanup 352240afd8cSMark Johnstonlong_file_name_body() 353240afd8cSMark Johnston{ 354240afd8cSMark Johnston local dir i 355240afd8cSMark Johnston 356240afd8cSMark Johnston create_test_dirs 357240afd8cSMark Johnston cd $TEST_INPUTS_DIR 358240afd8cSMark Johnston 359240afd8cSMark Johnston # micro ZAP keys can be at most 50 bytes. 360240afd8cSMark Johnston for i in $(seq 1 60); do 361240afd8cSMark Johnston touch $(jot -s '' $i 1 1) 362240afd8cSMark Johnston done 363240afd8cSMark Johnston dir=$(jot -s '' 61 1 1) 364240afd8cSMark Johnston mkdir $dir 365240afd8cSMark Johnston for i in $(seq 1 60); do 366240afd8cSMark Johnston touch ${dir}/$(jot -s '' $i 1 1) 367240afd8cSMark Johnston done 368240afd8cSMark Johnston 369240afd8cSMark Johnston cd - 370240afd8cSMark Johnston 371240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 372240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 373240afd8cSMark Johnston 374240afd8cSMark Johnston import_image 375240afd8cSMark Johnston 376240afd8cSMark Johnston check_image_contents 377240afd8cSMark Johnston 378240afd8cSMark Johnston # Add a directory entry in the hope that OpenZFS might catch a bug 379240afd8cSMark Johnston # in makefs' fat ZAP encoding. 380240afd8cSMark Johnston touch ${TEST_MOUNT_DIR}/foo 381240afd8cSMark Johnston} 382240afd8cSMark Johnstonlong_file_name_cleanup() 383240afd8cSMark Johnston{ 384240afd8cSMark Johnston common_cleanup 385240afd8cSMark Johnston} 386240afd8cSMark Johnston 387240afd8cSMark Johnston# 388240afd8cSMark Johnston# Exercise handling of multiple datasets. 389240afd8cSMark Johnston# 390240afd8cSMark Johnstonatf_test_case multi_dataset_1 cleanup 391240afd8cSMark Johnstonmulti_dataset_1_body() 392240afd8cSMark Johnston{ 393240afd8cSMark Johnston create_test_dirs 394240afd8cSMark Johnston cd $TEST_INPUTS_DIR 395240afd8cSMark Johnston 396240afd8cSMark Johnston mkdir dir1 397240afd8cSMark Johnston echo a > dir1/a 398240afd8cSMark Johnston mkdir dir2 399240afd8cSMark Johnston echo b > dir2/b 400240afd8cSMark Johnston 401240afd8cSMark Johnston cd - 402240afd8cSMark Johnston 403240afd8cSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 404240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir1 -o fs=${ZFS_POOL_NAME}/dir2 \ 405240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 406240afd8cSMark Johnston 407240afd8cSMark Johnston import_image 408240afd8cSMark Johnston 409240afd8cSMark Johnston check_image_contents 410240afd8cSMark Johnston 411240afd8cSMark Johnston # Make sure that we have three datasets with the expected mount points. 412240afd8cSMark Johnston atf_check -o inline:${ZFS_POOL_NAME}\\n -e empty -s exit:0 \ 413240afd8cSMark Johnston zfs list -H -o name ${ZFS_POOL_NAME} 414240afd8cSMark Johnston atf_check -o inline:${TEST_MOUNT_DIR}\\n -e empty -s exit:0 \ 415240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME} 416240afd8cSMark Johnston 417240afd8cSMark Johnston atf_check -o inline:${ZFS_POOL_NAME}/dir1\\n -e empty -s exit:0 \ 418240afd8cSMark Johnston zfs list -H -o name ${ZFS_POOL_NAME}/dir1 419240afd8cSMark Johnston atf_check -o inline:${TEST_MOUNT_DIR}/dir1\\n -e empty -s exit:0 \ 420240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1 421240afd8cSMark Johnston 422240afd8cSMark Johnston atf_check -o inline:${ZFS_POOL_NAME}/dir2\\n -e empty -s exit:0 \ 423240afd8cSMark Johnston zfs list -H -o name ${ZFS_POOL_NAME}/dir2 424240afd8cSMark Johnston atf_check -o inline:${TEST_MOUNT_DIR}/dir2\\n -e empty -s exit:0 \ 425240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir2 426240afd8cSMark Johnston} 427240afd8cSMark Johnstonmulti_dataset_1_cleanup() 428240afd8cSMark Johnston{ 429240afd8cSMark Johnston common_cleanup 430240afd8cSMark Johnston} 431240afd8cSMark Johnston 432240afd8cSMark Johnston# 433240afd8cSMark Johnston# Create a pool with two datasets, where the root dataset is mounted below 434240afd8cSMark Johnston# the child dataset. 435240afd8cSMark Johnston# 436240afd8cSMark Johnstonatf_test_case multi_dataset_2 cleanup 437240afd8cSMark Johnstonmulti_dataset_2_body() 438240afd8cSMark Johnston{ 439240afd8cSMark Johnston create_test_dirs 440240afd8cSMark Johnston cd $TEST_INPUTS_DIR 441240afd8cSMark Johnston 442240afd8cSMark Johnston mkdir dir1 443240afd8cSMark Johnston echo a > dir1/a 444240afd8cSMark Johnston mkdir dir2 445240afd8cSMark Johnston echo b > dir2/b 446240afd8cSMark Johnston 447240afd8cSMark Johnston cd - 448240afd8cSMark Johnston 449240afd8cSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 450240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir1\;mountpoint=/ \ 451240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}\;mountpoint=/dir1 \ 452240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 453240afd8cSMark Johnston 454240afd8cSMark Johnston import_image 455240afd8cSMark Johnston 456240afd8cSMark Johnston check_image_contents 457240afd8cSMark Johnston} 458240afd8cSMark Johnstonmulti_dataset_2_cleanup() 459240afd8cSMark Johnston{ 460240afd8cSMark Johnston common_cleanup 461240afd8cSMark Johnston} 462240afd8cSMark Johnston 463240afd8cSMark Johnston# 464240afd8cSMark Johnston# Create a dataset with a non-existent mount point. 465240afd8cSMark Johnston# 466240afd8cSMark Johnstonatf_test_case multi_dataset_3 cleanup 467240afd8cSMark Johnstonmulti_dataset_3_body() 468240afd8cSMark Johnston{ 469240afd8cSMark Johnston create_test_dirs 470240afd8cSMark Johnston cd $TEST_INPUTS_DIR 471240afd8cSMark Johnston 472240afd8cSMark Johnston mkdir dir1 473240afd8cSMark Johnston echo a > dir1/a 474240afd8cSMark Johnston 475240afd8cSMark Johnston cd - 476240afd8cSMark Johnston 477240afd8cSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 478240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir1 \ 479240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir2 \ 480240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 481240afd8cSMark Johnston 482240afd8cSMark Johnston import_image 483240afd8cSMark Johnston 484240afd8cSMark Johnston atf_check -o inline:${TEST_MOUNT_DIR}/dir2\\n -e empty -s exit:0 \ 485240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir2 486240afd8cSMark Johnston 487240afd8cSMark Johnston # Mounting dir2 should have created a directory called dir2. Go 488240afd8cSMark Johnston # back and create it in the staging tree before comparing. 489240afd8cSMark Johnston atf_check mkdir ${TEST_INPUTS_DIR}/dir2 490240afd8cSMark Johnston 491240afd8cSMark Johnston check_image_contents 492240afd8cSMark Johnston} 493240afd8cSMark Johnstonmulti_dataset_3_cleanup() 494240afd8cSMark Johnston{ 495240afd8cSMark Johnston common_cleanup 496240afd8cSMark Johnston} 497240afd8cSMark Johnston 498240afd8cSMark Johnston# 499240afd8cSMark Johnston# Create an unmounted dataset. 500240afd8cSMark Johnston# 501240afd8cSMark Johnstonatf_test_case multi_dataset_4 cleanup 502240afd8cSMark Johnstonmulti_dataset_4_body() 503240afd8cSMark Johnston{ 504240afd8cSMark Johnston create_test_dirs 505240afd8cSMark Johnston cd $TEST_INPUTS_DIR 506240afd8cSMark Johnston 507240afd8cSMark Johnston mkdir dir1 508240afd8cSMark Johnston echo a > dir1/a 509240afd8cSMark Johnston 510240afd8cSMark Johnston cd - 511240afd8cSMark Johnston 512240afd8cSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 513240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}/dir1\;canmount=noauto\;mountpoint=none \ 514240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 515240afd8cSMark Johnston 516240afd8cSMark Johnston import_image 517240afd8cSMark Johnston 518240afd8cSMark Johnston atf_check -o inline:none\\n -e empty -s exit:0 \ 519240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1 520240afd8cSMark Johnston 521240afd8cSMark Johnston check_image_contents 522240afd8cSMark Johnston 523240afd8cSMark Johnston atf_check zfs set mountpoint=/dir1 ${ZFS_POOL_NAME}/dir1 524240afd8cSMark Johnston atf_check zfs mount ${ZFS_POOL_NAME}/dir1 525240afd8cSMark Johnston atf_check -o inline:${TEST_MOUNT_DIR}/dir1\\n -e empty -s exit:0 \ 526240afd8cSMark Johnston zfs list -H -o mountpoint ${ZFS_POOL_NAME}/dir1 527240afd8cSMark Johnston 528240afd8cSMark Johnston # dir1/a should be part of the root dataset, not dir1. 529240afd8cSMark Johnston atf_check -s not-exit:0 -e not-empty stat ${TEST_MOUNT_DIR}dir1/a 530240afd8cSMark Johnston} 531240afd8cSMark Johnstonmulti_dataset_4_cleanup() 532240afd8cSMark Johnston{ 533240afd8cSMark Johnston common_cleanup 534240afd8cSMark Johnston} 535240afd8cSMark Johnston 536240afd8cSMark Johnston# 5378502144dSMark Johnston# Validate handling of multiple staging directories. 5388502144dSMark Johnston# 5398502144dSMark Johnstonatf_test_case multi_staging_1 cleanup 5408502144dSMark Johnstonmulti_staging_1_body() 5418502144dSMark Johnston{ 5428502144dSMark Johnston local tmpdir 5438502144dSMark Johnston 5448502144dSMark Johnston create_test_dirs 5458502144dSMark Johnston cd $TEST_INPUTS_DIR 5468502144dSMark Johnston 5478502144dSMark Johnston mkdir dir1 5488502144dSMark Johnston echo a > a 5498502144dSMark Johnston echo a > dir1/a 5508502144dSMark Johnston echo z > z 5518502144dSMark Johnston 5528502144dSMark Johnston cd - 5538502144dSMark Johnston 5548502144dSMark Johnston tmpdir=$(mktemp -d) 5558502144dSMark Johnston cd $tmpdir 5568502144dSMark Johnston 5578502144dSMark Johnston mkdir dir2 dir2/dir3 5588502144dSMark Johnston echo b > dir2/b 5598502144dSMark Johnston echo c > dir2/dir3/c 5608502144dSMark Johnston ln -s dir2/dir3c s 5618502144dSMark Johnston 5628502144dSMark Johnston cd - 5638502144dSMark Johnston 5648502144dSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 5658502144dSMark Johnston $TEST_IMAGE ${TEST_INPUTS_DIR} $tmpdir 5668502144dSMark Johnston 5678502144dSMark Johnston import_image 5688502144dSMark Johnston 5698502144dSMark Johnston check_image_contents -d $tmpdir 5708502144dSMark Johnston} 5718502144dSMark Johnstonmulti_staging_1_cleanup() 5728502144dSMark Johnston{ 5738502144dSMark Johnston common_cleanup 5748502144dSMark Johnston} 5758502144dSMark Johnston 5768502144dSMark Johnstonatf_test_case multi_staging_2 cleanup 5778502144dSMark Johnstonmulti_staging_2_body() 5788502144dSMark Johnston{ 5798502144dSMark Johnston local tmpdir 5808502144dSMark Johnston 5818502144dSMark Johnston create_test_dirs 5828502144dSMark Johnston cd $TEST_INPUTS_DIR 5838502144dSMark Johnston 5848502144dSMark Johnston mkdir dir 5858502144dSMark Johnston echo a > dir/foo 5868502144dSMark Johnston echo b > dir/bar 5878502144dSMark Johnston 5888502144dSMark Johnston cd - 5898502144dSMark Johnston 5908502144dSMark Johnston tmpdir=$(mktemp -d) 5918502144dSMark Johnston cd $tmpdir 5928502144dSMark Johnston 5938502144dSMark Johnston mkdir dir 5948502144dSMark Johnston echo c > dir/baz 5958502144dSMark Johnston 5968502144dSMark Johnston cd - 5978502144dSMark Johnston 5988502144dSMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 5998502144dSMark Johnston $TEST_IMAGE ${TEST_INPUTS_DIR} $tmpdir 6008502144dSMark Johnston 6018502144dSMark Johnston import_image 6028502144dSMark Johnston 6038502144dSMark Johnston # check_image_contents can't easily handle merged directories, so 6048502144dSMark Johnston # just check that the merged directory contains the files we expect. 6058502144dSMark Johnston atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/foo 6068502144dSMark Johnston atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/bar 6078502144dSMark Johnston atf_check -o not-empty stat ${TEST_MOUNT_DIR}/dir/baz 6088502144dSMark Johnston 6098502144dSMark Johnston if [ "$(ls ${TEST_MOUNT_DIR}/dir | wc -l)" -ne 3 ]; then 6108502144dSMark Johnston atf_fail "Expected 3 files in ${TEST_MOUNT_DIR}/dir" 6118502144dSMark Johnston fi 6128502144dSMark Johnston} 6138502144dSMark Johnstonmulti_staging_2_cleanup() 6148502144dSMark Johnston{ 6158502144dSMark Johnston common_cleanup 6168502144dSMark Johnston} 6178502144dSMark Johnston 6188502144dSMark Johnston# 619240afd8cSMark Johnston# Rudimentary test to verify that two ZFS images created using the same 620240afd8cSMark Johnston# parameters and input hierarchy are byte-identical. In particular, makefs(1) 621240afd8cSMark Johnston# does not preserve file access times. 622240afd8cSMark Johnston# 623240afd8cSMark Johnstonatf_test_case reproducible cleanup 624240afd8cSMark Johnstonreproducible_body() 625240afd8cSMark Johnston{ 626240afd8cSMark Johnston create_test_inputs 627240afd8cSMark Johnston 628240afd8cSMark Johnston atf_check $MAKEFS -s 512m -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 629240afd8cSMark Johnston ${TEST_IMAGE}.1 $TEST_INPUTS_DIR 630240afd8cSMark Johnston 631240afd8cSMark Johnston atf_check $MAKEFS -s 512m -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 632240afd8cSMark Johnston ${TEST_IMAGE}.2 $TEST_INPUTS_DIR 633240afd8cSMark Johnston 634240afd8cSMark Johnston # XXX-MJ cmp(1) is really slow 635240afd8cSMark Johnston atf_check cmp ${TEST_IMAGE}.1 ${TEST_IMAGE}.2 636240afd8cSMark Johnston} 637240afd8cSMark Johnstonreproducible_cleanup() 638240afd8cSMark Johnston{ 639240afd8cSMark Johnston} 640240afd8cSMark Johnston 641240afd8cSMark Johnston# 642240afd8cSMark Johnston# Verify that we can take a snapshot of a generated dataset. 643240afd8cSMark Johnston# 644240afd8cSMark Johnstonatf_test_case snapshot cleanup 645240afd8cSMark Johnstonsnapshot_body() 646240afd8cSMark Johnston{ 647240afd8cSMark Johnston create_test_dirs 648240afd8cSMark Johnston cd $TEST_INPUTS_DIR 649240afd8cSMark Johnston 650240afd8cSMark Johnston mkdir dir 651240afd8cSMark Johnston echo "hello" > dir/hello 652240afd8cSMark Johnston echo "goodbye" > goodbye 653240afd8cSMark Johnston 654240afd8cSMark Johnston cd - 655240afd8cSMark Johnston 656240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 657240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 658240afd8cSMark Johnston 659240afd8cSMark Johnston import_image 660240afd8cSMark Johnston 661240afd8cSMark Johnston atf_check zfs snapshot ${ZFS_POOL_NAME}@1 662240afd8cSMark Johnston} 663240afd8cSMark Johnstonsnapshot_cleanup() 664240afd8cSMark Johnston{ 665240afd8cSMark Johnston common_cleanup 666240afd8cSMark Johnston} 667240afd8cSMark Johnston 668240afd8cSMark Johnston# 669240afd8cSMark Johnston# Check handling of symbolic links. 670240afd8cSMark Johnston# 671240afd8cSMark Johnstonatf_test_case soft_links cleanup 672240afd8cSMark Johnstonsoft_links_body() 673240afd8cSMark Johnston{ 674240afd8cSMark Johnston create_test_dirs 675240afd8cSMark Johnston cd $TEST_INPUTS_DIR 676240afd8cSMark Johnston 677240afd8cSMark Johnston mkdir dir 678240afd8cSMark Johnston ln -s a a 679240afd8cSMark Johnston ln -s dir/../a a 680240afd8cSMark Johnston ln -s dir/b b 681240afd8cSMark Johnston echo 'c' > dir 682240afd8cSMark Johnston ln -s dir/c c 683240afd8cSMark Johnston # XXX-MJ overflows bonus buffer ln -s $(jot -s '' 320 1 1) 1 684240afd8cSMark Johnston 685240afd8cSMark Johnston cd - 686240afd8cSMark Johnston 687240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 688240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 689240afd8cSMark Johnston 690240afd8cSMark Johnston import_image 691240afd8cSMark Johnston 692240afd8cSMark Johnston check_image_contents 693240afd8cSMark Johnston} 694240afd8cSMark Johnstonsoft_links_cleanup() 695240afd8cSMark Johnston{ 696240afd8cSMark Johnston common_cleanup 697240afd8cSMark Johnston} 698240afd8cSMark Johnston 699240afd8cSMark Johnston# 700240afd8cSMark Johnston# Verify that we can set properties on the root dataset. 701240afd8cSMark Johnston# 702240afd8cSMark Johnstonatf_test_case root_props cleanup 703240afd8cSMark Johnstonroot_props_body() 704240afd8cSMark Johnston{ 705240afd8cSMark Johnston create_test_inputs 706240afd8cSMark Johnston 707240afd8cSMark Johnston atf_check $MAKEFS -s 10g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 708240afd8cSMark Johnston -o fs=${ZFS_POOL_NAME}\;atime=off\;setuid=off \ 709240afd8cSMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 710240afd8cSMark Johnston 711240afd8cSMark Johnston import_image 712240afd8cSMark Johnston 713240afd8cSMark Johnston check_image_contents 714240afd8cSMark Johnston 715240afd8cSMark Johnston atf_check -o inline:off\\n -e empty -s exit:0 \ 716240afd8cSMark Johnston zfs get -H -o value atime $ZFS_POOL_NAME 717240afd8cSMark Johnston atf_check -o inline:local\\n -e empty -s exit:0 \ 718240afd8cSMark Johnston zfs get -H -o source atime $ZFS_POOL_NAME 719240afd8cSMark Johnston atf_check -o inline:off\\n -e empty -s exit:0 \ 720240afd8cSMark Johnston zfs get -H -o value setuid $ZFS_POOL_NAME 721240afd8cSMark Johnston atf_check -o inline:local\\n -e empty -s exit:0 \ 722240afd8cSMark Johnston zfs get -H -o source setuid $ZFS_POOL_NAME 723240afd8cSMark Johnston} 724240afd8cSMark Johnstonroot_props_cleanup() 725240afd8cSMark Johnston{ 726240afd8cSMark Johnston common_cleanup 727240afd8cSMark Johnston} 728240afd8cSMark Johnston 7299f9d18d6SMark Johnston# 7309f9d18d6SMark Johnston# Verify that usedds and usedchild props are set properly. 7319f9d18d6SMark Johnston# 7329f9d18d6SMark Johnstonatf_test_case used_space_props cleanup 7339f9d18d6SMark Johnstonused_space_props_body() 7349f9d18d6SMark Johnston{ 7359f9d18d6SMark Johnston local used usedds usedchild 7369f9d18d6SMark Johnston local rootmb childmb totalmb fudge 7379f9d18d6SMark Johnston local status 7389f9d18d6SMark Johnston 7399f9d18d6SMark Johnston create_test_dirs 7409f9d18d6SMark Johnston cd $TEST_INPUTS_DIR 7419f9d18d6SMark Johnston mkdir dir 7429f9d18d6SMark Johnston 7439f9d18d6SMark Johnston rootmb=17 7449f9d18d6SMark Johnston childmb=39 7459f9d18d6SMark Johnston totalmb=$(($rootmb + $childmb)) 7469f9d18d6SMark Johnston fudge=$((2 * 1024 * 1024)) 7479f9d18d6SMark Johnston 7489f9d18d6SMark Johnston atf_check -e ignore dd if=/dev/random of=foo bs=1M count=$rootmb 7499f9d18d6SMark Johnston atf_check -e ignore dd if=/dev/random of=dir/bar bs=1M count=$childmb 7509f9d18d6SMark Johnston 7519f9d18d6SMark Johnston cd - 7529f9d18d6SMark Johnston 7539f9d18d6SMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 7549f9d18d6SMark Johnston -o fs=${ZFS_POOL_NAME}/dir \ 7559f9d18d6SMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 7569f9d18d6SMark Johnston 7579f9d18d6SMark Johnston import_image 7589f9d18d6SMark Johnston 7599f9d18d6SMark Johnston # Make sure that each dataset's space usage is no more than 2MB larger 7609f9d18d6SMark Johnston # than their files. This number is magic and might need to change 7619f9d18d6SMark Johnston # someday. 7629f9d18d6SMark Johnston usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME}) 7639f9d18d6SMark Johnston atf_check test $usedds -gt $(($rootmb * 1024 * 1024)) -a \ 7649f9d18d6SMark Johnston $usedds -le $(($rootmb * 1024 * 1024 + $fudge)) 7659f9d18d6SMark Johnston usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME}/dir) 7669f9d18d6SMark Johnston atf_check test $usedds -gt $(($childmb * 1024 * 1024)) -a \ 7679f9d18d6SMark Johnston $usedds -le $(($childmb * 1024 * 1024 + $fudge)) 7689f9d18d6SMark Johnston 7699f9d18d6SMark Johnston # Make sure that the usedchild property value makes sense: the parent's 7709f9d18d6SMark Johnston # value corresponds to the size of the child, and the child has no 7719f9d18d6SMark Johnston # children. 7729f9d18d6SMark Johnston usedchild=$(zfs list -o usedchild -Hp ${ZFS_POOL_NAME}) 7739f9d18d6SMark Johnston atf_check test $usedchild -gt $(($childmb * 1024 * 1024)) -a \ 7749f9d18d6SMark Johnston $usedchild -le $(($childmb * 1024 * 1024 + $fudge)) 7759f9d18d6SMark Johnston atf_check -o inline:'0\n' \ 7769f9d18d6SMark Johnston zfs list -Hp -o usedchild ${ZFS_POOL_NAME}/dir 7779f9d18d6SMark Johnston 7789f9d18d6SMark Johnston # Make sure that the used property value makes sense: the parent's 7799f9d18d6SMark Johnston # value is the sum of the two sizes, and the child's value is the 7809f9d18d6SMark Johnston # same as its usedds value, which has already been checked. 7819f9d18d6SMark Johnston used=$(zfs list -o used -Hp ${ZFS_POOL_NAME}) 7829f9d18d6SMark Johnston atf_check test $used -gt $(($totalmb * 1024 * 1024)) -a \ 7839f9d18d6SMark Johnston $used -le $(($totalmb * 1024 * 1024 + 2 * $fudge)) 7849f9d18d6SMark Johnston used=$(zfs list -o used -Hp ${ZFS_POOL_NAME}/dir) 7859f9d18d6SMark Johnston atf_check -o inline:$used'\n' \ 7869f9d18d6SMark Johnston zfs list -Hp -o usedds ${ZFS_POOL_NAME}/dir 7879f9d18d6SMark Johnston 7889f9d18d6SMark Johnston # Both datasets do not have snapshots. 7899f9d18d6SMark Johnston atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME} 7909f9d18d6SMark Johnston atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME}/dir 7919f9d18d6SMark Johnston} 7929f9d18d6SMark Johnstonused_space_props_cleanup() 7939f9d18d6SMark Johnston{ 7949f9d18d6SMark Johnston common_cleanup 7959f9d18d6SMark Johnston} 7969f9d18d6SMark Johnston 7977e5002e3SMark Johnston# Verify that file permissions are set properly. Make sure that non-executable 7987e5002e3SMark Johnston# files can't be executed. 7997e5002e3SMark Johnstonatf_test_case perms cleanup 8007e5002e3SMark Johnstonperms_body() 8017e5002e3SMark Johnston{ 8027e5002e3SMark Johnston local mode 8037e5002e3SMark Johnston 8047e5002e3SMark Johnston create_test_dirs 8057e5002e3SMark Johnston cd $TEST_INPUTS_DIR 8067e5002e3SMark Johnston 8077e5002e3SMark Johnston for mode in $(seq 0 511); do 8087e5002e3SMark Johnston mode=$(printf "%04o\n" $mode) 8097e5002e3SMark Johnston echo 'echo a' > $mode 8107e5002e3SMark Johnston atf_check chmod $mode $mode 8117e5002e3SMark Johnston done 8127e5002e3SMark Johnston 8137e5002e3SMark Johnston cd - 8147e5002e3SMark Johnston 8157e5002e3SMark Johnston atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ 8167e5002e3SMark Johnston $TEST_IMAGE $TEST_INPUTS_DIR 8177e5002e3SMark Johnston 8187e5002e3SMark Johnston import_image 8197e5002e3SMark Johnston 8207e5002e3SMark Johnston check_image_contents 8217e5002e3SMark Johnston 8227e5002e3SMark Johnston for mode in $(seq 0 511); do 8237e5002e3SMark Johnston mode=$(printf "%04o\n" $mode) 8247e5002e3SMark Johnston if [ $(($mode & 0111)) -eq 0 ]; then 8257e5002e3SMark Johnston atf_check -s not-exit:0 -e match:"Permission denied" \ 8267e5002e3SMark Johnston ${TEST_INPUTS_DIR}/$mode 8277e5002e3SMark Johnston fi 8287e5002e3SMark Johnston if [ $(($mode & 0001)) -eq 0 ]; then 8297e5002e3SMark Johnston atf_check -s not-exit:0 -e match:"Permission denied" \ 8307e5002e3SMark Johnston su -m tests -c ${TEST_INPUTS_DIR}/$mode 8317e5002e3SMark Johnston fi 8327e5002e3SMark Johnston done 8337e5002e3SMark Johnston 8347e5002e3SMark Johnston} 8357e5002e3SMark Johnstonperms_cleanup() 8367e5002e3SMark Johnston{ 8377e5002e3SMark Johnston common_cleanup 8387e5002e3SMark Johnston} 8397e5002e3SMark Johnston 840240afd8cSMark Johnstonatf_init_test_cases() 841240afd8cSMark Johnston{ 842240afd8cSMark Johnston atf_add_test_case autoexpand 843240afd8cSMark Johnston atf_add_test_case basic 844240afd8cSMark Johnston atf_add_test_case dataset_removal 845240afd8cSMark Johnston atf_add_test_case empty_dir 846240afd8cSMark Johnston atf_add_test_case empty_fs 847b6da7f2fSMark Johnston atf_add_test_case file_extend 848240afd8cSMark Johnston atf_add_test_case file_sizes 849240afd8cSMark Johnston atf_add_test_case hard_links 850240afd8cSMark Johnston atf_add_test_case indirect_dnode_array 851240afd8cSMark Johnston atf_add_test_case long_file_name 852240afd8cSMark Johnston atf_add_test_case multi_dataset_1 853240afd8cSMark Johnston atf_add_test_case multi_dataset_2 854240afd8cSMark Johnston atf_add_test_case multi_dataset_3 855240afd8cSMark Johnston atf_add_test_case multi_dataset_4 8568502144dSMark Johnston atf_add_test_case multi_staging_1 8578502144dSMark Johnston atf_add_test_case multi_staging_2 858240afd8cSMark Johnston atf_add_test_case reproducible 859240afd8cSMark Johnston atf_add_test_case snapshot 860240afd8cSMark Johnston atf_add_test_case soft_links 861240afd8cSMark Johnston atf_add_test_case root_props 8629f9d18d6SMark Johnston atf_add_test_case used_space_props 8637e5002e3SMark Johnston atf_add_test_case perms 864240afd8cSMark Johnston 865240afd8cSMark Johnston # XXXMJ tests: 866240afd8cSMark Johnston # - test with different ashifts (at least, 9 and 12), different image sizes 867240afd8cSMark Johnston # - create datasets in imported pool 868240afd8cSMark Johnston} 869