dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / test / zfs-tests / tests / functional / cli_user / misc / setup.ksh
blobbf4d24075ad09e40b0671faa852248a2c0e0fb32
1 #!/usr/bin/ksh -p
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
33 . $STF_SUITE/include/libtest.shlib
35 # This setup script is moderately complex, as it creates scenarios for all
36 # of the tests included in this directory. Usually we'd want each test case
37 # to setup/teardown it's own configuration, but this would be time consuming
38 # given the nature of these tests. However, as a side-effect, one test
39 # leaving the system in an unknown state could impact other test cases.
42 DISK=${DISKS%% *}
43 VOLSIZE=150m
44 TESTVOL=testvol
46 # Create a default setup that includes a volume
47 default_setup_noexit "$DISK" "" "volume"
50 # The rest of this setup script creates a ZFS filesystem configuration
51 # that is used to test the rest of the zfs subcommands in this directory.
54 # create a snapshot and a clone to test clone promote
55 log_must zfs snapshot $TESTPOOL/$TESTFS@snap
56 log_must zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS/clone
57 # create a file in the filesystem that isn't in the above snapshot
58 touch /$TESTDIR/file.txt
61 # create a non-default property and a child we can use to test inherit
62 log_must zfs create $TESTPOOL/$TESTFS/$TESTFS2
63 log_must zfs set snapdir=hidden $TESTPOOL/$TESTFS
66 # create an unmounted filesystem to test unmount
67 log_must zfs create $TESTPOOL/$TESTFS/$TESTFS2.unmounted
68 log_must zfs unmount $TESTPOOL/$TESTFS/$TESTFS2.unmounted
71 # send our snapshot to a known file in /tmp
72 zfs send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.dat
73 if [ ! -s /tmp/zfstest_datastream.dat ]
74 then
75 log_fail "ZFS send datafile was not created!"
77 log_must chmod 644 /tmp/zfstest_datastream.dat
80 # create a filesystem that has particular properties to test set/get
81 log_must zfs create -o version=1 $TESTPOOL/$TESTFS/prop
82 set -A props $PROP_NAMES
83 set -A prop_vals $PROP_VALS
84 typeset -i i=0
86 while [[ $i -lt ${#props[*]} ]]
88 prop_name=${props[$i]}
89 prop_val=${prop_vals[$i]}
90 log_must zfs set $prop_name=$prop_val $TESTPOOL/$TESTFS/prop
91 i=$(( $i + 1 ))
92 done
94 # create a filesystem we don't mind renaming
95 log_must zfs create $TESTPOOL/$TESTFS/renameme
98 if is_global_zone
99 then
100 # create a filesystem we can share
101 log_must zfs create $TESTPOOL/$TESTFS/unshared
102 log_must zfs set sharenfs=off $TESTPOOL/$TESTFS/unshared
104 # create a filesystem that we can unshare
105 log_must zfs create $TESTPOOL/$TESTFS/shared
106 log_must zfs set sharenfs=on $TESTPOOL/$TESTFS/shared
110 log_must zfs create -o version=1 $TESTPOOL/$TESTFS/version1
111 log_must zfs create -o version=1 $TESTPOOL/$TESTFS/allowed
112 log_must zfs allow everyone create $TESTPOOL/$TESTFS/allowed
114 if is_global_zone
115 then
117 # Now create several virtual disks to test zpool with
119 mkfile $MINVDEVSIZE /$TESTDIR/disk1.dat
120 mkfile $MINVDEVSIZE /$TESTDIR/disk2.dat
121 mkfile $MINVDEVSIZE /$TESTDIR/disk3.dat
122 mkfile $MINVDEVSIZE /$TESTDIR/disk-additional.dat
123 mkfile $MINVDEVSIZE /$TESTDIR/disk-export.dat
124 mkfile $MINVDEVSIZE /$TESTDIR/disk-offline.dat
125 mkfile $MINVDEVSIZE /$TESTDIR/disk-spare1.dat
126 mkfile $MINVDEVSIZE /$TESTDIR/disk-spare2.dat
128 # and create a pool we can perform attach remove replace,
129 # etc. operations with
130 log_must zpool create $TESTPOOL.virt mirror /$TESTDIR/disk1.dat \
131 /$TESTDIR/disk2.dat /$TESTDIR/disk3.dat /$TESTDIR/disk-offline.dat \
132 spare /$TESTDIR/disk-spare1.dat
135 # Offline one of the disks to test online
136 log_must zpool offline $TESTPOOL.virt /$TESTDIR/disk-offline.dat
139 # create an exported pool to test import
140 log_must zpool create $TESTPOOL.exported /$TESTDIR/disk-export.dat
141 log_must zpool export $TESTPOOL.exported
143 set -A props $POOL_PROPS
144 set -A prop_vals $POOL_VALS
145 typeset -i i=0
147 while [[ $i -lt ${#props[*]} ]]
149 prop_name=${props[$i]}
150 prop_val=${prop_vals[$i]}
151 log_must zpool set $prop_name=$prop_val $TESTPOOL
152 i=$(( $i + 1 ))
153 done
155 # copy a v1 pool from cli_root
156 cp $STF_SUITE/tests/functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1.dat.bz2 \
157 /$TESTDIR
158 log_must bunzip2 /$TESTDIR/zfs-pool-v1.dat.bz2
159 log_must zpool import -d /$TESTDIR v1-pool
161 log_pass