]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
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 | # | |
d7958b4c MA |
27 | |
28 | # | |
c1d9abf9 | 29 | # Copyright (c) 2012, 2016 by Delphix. All rights reserved. |
d7958b4c MA |
30 | # |
31 | ||
6bb24f4d BB |
32 | . $STF_SUITE/include/libtest.shlib |
33 | ||
34 | # | |
35 | # DESCRIPTION: | |
36 | # With ZFS_ABORT set, all zpool commands should be able to abort and generate a core file. | |
37 | # | |
38 | # STRATEGY: | |
39 | # 1. Create an array of zpool command | |
40 | # 2. Execute each command in the array | |
41 | # 3. Verify the command aborts and generate a core file | |
42 | # | |
43 | ||
44 | verify_runnable "global" | |
45 | ||
46 | function cleanup | |
47 | { | |
48 | unset ZFS_ABORT | |
49 | ||
50 | if [[ -d $corepath ]]; then | |
c1d9abf9 | 51 | rm -rf $corepath |
6bb24f4d BB |
52 | fi |
53 | ||
54 | if poolexists $pool; then | |
c1d9abf9 | 55 | log_must zpool destroy -f $pool |
6bb24f4d BB |
56 | fi |
57 | } | |
58 | ||
59 | log_assert "With ZFS_ABORT set, all zpool commands can abort and generate a core file." | |
60 | log_onexit cleanup | |
61 | ||
62 | #preparation work for testing | |
63 | corepath=$TESTDIR/core | |
64 | if [[ -d $corepath ]]; then | |
c1d9abf9 | 65 | rm -rf $corepath |
6bb24f4d | 66 | fi |
c1d9abf9 | 67 | mkdir $corepath |
6bb24f4d BB |
68 | |
69 | pool=pool.$$ | |
70 | vdev1=$TESTDIR/file1 | |
71 | vdev2=$TESTDIR/file2 | |
72 | vdev3=$TESTDIR/file3 | |
73 | for vdev in $vdev1 $vdev2 $vdev3; do | |
c1d9abf9 | 74 | mkfile $MINVDEVSIZE $vdev |
6bb24f4d BB |
75 | done |
76 | ||
77 | set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \ | |
78 | "status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \ | |
79 | "export $pool" "import -d $TESTDIR $pool" "offline $pool $vdev1" \ | |
80 | "online $pool $vdev1" "clear $pool" "detach $pool $vdev2" \ | |
81 | "attach $pool $vdev1 $vdev2" "replace $pool $vdev2 $vdev3" \ | |
82 | "scrub $pool" "destroy -f $pool" | |
83 | ||
84 | set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status" \ | |
85 | "online" "offline" "clear" "attach" "detach" "replace" "scrub" \ | |
86 | "import" "export" "upgrade" "history -?" "get" "set" | |
87 | ||
88 | if is_linux; then | |
89 | ulimit -c unlimited | |
90 | echo "$corepath/core.zpool" >/proc/sys/kernel/core_pattern | |
91 | echo 0 >/proc/sys/kernel/core_uses_pid | |
fed90353 | 92 | export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0" |
7839c4b5 MM |
93 | elif is_freebsd; then |
94 | ulimit -c unlimited | |
95 | log_must sysctl kern.corefile=$corepath/core.zpool | |
96 | export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0" | |
6bb24f4d | 97 | else |
c1d9abf9 | 98 | coreadm -p ${corepath}/core.%f |
6bb24f4d BB |
99 | fi |
100 | ||
101 | export ZFS_ABORT=yes | |
102 | ||
103 | for subcmd in "${cmds[@]}" "${badparams[@]}"; do | |
104 | corefile=${corepath}/core.zpool | |
c1d9abf9 | 105 | zpool $subcmd >/dev/null 2>&1 |
6bb24f4d | 106 | if [[ ! -e $corefile ]]; then |
c1d9abf9 | 107 | log_fail "zpool $subcmd cannot generate core file with ZFS_ABORT set." |
6bb24f4d | 108 | fi |
c1d9abf9 | 109 | rm -f $corefile |
6bb24f4d BB |
110 | done |
111 | ||
112 | log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected." |