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# 27# ident "@(#)zpool_002_pos.ksh 1.2 09/01/12 SMI" 28# 29. $STF_SUITE/include/libtest.kshlib 30 31################################################################################ 32# 33# __stc_assertion_start 34# 35# ID: zpool_002_pos 36# 37# DESCRIPTION: 38# With ZFS_ABORT set, all zpool commands should be able to abort and generate a core file. 39# 40# STRATEGY: 41# 1. Create an array of zpool command 42# 2. Execute each command in the array 43# 3. Verify the command aborts and generate a core file 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2007-06-29) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55verify_runnable "global" 56 57function cleanup 58{ 59 unset ZFS_ABORT 60 61 if [[ -d $corepath ]]; then 62 $RM -rf $corepath 63 fi 64 if poolexists $pool; then 65 log_must $ZPOOL destroy -f $pool 66 fi 67} 68 69log_assert "With ZFS_ABORT set, all zpool 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 77$MKDIR $corepath 78 79pool=pool.${TESTCASE_ID} 80vdev1=$TESTDIR/file1 81vdev2=$TESTDIR/file2 82vdev3=$TESTDIR/file3 83log_must create_vdevs $vdev1 $vdev2 $vdev3 84 85set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \ 86 "status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \ 87 "export $pool" "import -d $TESTDIR $pool" "offline $pool $vdev1" \ 88 "online $pool $vdev1" "clear $pool" "detach $pool $vdev2" \ 89 "attach $pool $vdev1 $vdev2" "replace $pool $vdev2 $vdev3" \ 90 "scrub $pool" "destroy -f $pool" 91 92set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status" \ 93 "online" "offline" "clear" "attach" "detach" "replace" "scrub" \ 94 "import" "export" "upgrade" "history -?" "get" "set" 95 96$COREADM -p ${corepath}/core.%f 97export ZFS_ABORT=yes 98 99for subcmd in "${cmds[@]}" "${badparams[@]}"; do 100 $ZPOOL $subcmd >/dev/null 2>&1 101 corefile=${corepath}/core.zpool 102 if [[ ! -e $corefile ]]; then 103 log_fail "$ZPOOL $subcmd cannot generate core file with ZFS_ABORT set." 104 fi 105 $RM -f $corefile 106done 107 108log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected." 109