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/mount/umountall_001.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/mount/umountall_001.ksh
↓ open down ↓ 4 lines elided ↑ open up ↑
   5    5  # Common Development and Distribution License ("CDDL"), version 1.0.
   6    6  # You may only use this file in accordance with the terms of version
   7    7  # 1.0 of the CDDL.
   8    8  #
   9    9  # A full copy of the text of the CDDL should have accompanied this
  10   10  # source.  A copy of the CDDL is also available via the Internet at
  11   11  # http://www.illumos.org/license/CDDL.
  12   12  #
  13   13  
  14   14  #
  15      -# Copyright (c) 2013 by Delphix. All rights reserved.
       15 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  16   16  #
  17   17  
  18   18  . $STF_SUITE/include/libtest.shlib
  19   19  
  20   20  #
  21   21  # DESCRIPTION:
  22   22  # There are myriad problems associated with trying to test umountall in a way
  23   23  # that works reliable across different systems. Some filesystems won't unmount
  24   24  # because they're busy. Some won't remount because they were legacy mounts in
  25   25  # the first place. etc...
  26   26  # Make a best approximation by calling umountall with the -n option, and verify
  27   27  # that the list of things it would try to unmout makes sense.
  28   28  #
  29   29  # STRATEGY:
  30   30  # 1. Make a list of file systems umountall is known to ignore.
  31   31  # 2. Append all ZFS file systems on this system.
  32   32  # 3. Run umountall -n and verify the file systems it reports are in the list.
  33   33  #
  34   34  
  35      -log_must $ZFS mount -a
       35 +log_must zfs mount -a
  36   36  for fs in 1 2 3 ; do
  37   37          log_must mounted $TESTPOOL/$TESTFS.$fs
  38   38  done
  39   39  
  40   40  # This is the list we check the output of umountall -n against. We seed it
  41   41  # with these values because umountall will ignore them, and they're possible
  42   42  # (though most are improbable) ZFS filesystem mountpoints.
  43   43  zfs_list="/ /lib /sbin /tmp /usr /var /var/adm /var/run"
  44   44  
  45   45  # Append our ZFS filesystems to the list, not worrying about duplicates.
  46      -for fs in $($MOUNT -p | $AWK '{if ($4 == "zfs") print $3}'); do
       46 +for fs in $(mount -p | awk '{if ($4 == "zfs") print $3}'); do
  47   47          zfs_list="$zfs_list $fs"
  48   48  done
  49   49  
  50   50  fs=''
  51      -for fs in $($UMOUNTALL -n -F zfs 2>&1 | $AWK '{print $2}'); do
       51 +for fs in $(umountall -n -F zfs 2>&1 | awk '{print $2}'); do
  52   52          for i in $zfs_list; do
  53   53                  [[ $fs = $i ]] && continue 2
  54   54          done
  55   55          log_fail "umountall -n -F zfs tried to unmount $fs"
  56   56  done
  57   57  [[ -n $fs ]] || log_fail "umountall -n -F zfs produced no output"
  58   58  
  59   59  log_pass "All ZFS file systems would have been unmounted"
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX