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