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_002_pos.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/snapshot/rollback_002_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  # Verify that rollbacks are with respect to the latest snapshot.
  38   38  #
  39   39  # STRATEGY:
↓ open down ↓ 6 lines elided ↑ open up ↑
  46   46  # 7. Perform a rollback
  47   47  # 8. Verify the latest 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.1
  55   55          [[ $? -eq 0 ]] && \
  56      -                log_must $ZFS destroy $SNAPFS.1
       56 +                log_must zfs destroy $SNAPFS.1
  57   57  
  58   58          snapexists $SNAPFS
  59   59          [[ $? -eq 0 ]] && \
  60      -                log_must $ZFS destroy $SNAPFS
       60 +                log_must zfs destroy $SNAPFS
  61   61  
  62   62          [[ -e $TESTDIR ]] && \
  63      -                log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
       63 +                log_must rm -rf $TESTDIR/* > /dev/null 2>&1
  64   64  }
  65   65  
  66   66  log_assert "Verify rollback is with respect to latest snapshot."
  67   67  
  68   68  log_onexit cleanup
  69   69  
  70   70  [[ -n $TESTDIR ]] && \
  71      -    log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
       71 +    log_must rm -rf $TESTDIR/* > /dev/null 2>&1
  72   72  
  73   73  typeset -i COUNT=10
  74   74  
  75   75  log_note "Populate the $TESTDIR directory (prior to first snapshot)"
  76   76  typeset -i i=1
  77   77  while [[ $i -le $COUNT ]]; do
  78      -        log_must $FILE_WRITE -o create -f $TESTDIR/original_file$i \
       78 +        log_must file_write -o create -f $TESTDIR/original_file$i \
  79   79             -b $BLOCKSZ -c $NUM_WRITES -d $i
  80   80  
  81   81          (( i = i + 1 ))
  82   82  done
  83   83  
  84      -log_must $ZFS snapshot $SNAPFS
       84 +log_must zfs snapshot $SNAPFS
  85   85  
  86      -FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
       86 +FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l`
  87   87  if [[ $FILE_COUNT -ne $COUNT ]]; then
  88      -        $LS -Al $SNAPDIR
       88 +        ls -Al $SNAPDIR
  89   89          log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
  90   90  fi
  91   91  
  92   92  log_note "Populate the $TESTDIR directory (prior to second snapshot)"
  93   93  typeset -i i=1
  94   94  while [[ $i -le $COUNT ]]; do
  95      -        log_must $FILE_WRITE -o create -f $TESTDIR/afterfirst_file$i \
       95 +        log_must file_write -o create -f $TESTDIR/afterfirst_file$i \
  96   96             -b $BLOCKSZ -c $NUM_WRITES -d $i
  97   97  
  98   98          (( i = i + 1 ))
  99   99  done
 100  100  
 101      -log_must $ZFS snapshot $SNAPFS.1
      101 +log_must zfs snapshot $SNAPFS.1
 102  102  
 103  103  log_note "Populate the $TESTDIR directory (Post second snapshot)"
 104  104  typeset -i i=1
 105  105  while [[ $i -le $COUNT ]]; do
 106      -        log_must $FILE_WRITE -o create -f $TESTDIR/aftersecond_file$i \
      106 +        log_must file_write -o create -f $TESTDIR/aftersecond_file$i \
 107  107             -b $BLOCKSZ -c $NUM_WRITES -d $i
 108  108  
 109  109          (( i = i + 1 ))
 110  110  done
 111  111  
 112  112  [[ -n $TESTDIR ]] && \
 113      -    log_must $RM -rf $TESTDIR/original_file* > /dev/null 2>&1
      113 +    log_must rm -rf $TESTDIR/original_file* > /dev/null 2>&1
 114  114  
 115  115  #
 116  116  # Now rollback to latest snapshot
 117  117  #
 118      -log_must $ZFS rollback $SNAPFS.1
      118 +log_must zfs rollback $SNAPFS.1
 119  119  
 120      -FILE_COUNT=`$LS -Al $TESTDIR/aftersecond* 2> /dev/null \
 121      -    | $GREP -v "total" | wc -l`
      120 +FILE_COUNT=`ls -Al $TESTDIR/aftersecond* 2> /dev/null \
      121 +    | grep -v "total" | wc -l`
 122  122  if [[ $FILE_COUNT -ne 0 ]]; then
 123      -        $LS -Al $TESTDIR
      123 +        ls -Al $TESTDIR
 124  124          log_fail "$TESTDIR contains $FILE_COUNT aftersecond* files(s)."
 125  125  fi
 126  126  
 127      -FILE_COUNT=`$LS -Al $TESTDIR/original* $TESTDIR/afterfirst*| $GREP -v "total" | wc -l`
      127 +FILE_COUNT=`ls -Al $TESTDIR/original* $TESTDIR/afterfirst*| grep -v "total" | wc -l`
 128  128  if [[ $FILE_COUNT -ne 20 ]]; then
 129      -        $LS -Al $TESTDIR
      129 +        ls -Al $TESTDIR
 130  130          log_fail "$TESTDIR contains $FILE_COUNT original* files(s)."
 131  131  fi
 132  132  
 133  133  log_pass "The rollback to the latest snapshot succeeded."
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX