Print this page
12181 zvol swap tests should avoid grep -w
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh
1 1 #! /usr/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]
19 19 #
20 20 # CDDL HEADER END
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
21 21 #
22 22
23 23 #
24 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #
29 29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 30 # Copyright 2016 Nexenta Systems, Inc.
31 +# Copyright 2020 Joyent, Inc.
31 32 #
32 33
33 34 . $STF_SUITE/include/libtest.shlib
34 35 . $STF_SUITE/tests/functional/zvol/zvol_common.shlib
35 36
36 37 #
37 38 # DESCRIPTION:
38 39 # Verify the ability to take snapshots of zvols used as dump or swap.
39 40 #
40 41 # STRATEGY:
41 42 # 1. Create a ZFS volume
42 43 # 2. Set the volume as dump or swap
43 44 # 3. Verify creating a snapshot of the zvol succeeds.
44 45 #
45 46
46 47 verify_runnable "global"
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
47 48
48 49 volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL)
49 50
50 51 function cleanup
51 52 {
52 53 typeset dumpdev=$(get_dumpdevice)
53 54 if [[ $dumpdev != $savedumpdev ]] ; then
54 55 safe_dumpadm $savedumpdev
55 56 fi
56 57
57 - swap -l | grep -w $voldev > /dev/null 2>&1
58 + swap -l | awk 'NR > 1 { print $1 }' | \
59 + grep "^$voldev\$" > /dev/null 2>&1
58 60 if (( $? == 0 )); then
59 61 log_must swap -d $voldev
60 62 fi
61 63
62 64 typeset snap
63 65 for snap in snap0 snap1 ; do
64 66 if datasetexists $TESTPOOL/$TESTVOL@$snap ; then
65 67 log_must zfs destroy $TESTPOOL/$TESTVOL@$snap
66 68 fi
67 69 done
68 70 zfs set volsize=$volsize $TESTPOOL/$TESTVOL
69 71 }
70 72
71 73 function verify_snapshot
72 74 {
73 75 typeset volume=$1
74 76
75 77 log_must zfs snapshot $volume@snap0
76 78 log_must zfs snapshot $volume@snap1
77 79 log_must datasetexists $volume@snap0 $volume@snap1
78 80
79 81 log_must zfs destroy $volume@snap1
80 82 log_must zfs snapshot $volume@snap1
81 83
82 84 log_mustnot zfs rollback -r $volume@snap0
83 85 log_must datasetexists $volume@snap0
84 86
85 87 log_must zfs destroy -r $volume@snap0
86 88 }
87 89
88 90 log_assert "Verify the ability to take snapshots of zvols used as dump or swap."
89 91 log_onexit cleanup
90 92
91 93 voldev=/dev/zvol/dsk/$TESTPOOL/$TESTVOL
92 94 savedumpdev=$(get_dumpdevice)
93 95
94 96 # create snapshot over dump zvol
95 97 safe_dumpadm $voldev
96 98 log_must is_zvol_dumpified $TESTPOOL/$TESTVOL
97 99
98 100 verify_snapshot $TESTPOOL/$TESTVOL
99 101
100 102 safe_dumpadm $savedumpdev
101 103 log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL
102 104
103 105 # create snapshot over swap zvol
104 106
105 107 log_must swap -a $voldev
106 108 log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL
107 109
108 110 verify_snapshot $TESTPOOL/$TESTVOL
109 111
110 112 log_must swap -d $voldev
111 113 log_mustnot is_zvol_dumpified $TESTPOOL/$TESTVOL
112 114
113 115 log_pass "Creating snapshots from dump/swap zvols succeeds."
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX