3311 Want a test framework for arbitrary OS unit tests
[illumos-gate.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_upgrade / zfs_upgrade_004_pos.ksh
blob67f441928a6e1c323173fb0f830377180b2e4997
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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
28 . $STF_SUITE/include/libtest.shlib
29 . $STF_SUITE/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib
32 # DESCRIPTION:
33 # Executing 'zfs upgrade -r [-V version] filesystem' command succeeds,
34 # it upgrade filesystem recursively to specific or current version.
36 # STRATEGY:
37 # 1. Prepare a set of datasets which contain old-version and current version.
38 # 2. Execute 'zfs upgrade -r [-V version] filesystem', verify return 0,
39 # 3. Verify the filesystem be updated recursively as expected.
42 verify_runnable "both"
44 function cleanup
46 if datasetexists $rootfs ; then
47 log_must $ZFS destroy -Rf $rootfs
49 log_must $ZFS create $rootfs
52 function setup_datasets
54 datasets=""
55 for version in $ZFS_ALL_VERSIONS ; do
56 typeset verfs
57 eval verfs=\$ZFS_VERSION_$version
58 typeset current_fs=$rootfs/$verfs
59 typeset current_snap=${current_fs}@snap
60 typeset current_clone=$rootfs/clone$verfs
61 log_must $ZFS create -o version=${version} ${current_fs}
62 log_must $ZFS snapshot ${current_snap}
63 log_must $ZFS clone ${current_snap} ${current_clone}
65 for subversion in $ZFS_ALL_VERSIONS ; do
66 typeset subverfs
67 eval subverfs=\$ZFS_VERSION_$subversion
68 log_must $ZFS create -o version=${subversion} \
69 ${current_fs}/$subverfs
70 done
71 datasets="$datasets ${current_fs}"
72 done
75 log_assert "Executing 'zfs upgrade -r [-V version] filesystem' command succeeds."
76 log_onexit cleanup
78 rootfs=$TESTPOOL/$TESTFS
80 typeset datasets
82 typeset newv
83 for newv in "" "current" $ZFS_VERSION; do
84 setup_datasets
85 for topfs in $datasets ; do
86 if [[ -n $newv ]]; then
87 opt="-V $newv"
88 if [[ $newv == current ]]; then
89 newv=$ZFS_VERSION
91 else
92 newv=$ZFS_VERSION
95 log_must eval '$ZFS upgrade -r $opt $topfs > /dev/null 2>&1'
97 for fs in $($ZFS list -rH -t filesystem -o name $topfs) ; do
98 log_must check_fs_version $fs $newv
99 done
100 done
101 cleanup
102 done
104 log_pass "Executing 'zfs upgrade -r [-V version] filesystem' command succeeds."