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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27. $STF_SUITE/tests/userquota/userquota_common.kshlib 28 29################################################################################ 30# 31# __stc_assertion_start 32# 33# ID: zfs_002_pos 34# 35# DESCRIPTION: 36# With ZFS_ABORT set, all zfs commands should be able to abort and generate a core file. 37# 38# STRATEGY: 39# 1. Create an array of zfs command 40# 2. Execute each command in the array 41# 3. Verify the command aborts and generate a core file 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2007-06-29) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55function cleanup 56{ 57 unset ZFS_ABORT 58 59 if [[ -d $corepath ]]; then 60 $RM -rf $corepath 61 fi 62 for ds in $fs1 $fs $ctr; do 63 if datasetexists $ds; then 64 log_must $ZFS destroy -rRf $ds 65 fi 66 done 67} 68 69log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a core file." 70log_onexit cleanup 71 72#preparation work for testing 73corepath=$TESTDIR/core 74if [[ -d $corepath ]]; then 75 $RM -rf $corepath 76fi 77log_must $MKDIR $corepath 78 79ctr=$TESTPOOL/$TESTCTR 80log_must $ZFS create $ctr 81 82fs=$ctr/$TESTFS 83fs1=$ctr/$TESTFS1 84snap=$fs@$TESTSNAP 85clone=$ctr/$TESTCLONE 86streamf=$corepath/s.${TESTCASE_ID} 87 88set -A cmds "create $fs" "list $fs" "snapshot $snap" "set snapdir=hidden $fs" \ 89 "get snapdir $fs" "rollback $snap" "inherit snapdir $fs" \ 90 "rename $fs $fs-new" "rename $fs-new $fs" "unmount $fs" \ 91 "mount $fs" "share $fs" "unshare $fs" "send $snap \>$streamf" \ 92 "receive $fs1 \<$streamf" "clone $snap $clone" "promote $clone" \ 93 "promote $fs" "destroy -rRf $fs" 94 95set -A badparams "" "create" "destroy" "snapshot" "rollback" "clone" "promote" "rename" \ 96 "list -*" "set" "get -*" "inherit" "mount -A" "unmount" "share" \ 97 "unshare" "send" "receive" 98 99if ! is_userquota_supported; then 100 typeset -i i=${cmds[#]} 101 cmds[i]="allow everyone snapshot $fs" 102 cmds[((i+1))]="unallow everyone snapshot $fs" 103 104 i=${badparams[#]} 105 badparams[i]="allow" 106 badparams[((i+1))]="unallow" 107fi 108 109 110log_must $COREADM -p ${corepath}/core.%f 111log_must export ZFS_ABORT=yes 112 113for subcmd in "${cmds[@]}" "${badparams[@]}"; do 114 log_mustnot $ZFS $subcmd 115 corefile=${corepath}/core.zfs 116 if [[ ! -e $corefile ]]; then 117 log_fail "$ZFS $subcmd cannot generate core file with ZFS_ABORT set." 118 fi 119 log_must $RM -f $corefile 120done 121 122log_pass "With ZFS_ABORT set, zfs command can abort and generate core file as expected." 123