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/snapshot/rollback_001_pos.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24   24  # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  25   25  # Use is subject to license terms.
  26   26  #
  27   27  
  28   28  #
  29      -# Copyright (c) 2013 by Delphix. All rights reserved.
       29 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  30   30  #
  31   31  
  32   32  . $STF_SUITE/include/libtest.shlib
  33   33  . $STF_SUITE/tests/functional/snapshot/snapshot.cfg
  34   34  
  35   35  #
  36   36  # DESCRIPTION:
  37   37  # Populate a file system and take a snapshot. Add some more files to the
  38   38  # file system and rollback to the last snapshot. Verify no post snapshot
  39   39  # file exist.
↓ open down ↓ 6 lines elided ↑ open up ↑
  46   46  # 5. Perform a rollback
  47   47  # 6. Verify the snapshot and file system agree
  48   48  #
  49   49  
  50   50  verify_runnable "both"
  51   51  
  52   52  function cleanup
  53   53  {
  54   54          snapexists $SNAPFS
  55   55          [[ $? -eq 0 ]] && \
  56      -                log_must $ZFS destroy $SNAPFS
       56 +                log_must zfs destroy $SNAPFS
  57   57  
  58   58          [[ -e $TESTDIR ]] && \
  59      -                log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
       59 +                log_must rm -rf $TESTDIR/* > /dev/null 2>&1
  60   60  }
  61   61  
  62   62  log_assert "Verify that a rollback to a previous snapshot succeeds."
  63   63  
  64   64  log_onexit cleanup
  65   65  
  66   66  [[ -n $TESTDIR ]] && \
  67      -    log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
       67 +    log_must rm -rf $TESTDIR/* > /dev/null 2>&1
  68   68  
  69   69  typeset -i COUNT=10
  70   70  
  71   71  log_note "Populate the $TESTDIR directory (prior to snapshot)"
  72   72  typeset -i i=1
  73   73  while [[ $i -le $COUNT ]]; do
  74      -        log_must $FILE_WRITE -o create -f $TESTDIR/before_file$i \
       74 +        log_must file_write -o create -f $TESTDIR/before_file$i \
  75   75             -b $BLOCKSZ -c $NUM_WRITES -d $i
  76   76  
  77   77          (( i = i + 1 ))
  78   78  done
  79   79  
  80      -log_must $ZFS snapshot $SNAPFS
       80 +log_must zfs snapshot $SNAPFS
  81   81  
  82      -FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
       82 +FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l`
  83   83  if [[ $FILE_COUNT -ne $COUNT ]]; then
  84      -        $LS -Al $SNAPDIR
       84 +        ls -Al $SNAPDIR
  85   85          log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
  86   86  fi
  87   87  
  88   88  log_note "Populate the $TESTDIR directory (post snapshot)"
  89   89  typeset -i i=1
  90   90  while [[ $i -le $COUNT ]]; do
  91      -        log_must $FILE_WRITE -o create -f $TESTDIR/after_file$i \
       91 +        log_must file_write -o create -f $TESTDIR/after_file$i \
  92   92             -b $BLOCKSZ -c $NUM_WRITES -d $i
  93   93  
  94   94          (( i = i + 1 ))
  95   95  done
  96   96  
  97   97  #
  98   98  # Now rollback to latest snapshot
  99   99  #
 100      -log_must $ZFS rollback $SNAPFS
      100 +log_must zfs rollback $SNAPFS
 101  101  
 102      -FILE_COUNT=`$LS -Al $TESTDIR/after* 2> /dev/null | $GREP -v "total" | wc -l`
      102 +FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l`
 103  103  if [[ $FILE_COUNT -ne 0 ]]; then
 104      -        $LS -Al $TESTDIR
      104 +        ls -Al $TESTDIR
 105  105          log_fail "$TESTDIR contains $FILE_COUNT after* files(s)."
 106  106  fi
 107  107  
 108      -FILE_COUNT=`$LS -Al $TESTDIR/before* 2> /dev/null \
 109      -    | $GREP -v "total" | wc -l`
      108 +FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \
      109 +    | grep -v "total" | wc -l`
 110  110  if [[ $FILE_COUNT -ne $COUNT ]]; then
 111      -        $LS -Al $TESTDIR
      111 +        ls -Al $TESTDIR
 112  112          log_fail "$TESTDIR contains $FILE_COUNT before* files(s)."
 113  113  fi
 114  114  
 115  115  log_pass "The rollback operation succeeded."
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX