1# 2# This file and its contents are supplied under the terms of the 3# Common Development and Distribution License ("CDDL"), version 1.0. 4# You may only use this file in accordance with the terms of version 5# 1.0 of the CDDL. 6# 7# A full copy of the text of the CDDL should have accompanied this 8# source. A copy of the CDDL is also available via the Internet at 9# http://www.illumos.org/license/CDDL. 10# 11 12# 13# Copyright 2015 Nexenta Systems, Inc. All rights reserved. 14# 15 16# 17# Copyright (c) 2016 by Delphix. All rights reserved. 18# 19 20. $STF_SUITE/include/libtest.shlib 21. $STF_SUITE/tests/functional/casenorm/casenorm.cfg 22 23function create_testfs 24{ 25 typeset opts=$1 26 27 rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR 28 mkdir -p $TESTDIR || log_unresolved Could not create $TESTDIR 29 30 log_must zfs create $opts $TESTPOOL/$TESTFS 31 log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 32} 33 34function destroy_testfs 35{ 36 if datasetexists $TESTPOOL/$TESTFS ; then 37 log_must zfs destroy -f $TESTPOOL/$TESTFS 38 rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR 39 fi 40} 41 42function create_file 43{ 44 typeset name=$TESTDIR/$1 45 46 echo $name > $name 47} 48 49function delete_file 50{ 51 typeset name=$TESTDIR/$1 52 53 rm $name >/dev/null 2>&1 54 55 if [[ $? -ne 0 ]] ; then 56 return 1 57 fi 58 59 if [[ -f $name ]] ; then 60 return 2 61 fi 62} 63 64function lookup_file 65{ 66 typeset name=$1 67 68 if is_illumos; then 69 zlook -l $TESTDIR $name >/dev/null 2>&1 70 else 71 test -f "${TESTDIR}/${name}" >/dev/null 2>&1 72 fi 73} 74 75function lookup_file_ci 76{ 77 typeset name=$1 78 79 if is_illumos; then 80 zlook -il $TESTDIR $name >/dev/null 2>&1 81 else 82 test -f "${TESTDIR}/${name}" >/dev/null 2>&1 83 fi 84} 85 86function lookup_any 87{ 88 for name in $NAMES_ALL ; do 89 lookup_file $name 90 if [[ $? -eq 0 ]] ; then 91 return 0 92 fi 93 done 94 95 return 1 96} 97 98function switch_norm 99{ 100 typeset norm=$(get_norm $1) 101 102 if [[ $norm == "C" ]] ; then 103 print "D" 104 else 105 print "C" 106 fi 107} 108 109function get_norm 110{ 111 if [[ "${NAMES_C#*$1}" != "${NAMES_C}" ]] ; then 112 print "C" 113 elif [[ "${NAMES_D#*$1}" != "${NAMES_D}" ]] ; then 114 print "D" 115 else 116 return 1 117 fi 118} 119 120function get_case 121{ 122 if [[ ${NAMES_UPPER#*$1} != ${NAMES_UPPER} ]] ; then 123 print "UPPER" 124 elif [[ ${NAMES_LOWER#*$1} != ${NAMES_LOWER} ]] ; then 125 print "LOWER" 126 elif [[ ${NAMES_ORIG#*$1} != ${NAMES_ORIG} ]] ; then 127 print "ORIG" 128 else 129 return 1 130 fi 131} 132