Print this page
12181 zvol swap tests should avoid grep -w


   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.

  29 #
  30 
  31 . $STF_SUITE/include/libtest.shlib
  32 . $STF_SUITE/tests/functional/zvol/zvol.cfg
  33 
  34 #
  35 # Create a simple zvol volume
  36 #
  37 # Where disk_device: is the name of the disk to be used
  38 #       volume_size: is the size of the volume, e.g. 2G
  39 #
  40 function default_zvol_setup # disk_device volume_size
  41 {
  42         typeset disk=$1
  43         typeset size=$2
  44         typeset savedumpdev
  45         typeset -i output
  46 
  47         create_pool $TESTPOOL "$disk"
  48 


 116         typeset volume=$1
 117 
 118         if [[ -z $volume ]] ; then
 119                 log_note "No volume specified."
 120                 return 1
 121         fi
 122 
 123         zdb -dddd $volume 2 | grep "dumpsize" > /dev/null 2>&1
 124         return $?
 125 }
 126 
 127 function is_swap_inuse
 128 {
 129         typeset device=$1
 130 
 131         if [[ -z $device ]] ; then
 132                 log_note "No device specified."
 133                 return 1
 134         fi
 135 
 136         swap -l | grep -w $device > /dev/null 2>&1

 137         return $?
 138 }


   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  29 # Copyright 2020 Joyent, Inc.
  30 #
  31 
  32 . $STF_SUITE/include/libtest.shlib
  33 . $STF_SUITE/tests/functional/zvol/zvol.cfg
  34 
  35 #
  36 # Create a simple zvol volume
  37 #
  38 # Where disk_device: is the name of the disk to be used
  39 #       volume_size: is the size of the volume, e.g. 2G
  40 #
  41 function default_zvol_setup # disk_device volume_size
  42 {
  43         typeset disk=$1
  44         typeset size=$2
  45         typeset savedumpdev
  46         typeset -i output
  47 
  48         create_pool $TESTPOOL "$disk"
  49 


 117         typeset volume=$1
 118 
 119         if [[ -z $volume ]] ; then
 120                 log_note "No volume specified."
 121                 return 1
 122         fi
 123 
 124         zdb -dddd $volume 2 | grep "dumpsize" > /dev/null 2>&1
 125         return $?
 126 }
 127 
 128 function is_swap_inuse
 129 {
 130         typeset device=$1
 131 
 132         if [[ -z $device ]] ; then
 133                 log_note "No device specified."
 134                 return 1
 135         fi
 136 
 137         swap -l | awk 'NR > 1 { print $1 }' | \
 138             grep "^$device\$" > /dev/null 2>&1
 139         return $?
 140 }