4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
34 # A function that verifies sort order. It takes as input
35 # a command, which gets executed. We then iterate over the results
36 # comparing that the sort order passed in via the list
38 function verify_sort { # command list name
40 # now verify we've sorted by creation date:
48 # run the command to verify that it works
49 log_must eval "$CMD > /dev/null"
51 # Now check the sort order
52 for dataset in $( $CMD )
54 ACTUAL=$(basename $dataset)
55 if [ "$dataset" != "$TESTPOOL/$TESTFS" ]
57 EXPECTED=$(echo $list | awk "{print \$$index}")
58 if [ "$ACTUAL" != "$EXPECTED" ]
61 "'$ACTUAL' does not equal '$EXPECTED'"
62 log_fail "ERROR: Sort by $name fails."
69 # finally check to see if we have the expected number of elements
70 if [ $index -ne $(echo $list | awk '{print split($0,arr)+1}') ]
72 log_fail "Warning: " \
73 "unexpected number of filesystems found in list output!"
77 # A function that verifies reverse sort order. It takes as input
78 # a command, which gets executed. We then iterate over the results
79 # comparing that the sort order passed in via the list
81 function verify_reverse_sort { # command list name
87 # set our index to the be number of elements in the list
88 typeset -i index=$(echo $list | awk '{print split($0,arr)}')
90 log_note "Checking reverse sort by '$name'," \
91 "expecting the reverse of '$list'"
92 log_must eval "$CMD > /dev/null"
94 for dataset in $( $CMD )
96 ACTUAL=$(basename $dataset)
97 if [ "$dataset" != "$TESTPOOL/$TESTFS" ]
99 EXPECTED=$(echo $list | awk "{print \$$index}")
100 if [ "$ACTUAL" != "$EXPECTED" ]
102 log_note "Warning:" \
103 "'$ACTUAL' does not equal to" \
104 "the reverse of '$EXPECTED'"
105 log_fail "ERROR: Reverse sort by '$name' fails."
108 ((index = index - 1))
112 # finally check to see if we have the expected number of elements
115 log_fail "Warning: " \
116 "unexpected number of filesystems found in list output!"