7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_destroy / zfs_destroy_014_pos.ksh
blobdf7cfcf5271dbddf2cf35a6333732e9fd312e54c
1 #!/bin/ksh -p
3 # CDDL HEADER START
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
14 # CDDL HEADER END
18 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
21 . $STF_SUITE/include/libtest.shlib
22 . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
25 # DESCRIPTION:
26 # 'zfs destroy -R <snapshot>' can destroy all the child
27 # snapshots and preserves all the nested datasetss.
29 # STRATEGY:
30 # 1. Create nested datasets in the storage pool.
31 # 2. Create recursive snapshots for all the nested datasets.
32 # 3. Verify when snapshots are destroyed recursively, all
33 # the nested datasets still exist.
36 verify_runnable "both"
38 log_assert "Verify 'zfs destroy -R <snapshot>' does not destroy" \
39 "nested datasets."
40 log_onexit cleanup
42 datasets="$TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1/$TESTFS2
43 $TESTPOOL/$TESTFS1/$TESTFS2/$TESTFS3"
45 function cleanup
47 for ds in $datasets; do
48 datasetexists $ds && zfs destroy -rf $ds
49 done
52 # create nested datasets
53 log_must zfs create -p $TESTPOOL/$TESTFS1/$TESTFS2/$TESTFS3
55 # verify dataset creation
56 for ds in $datasets; do
57 datasetexists $ds || log_fail "Create $ds dataset fail."
58 done
60 # create recursive nestedd snapshot
61 log_must zfs snapshot -r $TESTPOOL/$TESTFS1@snap
62 for ds in $datasets; do
63 datasetexists $ds@snap || log_fail "Create $ds@snap snapshot fail."
64 done
66 # destroy nested snapshot recursively
67 log_must zfs destroy -R $TESTPOOL/$TESTFS1@snap
69 # verify snapshot destroy
70 for ds in $datasets; do
71 datasetexists $ds@snap && log_fail "$ds@snap exists. Destroy failed!"
72 done
74 # verify nested datasets still exist
75 for ds in $datasets; do
76 datasetexists $ds || log_fail "Recursive snapshot destroy deleted $ds"
77 done
79 log_pass "'zfs destroy -R <snapshot>' works as expected."