#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2014, 2016 by Delphix. All rights reserved.
#
set -A VALID_NAME_CHAR a b c d e f g h i j k l m n o p q r s t u v w x y z \
0 1 2 3 4 5 6 7 8 9 ':' '-' '.' '_'
set -A INVALID_NAME_CHAR A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
'`' '~' '!' '@' '#' '$' '%' '^' '&' '(' ')' '+' '=' '|' "\\" '{' '[' ']' \
'}' ';' '"' '<' ',' '>' '?' '/' ' '
#
# Firstly, set the property value to dataset. Then checking if the property
# value is equal with the expected value, according to the expected result.
#
# $1 property value
# $2 property name
# $3 dataset
# $4 expected result
#
function set_n_check_prop
{
typeset expect_value=$1
typeset prop=$2
typeset dataset=$3
typeset expect_result=${4:-true}
typeset old_value=""
typeset cur_value=""
if [[ $expect_result == true ]]; then
log_fail "property or dataset isn't defined."
expect_value="gzip"
fi
'$cur_value' is not expected."
elif [[ $cur_value != $expect_value ]]; then
log_fail "The '$dataset' '$prop' value '$cur_value' \
does not equal the expected value '$expect_value'."
fi
;;
* )
if [[ $cur_value != $expect_value ]]; then
log_fail "The '$dataset' '$prop' value '$cur_value' \
does not equal the expected value '$expect_value'."
fi
;;
esac
else
then
log_fail "The '$dataset' '$prop' value '$cur_value' \
should equal with '$old_value'."
fi
fi
}
#
# Cleanup all the user properties of the pool and the dataset reside it.
#
# $1 pool name
#
function cleanup_user_prop
{
typeset pool=$1
typeset user_prop
typeset prop
for prop in $user_prop; do
done
done
}
#
# Random select charactor from the specified charactor set and combine into a
# random string
#
# $1 character set name
# $2 String length
#
function random_string
{
typeset char_set=${1:-VALID_NAME_CHAR}
typeset -i len=${2:-5}
eval typeset -i count=\${#$char_set[@]}
# No consumers want an empty string.
typeset str
typeset -i i=0
typeset -i ind
((i += 1))
done
echo "$str"
}
#
# Get vaild user defined property name
#
# $1 user defined property name length
#
function valid_user_property
{
typeset -i sumlen=${1:-10}
typeset -i len
while true; do
continue
fi
break
done
while true; do
continue
fi
break
done
echo "${part1}:${part2}"
}
#
# Get invaild user defined property name
#
# $1 user defined property name length
#
function invalid_user_property
{
typeset -i sumlen=${1:-10}
typeset -i len
while true; do
# Avoid $part1 is *:* and $part2 is "=*"
continue
fi
break
done
echo "${part1}${part2}"
}
#
# Get user property value
#
# $1 user defined property name length
#
function user_property_value
{
typeset -i len=${1:-100}
typeset value=$(random_string ALL_CHAR $len)
echo "$value"
}
#
# Check if the user property is identical to the expected value.
#
# $1 dataset
# $2 user property
# $3 expected value
#
function check_user_prop
{
typeset dtst=$1
typeset user_prop="$2"
typeset expect_value="$3"
return 0
else
return 1
fi
}
#
# Get source of the dataset
#
function get_source
{
typeset prop=$1
typeset dataset=$2
typeset source
if (($? != 0)); then
fi
echo "$source"
}