Print this page
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>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/zfs-tests/tests/functional/devices/devices_common.kshlib
          +++ new/usr/src/test/zfs-tests/tests/functional/devices/devices_common.kshlib
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18  #
  19   19  # CDDL HEADER END
  20   20  #
  21   21  
  22   22  #
  23   23  # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24  # Use is subject to license terms.
  25   25  #
  26   26  
  27   27  #
  28      -# Copyright (c) 2013 by Delphix. All rights reserved.
       28 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  29   29  #
  30   30  
  31   31  . $STF_SUITE/tests/functional/devices/devices.cfg
  32   32  . $STF_SUITE/include/libtest.shlib
  33   33  
  34   34  #
  35   35  # Create block file or charactor file according to parameter.
  36   36  #
  37   37  # $1 device file type
  38   38  # $2 file name
  39   39  #
  40   40  function create_dev_file
  41   41  {
  42   42          typeset filetype=$1
  43   43          typeset filename=$2
  44   44  
  45   45          case $filetype in
  46   46                  b)
  47      -                        devtype=$($DF -n / | $AWK '{print $3}')
       47 +                        devtype=$(df -n / | awk '{print $3}')
  48   48                          case $devtype in
  49   49                                  zfs)
  50      -                                        rootpool=$($DF / | \
  51      -                                                $AWK '{print $2}')
       50 +                                        rootpool=$(df / | \
       51 +                                                awk '{print $2}')
  52   52                                          rootpool=${rootpool#\(}
  53   53                                          rootpool=${rootpool%%/*}
  54   54  
  55   55                                          devstr=$(get_disklist $rootpool)
  56      -                                        devstr=$($ECHO "$devstr" | \
  57      -                                                $AWK '{print $1}')
       56 +                                        devstr=$(echo "$devstr" | \
       57 +                                                awk '{print $1}')
  58   58                                          [[ -z $devstr ]] && \
  59   59                                                  log_fail "Can not get block device file."
  60   60                                          devstr=/dev/dsk/${devstr}
  61   61                                          ;;
  62   62                                  ufs)
  63   63                          #
  64   64                          # Get the existing block device file in current system.
  65   65                          # And bring out the first one.
  66   66                          #
  67      -                                        devstr=$($DF -lhF ufs | \
  68      -                                                $GREP "^/dev/dsk" | \
  69      -                                                $AWK '{print $1}')
  70      -                                        devstr=$($ECHO "$devstr" | \
  71      -                                                $AWK '{print $1}')
       67 +                                        devstr=$(df -lhF ufs | \
       68 +                                                grep "^/dev/dsk" | \
       69 +                                                awk '{print $1}')
       70 +                                        devstr=$(echo "$devstr" | \
       71 +                                                awk '{print $1}')
  72   72                                          [[ -z $devstr ]] && \
  73   73                                                  log_fail "Can not get block device file."
  74   74                                          ;;
  75   75                                  *)
  76   76                                          log_unsupported "Unsupported fstype " \
  77   77                                                  "for / ($devtype)," \
  78   78                                                  "only ufs|zfs is supported."
  79   79                                          ;;
  80   80                          esac
  81   81  
  82   82                          #
  83   83                          # Get the device file information. i.e:
  84   84                          # /dev/dsk/c0t0d0s0:      block special (28/768)
  85   85                          #
  86      -                        devstr=$($FILE $devstr)
       86 +                        devstr=$(file $devstr)
  87   87  
  88   88                          #
  89   89                          # Bring out major and minor number.
  90   90                          #
  91   91                          major=${devstr##*\(}
  92   92                          major=${major%%/*}
  93   93                          minor=${devstr##*/}
  94   94                          minor=${minor%\)}
  95   95  
  96      -                        log_must $MKNOD $filename b $major $minor
       96 +                        log_must mknod $filename b $major $minor
  97   97                          ;;
  98   98                  c)
  99   99                          #
 100  100                          # Create device file '/dev/null'
 101  101                          #
 102      -                        log_must $MKNOD $filename c $($GETMAJOR mm) 2
      102 +                        log_must mknod $filename c $(getmajor mm) 2
 103  103                          ;;
 104  104                  *)
 105  105                          log_fail "'$filetype' is wrong."
 106  106                          ;;
 107  107          esac
 108  108  
 109  109          return 0
 110  110  }
 111  111  
 112  112  function cleanup
 113  113  {
 114      -        log_must $ZFS set devices=on $TESTPOOL/$TESTFS
 115      -        log_must $RM -f $TESTDIR/$TESTFILE1
 116      -        log_must $RM -f $TESTDIR/$TESTFILE2
 117      -        log_must $RM -f $TESTDIR/$TESTFILE1.out
 118      -        log_must $RM -f $TESTDIR/$TESTFILE2.out
      114 +        log_must zfs set devices=on $TESTPOOL/$TESTFS
      115 +        log_must rm -f $TESTDIR/$TESTFILE1
      116 +        log_must rm -f $TESTDIR/$TESTFILE2
      117 +        log_must rm -f $TESTDIR/$TESTFILE1.out
      118 +        log_must rm -f $TESTDIR/$TESTFILE2.out
 119  119  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX