7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_copies / zfs_copies_002_pos.ksh
blob54a7ee84569f23e29bd41a7b524d6ae00fada7e5
1 #!/bin/ksh
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 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_copies/zfs_copies.kshlib
36 # DESCRIPTION:
37 # Verify that the space used by multiple copies is charged correctly
39 # STRATEGY:
40 # 1. Create filesystems with copies set as 2,3 respectively;
41 # 2. Copy specified size data into each filesystem;
42 # 3. Verify that the space is charged as expected with zfs list, ls -s, df(1m),
43 # du(1) commands;
46 verify_runnable "both"
48 function cleanup
50 typeset val
52 for val in 1 2 3; do
53 if datasetexists $TESTPOOL/fs_$val; then
54 log_must zfs destroy $TESTPOOL/fs_$val
56 done
59 log_assert "Verify that the space used by multiple copies is charged correctly."
60 log_onexit cleanup
62 for val in 1 2 3; do
63 log_must zfs create -o copies=$val $TESTPOOL/fs_$val
65 log_must mkfile $FILESIZE /$TESTPOOL/fs_$val/$FILE
66 done
69 # Sync up the filesystem
71 sync
74 # Verify 'zfs list' can correctly list the space charged
76 log_note "Verify 'zfs list' can correctly list the space charged."
77 fsize=${FILESIZE%[m|M]}
78 for val in 1 2 3; do
79 used=$(get_used_prop $TESTPOOL/fs_$val)
80 check_used $used $val
81 done
83 log_note "Verify 'ls -s' can correctly list the space charged."
84 for val in 1 2 3; do
85 blks=`ls -ls /$TESTPOOL/fs_$val/$FILE | awk '{print $1}'`
86 (( used = blks * 512 / (1024 * 1024) ))
87 check_used $used $val
88 done
90 log_note "Verify df(1M) can corectly display the space charged."
91 for val in 1 2 3; do
92 used=`df -F zfs -h /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \
93 | awk '{print $3}'`
94 check_used $used $val
95 done
97 log_note "Verify du(1) can correctly display the space charged."
98 for val in 1 2 3; do
99 used=`du -h /$TESTPOOL/fs_$val/$FILE | awk '{print $1}'`
100 check_used $used $val
101 done
103 log_pass "The space used by multiple copies is charged correctly as expected. "