@@ -47,31 +47,32 @@ function cleanup
47
47
{
48
48
unset ZFS_ABORT
49
49
50
- if [[ -d $corepath ] ]; then
51
- rm -rf $corepath
50
+ if is_freebsd && [ -n " $old_corefile " ]; then
51
+ sysctl kern.corefile= $old_corefile
52
52
fi
53
53
54
- if poolexists $pool ; then
55
- log_must zpool destroy -f $pool
56
- fi
54
+ # Clean up the pool created if we failed to abort.
55
+ poolexists $pool && destroy_pool $pool
56
+
57
+ rm -rf $corepath $vdev1 $vdev2 $vdev3
57
58
}
58
59
59
60
log_assert " With ZFS_ABORT set, all zpool commands can abort and generate a core file."
60
61
log_onexit cleanup
61
62
62
- # preparation work for testing
63
63
corepath=$TESTDIR /core
64
+ corefile=$corepath /zpool.core
64
65
if [[ -d $corepath ]]; then
65
- rm -rf $corepath
66
+ log_must rm -rf $corepath
66
67
fi
67
- mkdir $corepath
68
+ log_must mkdir $corepath
68
69
69
70
pool=pool.$$
70
71
vdev1=$TESTDIR /file1
71
72
vdev2=$TESTDIR /file2
72
73
vdev3=$TESTDIR /file3
73
74
for vdev in $vdev1 $vdev2 $vdev3 ; do
74
- mkfile $MINVDEVSIZE $vdev
75
+ log_must mkfile $MINVDEVSIZE $vdev
75
76
done
76
77
77
78
set -A cmds " create $pool mirror $vdev1 $vdev2 " " list $pool " " iostat $pool " \
@@ -86,27 +87,25 @@ set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status"
86
87
" import" " export" " upgrade" " history -?" " get" " set"
87
88
88
89
if is_linux; then
89
- ulimit -c unlimited
90
- echo " $corepath /core.zpool" > /proc/sys/kernel/core_pattern
90
+ echo $corefile > /proc/sys/kernel/core_pattern
91
91
echo 0 > /proc/sys/kernel/core_uses_pid
92
- export ASAN_OPTIONS=" abort_on_error=1:disable_coredump=0"
93
92
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"
97
- else
98
- coreadm -p ${corepath} /core.%f
93
+ old_corefile=$( sysctl -n kern.corefile)
94
+ log_must sysctl kern.corefile=$corefile
99
95
fi
96
+ ulimit -c unlimited
100
97
98
+ export ASAN_OPTIONS=" abort_on_error=1:disable_coredump=0"
101
99
export ZFS_ABORT=yes
102
100
103
101
for subcmd in " ${cmds[@]} " " ${badparams[@]} " ; do
104
- corefile=${corepath} /core.zpool
105
102
zpool $subcmd > /dev/null 2>&1
106
103
if [[ ! -e $corefile ]]; then
107
- log_fail " zpool $subcmd cannot generate core file with ZFS_ABORT set."
104
+ log_fail " zpool $subcmd cannot generate core file with ZFS_ABORT set."
108
105
fi
109
106
rm -f $corefile
110
107
done
111
108
109
+ unset ZFS_ABORT
110
+
112
111
log_pass " With ZFS_ABORT set, zpool command can abort and generate core file as expected."
0 commit comments