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