1#! /usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"@(#)zvol_misc_005_neg.ksh	1.1	08/05/14 SMI"
28#
29
30. $STF_SUITE/include/libtest.kshlib
31. $STF_SUITE/tests/zvol/zvol_common.kshlib
32
33###############################################################################
34#
35# __stc_assertion_start
36#
37# ID: zvol_misc_005_neg
38#
39# DESCRIPTION:
40# 	Verify a device cannot be dump and swap at the same time.
41#
42# STRATEGY:
43# 1. Create a ZFS volume
44# 2. Set it as swap device.
45# 3. Verify dumpadm with this zvol will fail.
46#
47# TESTABILITY: explicit
48#
49# TEST_AUTOMATION_LEVEL: automated
50#
51# CODING_STATUS: COMPLETED (2008-03-10)
52#
53# __stc_assertion_end
54#
55################################################################################
56
57verify_runnable "global"
58
59function cleanup
60{
61	$SWAP -l | $GREP $voldev > /dev/null 2>&1
62	if (( $? == 0 )) ; then
63		log_must $SWAP -d $voldev
64	fi
65
66	typeset dumpdev=$(get_dumpdevice)
67	if [[ $dumpdev != $savedumpdev ]] ; then
68		safe_dumpadm $savedumpdev
69	fi
70}
71
72log_assert "Verify a device cannot be dump and swap at the same time."
73if ! is_dumpswap_supported $TESTPOOL ; then
74	log_unsupported "dumpswap not currently supported."
75fi
76log_onexit cleanup
77
78test_requires DUMPADM
79
80voldev=/dev/zvol/$TESTPOOL/$TESTVOL
81savedumpdev=$(get_dumpdevice)
82
83# If device in swap list, it cannot be dump device
84log_must $SWAP -a $voldev
85log_mustnot $DUMPADM -d $voldev
86log_must $SWAP -d $voldev
87
88# If device has dedicated as dump device, it cannot add into swap list
89safe_dumpadm $voldev
90log_mustnot $SWAP -a $voldev
91
92log_pass "A device cannot be dump and swap at the same time."
93