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_002_pos 34# 35# DESCRIPTION: 36# The sort functionality in 'zfs list' works as expected. 37# 38# STRATEGY: 39# 1. Using several zfs datasets with names, creation dates, checksum options 40# 2. Sort the datasets by name, checksum options, creation date. 41# 3. Verify that the datasets are sorted correctly. 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2006-09-08) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55# datasets ordered by name 56fs_name="Apple Banana Carrot Orange apple banana carrot" 57vol_name="Apple-vol Banana-vol Carrot-vol Orange-vol apple-vol" 58vol_name="$vol_name banana-vol carrot-vol" 59if is_global_zone ; then 60 snap_name="Apple-vol@snap Apple@snap Banana-vol@snap Banana@snap" 61 snap_name="$snap_name Carrot-vol@snap Carrot@snap Orange-vol@snap Orange@snap" 62 snap_name="$snap_name apple-vol@snap apple@snap banana-vol@snap banana@snap" 63 snap_name="$snap_name carrot-vol@snap carrot@snap" 64else 65 snap_name="Apple@snap Banana@snap" 66 snap_name="$snap_name Carrot@snap Orange@snap" 67 snap_name="$snap_name apple@snap banana@snap" 68 snap_name="$snap_name carrot@snap" 69fi 70 71fs_creation=$fs_name 72vol_creation=$vol_name 73if is_global_zone ; then 74 snap_creation="Apple@snap Apple-vol@snap Banana@snap Banana-vol@snap" 75 snap_creation="$snap_creation Carrot@snap Carrot-vol@snap Orange@snap Orange-vol@snap" 76 snap_creation="$snap_creation apple@snap apple-vol@snap banana@snap banana-vol@snap" 77 snap_creation="$snap_creation carrot@snap carrot-vol@snap" 78else 79 snap_creation="Apple@snap Banana@snap" 80 snap_creation="$snap_creation Carrot@snap Orange@snap" 81 snap_creation="$snap_creation apple@snap banana@snap" 82 snap_creation="$snap_creation carrot@snap" 83fi 84 85# 86# datsets ordered by checksum options (note, Orange, Carrot & Banana have the 87# same checksum options, so ZFS should revert to sorting them alphabetically by 88# name) 89# 90fs_cksum="carrot apple banana Apple Banana Carrot Orange" 91vol_cksum="carrot-vol apple-vol banana-vol Apple-vol Banana-vol" 92vol_cksum="$vol_cksum Carrot-vol Orange-vol" 93snap_cksum=$snap_creation 94 95fs_rev_cksum="carrot apple banana Apple Orange Carrot Banana" 96vol_rev_cksum="carrot-vol apple-vol banana-vol Apple-vol Orange-vol" 97vol_rev_cksum="$vol_rev_cksum Carrot-vol Banana-vol" 98 99log_assert "The sort functionality in 'zfs list' works as expected." 100 101# 102# we must be in the C locale here, as running in other locales 103# will make zfs use that locale's sort order. 104# 105LC_ALL=C; export LC_ALL 106 107# sort by creation 108verify_sort \ 109 "run_unprivileged $ZFS list -H -r -o name -s creation -t filesystem $TESTPOOL/$TESTFS" \ 110 "$fs_creation" "creation date" 111if is_global_zone ; then 112 verify_sort \ 113 "run_unprivileged $ZFS list -H -r -o name -s creation -t volume $TESTPOOL/$TESTFS" \ 114 "$vol_creation" "creation date" 115fi 116verify_sort \ 117 "run_unprivileged $ZFS list -H -r -o name -s creation -t snapshot $TESTPOOL/$TESTFS" \ 118 "$snap_creation" "creation date" 119 120# sort by checksum 121verify_sort \ 122 "run_unprivileged $ZFS list -H -r -o name -s checksum -t filesystem $TESTPOOL/$TESTFS" \ 123 "$fs_cksum" "checksum" 124if is_global_zone ; then 125 verify_sort \ 126 "run_unprivileged $ZFS list -H -r -o name -s checksum -t volume $TESTPOOL/$TESTFS" \ 127 "$vol_cksum" "checksum" 128fi 129verify_sort \ 130 "run_unprivileged $ZFS list -H -r -o name -s checksum -t snapshot $TESTPOOL/$TESTFS" \ 131 "$snap_cksum" "checksum" 132verify_sort \ 133 "run_unprivileged $ZFS list -H -r -o name -S checksum -t snapshot $TESTPOOL/$TESTFS" \ 134 "$snap_cksum" "checksum" 135 136# sort by name 137verify_sort \ 138 "run_unprivileged $ZFS list -H -r -o name -s name -t filesystem $TESTPOOL/$TESTFS" \ 139 "$fs_name" "name" 140if is_global_zone ; then 141 verify_sort \ 142 "run_unprivileged $ZFS list -H -r -o name -s name -t volume $TESTPOOL/$TESTFS" \ 143 "$vol_name" "name" 144fi 145verify_sort \ 146 "run_unprivileged $ZFS list -H -r -o name -s name -t snapshot $TESTPOOL/$TESTFS" \ 147 "$snap_name" "name" 148 149# reverse sort by creation 150verify_reverse_sort \ 151 "run_unprivileged $ZFS list -H -r -o name -S creation -t filesystem $TESTPOOL/$TESTFS" \ 152 "$fs_creation" "creation date" 153if is_global_zone ; then 154 verify_reverse_sort \ 155 "run_unprivileged $ZFS list -H -r -o name -S creation -t volume $TESTPOOL/$TESTFS" \ 156 "$vol_creation" "creation date" 157fi 158verify_reverse_sort \ 159 "run_unprivileged $ZFS list -H -r -o name -S creation -t snapshot $TESTPOOL/$TESTFS" \ 160 "$snap_creation" "creation date" 161 162# reverse sort by checksum 163verify_reverse_sort \ 164 "run_unprivileged $ZFS list -H -r -o name -S checksum -t filesystem $TESTPOOL/$TESTFS" \ 165 "$fs_rev_cksum" "checksum" 166if is_global_zone ; then 167 verify_reverse_sort \ 168 "run_unprivileged $ZFS list -H -r -o name -S checksum -t volume $TESTPOOL/$TESTFS" \ 169 "$vol_rev_cksum" "checksum" 170fi 171 172# reverse sort by name 173verify_reverse_sort \ 174 "run_unprivileged $ZFS list -H -r -o name -S name -t filesystem $TESTPOOL/$TESTFS"\ 175 "$fs_name" "name" 176if is_global_zone ; then 177 verify_reverse_sort \ 178 "run_unprivileged $ZFS list -H -r -o name -S name -t volume $TESTPOOL/$TESTFS"\ 179 "$vol_name" "name" 180fi 181verify_reverse_sort \ 182 "run_unprivileged $ZFS list -H -r -o name -S name -t snapshot $TESTPOOL/$TESTFS"\ 183 "$snap_name" "name" 184 185log_pass "The sort functionality in 'zfs list' works as expected." 186