1#!/usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/tests/cli_user/zfs_list/zfs_list.kshlib 27. $STF_SUITE/tests/cli_user/cli_user.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: zfs_list_005_pos 34# 35# DESCRIPTION: 36# Verify 'zfs list' evaluate multiple '-s' options from left to right 37# in decreasing order of importance. 38# 39# STRATEGY: 40# 1. Setting user property f:color for filesystem and volume. 41# 2. Setting user property f:amount for filesystem and volume. 42# 3. Setting reservation for filesystem and volume 43# 3. Verify 'zfs list' evaluated multiple -s options from left to right. 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2008-07-23) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55verify_runnable "both" 56 57log_assert "Verify 'zfs list' evaluate multiple '-s' options " \ 58 "from left to right in decreasing order of importance." 59 60COLOR="red yellow green blue red yellow white" 61AMOUNT="0217 812 0217 0781 7 1364 687" 62RESERVATION="2048K 1024 2048K 512K 16M 3072 128K" 63 64basefs=$TESTPOOL/$TESTFS 65typeset -i n=0 66for ds in $DATASETS ; do 67 color=$($ECHO $COLOR | $AWK '{print $1}') 68 log_must $ZFS set f:color=$color $basefs/$ds 69 if is_global_zone ; then 70 log_must $ZFS set f:color=$color $basefs/${ds}-vol 71 fi 72 eval COLOR=\${COLOR#$color } 73 74 amount=$($ECHO $AMOUNT | $AWK '{print $1}') 75 log_must $ZFS set f:amount=$amount $basefs/$ds 76 if is_global_zone ; then 77 log_must $ZFS set f:amount=$amount $basefs/${ds}-vol 78 fi 79 eval AMOUNT=\${AMOUNT#$amount } 80 81 reserv=$($ECHO $RESERVATION | $AWK '{print $1}') 82 log_must $ZFS set reservation=$reserv $basefs/$ds 83 if is_global_zone ; then 84 log_must $ZFS set reservation=$reserv $basefs/${ds}-vol 85 fi 86 eval RESERVATION=\${RESERVATION#$reserv } 87done 88 89# 90# we must be in the C locale here, as running in other locales 91# will make zfs use that locale's sort order. 92# 93LC_ALL=C; export LC_ALL 94 95fs_color_amount="Orange Carrot Apple apple carrot banana Banana" 96fs_amount_color="Carrot Apple Orange banana carrot apple Banana" 97fs_color_reserv="Orange Carrot Apple apple carrot Banana banana" 98fs_reserv_color="Banana banana carrot Orange Carrot Apple apple" 99fs_reserv_amount_color="Banana banana carrot Orange Carrot Apple apple" 100 101vol_color_amount="Orange-vol Carrot-vol Apple-vol apple-vol carrot-vol" 102vol_color_amount="$vol_color_amount banana-vol Banana-vol" 103 104vol_amount_color="Carrot-vol Apple-vol Orange-vol banana-vol carrot-vol" 105vol_amount_color="$vol_amount_color apple-vol Banana-vol" 106 107vol_color_reserv="Orange-vol Carrot-vol Apple-vol apple-vol carrot-vol" 108vol_color_reserv="$vol_color_reserv Banana-vol banana-vol" 109 110vol_reserv_color="Banana-vol banana-vol carrot-vol Orange-vol Carrot-vol" 111vol_reserv_color="$vol_reserv_color Apple-vol apple-vol" 112 113vol_reserv_amount_color="Banana-vol banana-vol carrot-vol Orange-vol Carrot-vol" 114vol_reserv_amount_color="$vol_reserv_amount_color Apple-vol apple-vol" 115 116if is_global_zone ; then 117 snap_list="Apple@snap Apple-vol@snap Banana@snap Banana-vol@snap" 118 snap_list="$snap_list Carrot@snap Carrot-vol@snap Orange@snap Orange-vol@snap" 119 snap_list="$snap_list apple@snap apple-vol@snap banana@snap banana-vol@snap" 120 snap_list="$snap_list carrot@snap carrot-vol@snap" 121else 122 snap_list="Apple@snap Banana@snap" 123 snap_list="$snap_list Carrot@snap Orange@snap" 124 snap_list="$snap_list apple@snap banana@snap" 125 snap_list="$snap_list carrot@snap" 126fi 127# Sort by color,amount 128verify_sort \ 129 "run_unprivileged $ZFS list -H -r -o name -s f:color -s f:amount -t filesystem $basefs" \ 130 "$fs_color_amount" "f:color,f:amount" 131if is_global_zone ; then 132 verify_sort \ 133 "run_unprivileged $ZFS list -H -r -o name -s f:color -s f:amount -t volume $basefs" \ 134 "$vol_color_amount" "f:color,f:amount" 135fi 136# Sort by amount,color 137verify_sort \ 138 "run_unprivileged $ZFS list -H -r -o name -s f:amount -s f:color -t filesystem $basefs" \ 139 "$fs_amount_color" "f:amount,f:color" 140if is_global_zone ; then 141 verify_sort \ 142 "run_unprivileged $ZFS list -H -r -o name -s f:amount -s f:color -t volume $basefs" \ 143 "$vol_amount_color" "f:amount,f:color" 144fi 145 146# Sort by color reservation 147verify_sort \ 148 "run_unprivileged $ZFS list -H -r -o name -s f:color -s reserv -t filesystem $basefs" \ 149 "$fs_color_reserv" "f:color,reserv" 150if is_global_zone ; then 151 verify_sort \ 152 "run_unprivileged $ZFS list -H -r -o name -s f:color -s reserv -t volume $basefs" \ 153 "$vol_color_reserv" "f:color,reserv" 154fi 155# Sort by reserv, color 156verify_sort \ 157 "run_unprivileged $ZFS list -H -r -o name -s reserv -s f:color -t filesystem $basefs" \ 158 "$fs_reserv_color" "reserv,f:color" 159if is_global_zone ; then 160 verify_sort \ 161 "run_unprivileged $ZFS list -H -r -o name -s reserv -s f:color -t volume $basefs" \ 162 "$vol_reserv_color" "reserv,f:color" 163fi 164 165# Sort by reservation, amount, color 166verify_sort \ 167 "run_unprivileged $ZFS list -H -r -o name -s reserv -s reserv -s f:amount -s f:color -t filesystem $basefs" \ 168 "$fs_reserv_amount_color" "reserv,:amount,f:color" 169if is_global_zone ; then 170 verify_sort \ 171 "run_unprivileged $ZFS list -H -r -o name -s reserv -s f:amount -s f:color -t volume $basefs" \ 172 "$vol_reserv_amount_color" "reserv,:amount,f:color" 173fi 174# User property and reservation was not stored in snapshot 175verify_sort \ 176 "run_unprivileged $ZFS list -H -r -o name -s f:amount -s f:color -t snapshot $basefs" \ 177 "$snap_list" "f:amount,f:color" 178verify_sort \ 179 "run_unprivileged $ZFS list -H -r -o name -s f:color -s f:amount -t snapshot $basefs" \ 180 "$snap_list" "f:color,f:amount" 181verify_sort \ 182 "run_unprivileged $ZFS list -H -r -o name -s f:color -s reserv -t snapshot $basefs" \ 183 "$snap_list" "f:color,reservation" 184verify_sort \ 185 "run_unprivileged $ZFS list -H -r -o name -s reserv -s f:color -t snapshot $basefs" \ 186 "$snap_list" "reserv,f:color" 187verify_sort \ 188 "run_unprivileged $ZFS list -H -r -o name -s reserv -s f:amount -s f:color -t snapshot $basefs" \ 189 "$snap_list" "reservation,f:color,f:amount" 190 191log_pass "Verify 'zfs list' evaluate multiple '-s' options " \ 192 "from left to right in decreasing order of importance." 193