xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh (revision f985abb4a2473d3c04b086f7c9fab177e368ffef)
1#!/bin/ksh -p
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2012 by Delphix. All rights reserved.
15#
16
17. $STF_SUITE/include/libtest.shlib
18. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy.cfg
19. $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
20
21################################################################################
22#
23# Destroy of held snapshot should fail.
24#
25# 1. Create test environment without clones.
26# 2. 'zfs hold <tag> <snap>'
27# 3. 'zfs destroy <snap>' should fail.
28# 4. Verify snapshot still exists.
29# 5. 'zfs release <tag> <snap>'
30# 6. Verify that we can destroy the snapshot.
31#
32################################################################################
33
34log_assert "zfs destroy of held snapshots fails"
35log_onexit cleanup_testenv
36
37setup_testenv snap
38
39for dstype in FS VOL; do
40    snap=$(eval echo \$${dstype}SNAP)
41    log_must $ZFS hold zfstest $snap
42    log_mustnot $ZFS destroy $snap
43    log_must datasetexists $snap
44    log_must $ZFS release zfstest $snap
45    log_must $ZFS destroy $snap
46    log_mustnot datasetexists $snap
47done
48
49log_pass "zfs destroy of held snapshots fails"
50