Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/compression/compress_004_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/compression/compress_004_pos.ksh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #
29 -# Copyright (c) 2013 by Delphix. All rights reserved.
29 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 30 #
31 31
32 32 . $STF_SUITE/include/libtest.shlib
33 33
34 34 #
35 35 # DESCRIPTION:
36 36 # With 'compression' set, a file with non-power-of-2 blocksize storage space
37 37 # can be freed as will normally.
38 38 #
39 39 # STRATEGY:
40 40 # 1. Set 'compression' or 'compress' to on or lzjb
41 41 # 2. Set different recordsize with ZFS filesystem
42 42 # 3. Repeatedly using 'randfree_file' to create a file and then free its
43 43 # storage space with different range, the system should work normally.
44 44 #
45 45
46 46 verify_runnable "both"
47 47
48 48 function cleanup
49 49 {
50 - $RM -f $TESTDIR/*
50 + rm -f $TESTDIR/*
51 51 }
52 52
53 53 function create_free_testing #<file size> <file>
54 54 {
55 55 typeset -i fsz=$1
56 56 typeset file=$2
57 57 typeset -i start=0
58 58 typeset -i len=0
59 59 typeset -i dist=0
60 60
61 61 for start in 0 `expr $RANDOM % $fsz`
62 62 do
63 63 (( dist = fsz - start ))
64 64 for len in `expr $RANDOM % $dist` $dist \
65 65 `expr $start + $dist`; do
66 - log_must $RANDFREE_FILE -l fsz -s $start \
66 + log_must randfree_file -l fsz -s $start \
67 67 -n $len $file
68 68 [[ -e $file ]] && \
69 - log_must $RM -f $file
69 + log_must rm -f $file
70 70 done
71 71 done
72 72 }
73 73
74 74
75 75 log_assert "Creating non-power-of-2 blocksize file and freeing the file \
76 76 storage space at will should work normally with compression setting"
77 77 log_onexit cleanup
78 78
79 79 fs=$TESTPOOL/$TESTFS
80 80 single_blk_file=$TESTDIR/singleblkfile.$$
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
81 81 multi_blk_file=$TESTDIR/multiblkfile.$$
82 82 typeset -i blksize=512
83 83 typeset -i fsize=0
84 84 typeset -i avail=0
85 85 typeset -i blknum=0
86 86
87 87 for propname in "compression" "compress"
88 88 do
89 89 for value in $(get_compress_opts zfs_compress)
90 90 do
91 - log_must $ZFS set compression=$value $fs
91 + log_must zfs set compression=$value $fs
92 92 real_val=$(get_prop $propname $fs)
93 93 if [[ $value == "gzip-6" ]]; then
94 94 value="gzip"
95 95 fi
96 96 [[ $real_val != $value ]] && \
97 97 log_fail "Set property $propname=$value failed."
98 98
99 99 (( blksize = 512 ))
100 100 while (( blksize <= 131072 )); do
101 - log_must $ZFS set recordsize=$blksize $fs
101 + log_must zfs set recordsize=$blksize $fs
102 102
103 103 # doing single block testing
104 104 (( fsize = $RANDOM ))
105 105 if (( fsize > blksize )); then
106 106 (( fsize = fsize % blksize ))
107 107 fi
108 108 if (( (fsize % 2) == 0 )); then
109 109 #make sure fsize is non-power-of-2
110 110 (( fsize = fsize + 1 ))
111 111 fi
112 112 create_free_testing $fsize $single_blk_file
113 113
114 114 # doing multiple blocks testing
115 115 avail=$(get_prop available $fs)
116 116 (( blknum = avail / blksize ))
117 117 # we just test <10 multi-blocks to limit testing time
118 118 (( blknum = blknum % 9 ))
119 119 while (( blknum < 2 )); do
120 120 (( blknum = blknum + $RANDOM % 9 ))
121 121 done
122 122 if (( (blknum % 2) == 0 )); then
123 123 (( blknum = blknum + 1 )) # keep blknum as odd
124 124 fi
125 125 (( fsize = blknum * blksize ))
126 126 create_free_testing $fsize $multi_blk_file
127 127
128 128 (( blksize = blksize * 2 ))
129 129 done
130 130 done
131 131 done
132 132
133 133 log_pass "Creating and freeing non-power-of-2 blocksize file work as expected."
|
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX