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/quota/quota.kshlib
          +++ new/usr/src/test/zfs-tests/tests/functional/quota/quota.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/quota/quota.cfg
  32   32  
  33   33  # BLOCK_SIZE, QUOTA_VALUE and TOLERANCE set in quota.cfg
  34   34  readonly EDQUOT=49
  35   35  
  36   36  #
  37   37  # Function to fill the quota of a zfs filesystem
  38   38  #
  39   39  # $1 - The File system or container to fill.
  40   40  # $2 - The mountpoint to use.
  41   41  #
  42   42  function fill_quota
  43   43  {
  44   44          typeset FILESYSTEM="$1"
  45   45          typeset MNTPT="$2"
  46   46  
  47      -        log_must $ZFS set quota=$QUOTA_VALUE $FILESYSTEM
       47 +        log_must zfs set quota=$QUOTA_VALUE $FILESYSTEM
  48   48  
  49   49          typeset -i write_size=0
  50   50          (( write_size = 2 * QUOTA_VALUE ))
  51   51  
  52   52          typeset -i zret=0
  53      -        $FILE_WRITE -o create -f $MNTPT/$TESTFILE1 -b $BLOCK_SIZE \
       53 +        file_write -o create -f $MNTPT/$TESTFILE1 -b $BLOCK_SIZE \
  54   54                   -c $write_size -d 0
  55   55          zret=$?
  56   56          [[ $zret -ne EDQUOT ]] && \
  57   57              log_fail "Returned error code: $zret. Expected: $EDQUOT."
  58   58  
  59      -        typeset -i file_size=`$LS -ls $MNTPT/$TESTFILE1 | $AWK '{ print $1 }'`
       59 +        typeset -i file_size=`ls -ls $MNTPT/$TESTFILE1 | awk '{ print $1 }'`
  60   60          typeset -i limit=0
  61   61          (( file_size = file_size * 512 ))
  62   62          (( limit = QUOTA_VALUE + TOLERANCE ))
  63   63          (( file_size > limit )) && \
  64   64              log_fail "File was created larger than the quota value, aborting!!!"
  65   65          return 0
  66   66  }
  67   67  
  68   68  #
  69   69  # Function attempts to write another file in a ZFS filesystem
↓ open down ↓ 5 lines elided ↑ open up ↑
  75   75          typeset MNTPT="$2"
  76   76  
  77   77          log_must fill_quota $FILESYSTEM $MNTPT
  78   78          typeset -i write_size=0
  79   79          (( write_size = 2 * QUOTA_VALUE ))
  80   80          typeset -i zret=0
  81   81          #
  82   82          # Writing a file without API to access return code
  83   83          #
  84   84          log_note "Creating a file in a FS that has already exceeded its quota"
  85      -        $FILE_WRITE -o create -f $MNTPT/$TESTFILE2 \
       85 +        file_write -o create -f $MNTPT/$TESTFILE2 \
  86   86                  -b $BLOCK_SIZE -c $write_size -d 0
  87   87          zret=$?
  88   88          [[ $zret -ne EDQUOT ]] && \
  89   89              log_fail "Returned error code: $zret. Expected: EDQUOT."
  90   90          return 0
  91   91  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX