1#!/bin/ksh -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. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# With ZFS_ABORT set, all zpool commands should be able to abort and generate a core file. 32# 33# STRATEGY: 34# 1. Create an array of zpool command 35# 2. Execute each command in the array 36# 3. Verify the command aborts and generate a core file 37# 38 39verify_runnable "global" 40 41function cleanup 42{ 43 unset ZFS_ABORT 44 45 if [[ -d $corepath ]]; then 46 $RM -rf $corepath 47 fi 48 if poolexists $pool; then 49 log_must $ZPOOL destroy -f $pool 50 fi 51} 52 53log_assert "With ZFS_ABORT set, all zpool commands can abort and generate a core file." 54log_onexit cleanup 55 56#preparation work for testing 57corepath=$TESTDIR/core 58if [[ -d $corepath ]]; then 59 $RM -rf $corepath 60fi 61$MKDIR $corepath 62 63pool=pool.$$ 64vdev1=$TESTDIR/file1 65vdev2=$TESTDIR/file2 66vdev3=$TESTDIR/file3 67for vdev in $vdev1 $vdev2 $vdev3; do 68 $MKFILE 64m $vdev 69done 70 71set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \ 72 "status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \ 73 "export $pool" "import -d $TESTDIR $pool" "offline $pool $vdev1" \ 74 "online $pool $vdev1" "clear $pool" "detach $pool $vdev2" \ 75 "attach $pool $vdev1 $vdev2" "replace $pool $vdev2 $vdev3" \ 76 "scrub $pool" "destroy -f $pool" 77 78set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status" \ 79 "online" "offline" "clear" "attach" "detach" "replace" "scrub" \ 80 "import" "export" "upgrade" "history -?" "get" "set" 81 82$COREADM -p ${corepath}/core.%f 83export ZFS_ABORT=yes 84 85for subcmd in "${cmds[@]}" "${badparams[@]}"; do 86 $ZPOOL $subcmd >/dev/null 2>&1 87 corefile=${corepath}/core.zpool 88 if [[ ! -e $corefile ]]; then 89 log_fail "$ZPOOL $subcmd cannot generate core file with ZFS_ABORT set." 90 fi 91 $RM -f $corefile 92done 93 94log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected." 95