Print this page
XXX Remove nawk(1)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_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
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 . $STF_SUITE/include/libtest.shlib
29 29 . $STF_SUITE/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
30 30
31 31 #
32 32 # DESCRIPTION:
33 33 # Executing 'zfs upgrade' command succeeds, it should report
34 34 # the current system version and list all old-version filesystems.
35 35 # If no old-version filesystems be founded, it prints out
36 36 # "All filesystems are formatted with the current version."
37 37 #
38 38 # STRATEGY:
39 39 # 1. Prepare a set of datasets which contain old-version and current version.
40 40 # 2. Execute 'zfs upgrade', verify return 0, and it prints out
41 41 # the current system version and list all old-version filesystems.
42 42 # 3. Remove all old-version filesystems, then execute 'zfs upgrade' again,
43 43 # verify return 0, and get the expected message.
44 44 #
45 45
46 46 verify_runnable "both"
47 47
48 48 function cleanup
49 49 {
50 50 if datasetexists $rootfs ; then
51 51 log_must $ZFS destroy -Rf $rootfs
52 52 fi
53 53 log_must $ZFS create $rootfs
54 54
55 55 for file in $output $oldoutput ; do
56 56 if [[ -f $file ]]; then
57 57 log_must $RM -f $file
58 58 fi
59 59 done
60 60 }
61 61
62 62 log_assert "Executing 'zfs upgrade' command succeeds."
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
63 63 log_onexit cleanup
64 64
65 65 rootfs=$TESTPOOL/$TESTFS
66 66 typeset output=/tmp/zfs-versions.$$
67 67 typeset oldoutput=/tmp/zfs-versions-old.$$
68 68 typeset expect_str1="This system is currently running ZFS filesystem version"
69 69 typeset expect_str2="All filesystems are formatted with the current version"
70 70 typeset expect_str3="The following filesystems are out of date, and can be upgraded"
71 71 typeset -i COUNT OLDCOUNT
72 72
73 -$ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
73 +$ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
74 74 OLDCOUNT=$( $WC -l $oldoutput | $AWK '{print $1}' )
75 75
76 76 old_datasets=""
77 77 for version in $ZFS_ALL_VERSIONS ; do
78 78 typeset verfs
79 79 eval verfs=\$ZFS_VERSION_$version
80 80 typeset current_fs=$rootfs/$verfs
81 81 typeset current_snap=${current_fs}@snap
82 82 typeset current_clone=$rootfs/clone$verfs
83 83 log_must $ZFS create -o version=${version} ${current_fs}
84 84 log_must $ZFS snapshot ${current_snap}
85 85 log_must $ZFS clone ${current_snap} ${current_clone}
86 86
87 87 if (( version != $ZFS_VERSION )); then
88 88 old_datasets="$old_datasets ${current_fs} ${current_clone}"
89 89 fi
90 90 done
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
91 91
92 92 if is_global_zone; then
93 93 log_must $ZFS create -V 100m $rootfs/$TESTVOL
94 94 fi
95 95
96 96 log_must eval '$ZFS upgrade > $output 2>&1'
97 97
98 98 # we also check that the usage message contains at least a description
99 99 # of the current ZFS version.
100 100 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
101 -$ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $output
101 +$ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $output
102 102 COUNT=$( $WC -l $output | $AWK '{print $1}' )
103 103
104 104 typeset -i i=0
105 105 for fs in ${old_datasets}; do
106 106 log_must $GREP "^$fs$" $output
107 107 (( i = i + 1 ))
108 108 done
109 109
110 110 if (( i != COUNT - OLDCOUNT )); then
111 111 $CAT $output
112 112 log_fail "More old-version filesystems print out than expect."
113 113 fi
114 114
115 115 for fs in $old_datasets ; do
116 116 if datasetexists $fs ; then
117 117 log_must $ZFS destroy -Rf $fs
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
118 118 fi
119 119 done
120 120
121 121 log_must eval '$ZFS upgrade > $output 2>&1'
122 122 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
123 123 if (( OLDCOUNT == 0 )); then
124 124 log_must eval '$GREP "${expect_str2}" $output > /dev/null 2>&1'
125 125 else
126 126 log_must eval '$GREP "${expect_str3}" $output > /dev/null 2>&1'
127 127 fi
128 -$ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $output
128 +$ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $output
129 129 COUNT=$( $WC -l $output | $AWK '{print $1}' )
130 130
131 131 if (( COUNT != OLDCOUNT )); then
132 132 $CAT $output
133 133 log_fail "Unexpect old-version filesystems print out."
134 134 fi
135 135
136 136 log_pass "Executing 'zfs upgrade' command succeeds."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX