Print this page
Missed zlook, sync with master
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
   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 . $STF_SUITE/include/libtest.shlib
  17 . $STF_SUITE/tests/functional/casenorm/casenorm.cfg
  18 
  19 function create_testfs
  20 {
  21         typeset opts=$1
  22 
  23         $RM -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
  24         $MKDIR -p $TESTDIR || log_unresolved Could not create $TESTDIR
  25 
  26         log_must $ZFS create $opts $TESTPOOL/$TESTFS
  27         log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
  28 }
  29 
  30 function destroy_testfs
  31 {
  32         if datasetexists $TESTPOOL/$TESTFS ; then
  33                 log_must $ZFS destroy -f $TESTPOOL/$TESTFS
  34                 $RM -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
  35         fi
  36 }
  37 
  38 function create_file
  39 {
  40         typeset name=$TESTDIR/$1
  41 
  42         $ECHO $name > $name
  43 }
  44 
  45 function delete_file
  46 {
  47         typeset name=$TESTDIR/$1
  48 
  49         $RM $name >/dev/null 2>&1
  50 
  51         if [[ $? -ne 0 ]] ; then
  52                 return 1
  53         fi
  54 
  55         if [[ -f $name ]] ; then
  56                 return 2
  57         fi
  58 }
  59 
  60 function lookup_file
  61 {
  62         typeset name=$1
  63 
  64         $ZLOOK -l $TESTDIR $name >/dev/null 2>&1
  65 }
  66 
  67 function lookup_file_ci
  68 {
  69         typeset name=$1
  70 
  71         $ZLOOK -il $TESTDIR $name >/dev/null 2>&1
  72 }
  73 
  74 function lookup_any
  75 {
  76         for name in $NAMES_ALL ; do
  77                 lookup_file $name
  78                 if [[ $? -eq 0 ]] ; then
  79                         return 0
  80                 fi
  81         done
  82 
  83         return 1
  84 }
  85 
  86 function switch_norm
  87 {
  88         typeset norm=$(get_norm $1)
  89 
  90         if [[ $norm == "C" ]] ; then
  91                 print "D"


   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 
  23 function 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 
  34 function 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 
  42 function create_file
  43 {
  44         typeset name=$TESTDIR/$1
  45 
  46         echo $name > $name
  47 }
  48 
  49 function 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 
  64 function lookup_file
  65 {
  66         typeset name=$1
  67 
  68         zlook -l $TESTDIR $name >/dev/null 2>&1
  69 }
  70 
  71 function lookup_file_ci
  72 {
  73         typeset name=$1
  74 
  75         zlook -il $TESTDIR $name >/dev/null 2>&1
  76 }
  77 
  78 function lookup_any
  79 {
  80         for name in $NAMES_ALL ; do
  81                 lookup_file $name
  82                 if [[ $? -eq 0 ]] ; then
  83                         return 0
  84                 fi
  85         done
  86 
  87         return 1
  88 }
  89 
  90 function switch_norm
  91 {
  92         typeset norm=$(get_norm $1)
  93 
  94         if [[ $norm == "C" ]] ; then
  95                 print "D"