mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-04-06 17:49:11 +03:00
tests: revert back to original coredump patterns on Linux, too
Otherwise, they leak past the tests and contaminate the running system, breaking coredumps entirely Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Co-authored-by: Yannick Le Pennec <yannick.lepennec@live.fr> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13259
This commit is contained in:
parent
912d2aa7d7
commit
598fed7ecd
@ -79,7 +79,7 @@ FreeBSD)
|
|||||||
;;
|
;;
|
||||||
Linux)
|
Linux)
|
||||||
# core file helpers
|
# core file helpers
|
||||||
origcorepattern="$(cat /proc/sys/kernel/core_pattern)"
|
read -r origcorepattern </proc/sys/kernel/core_pattern
|
||||||
coreglob="$(grep -E -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
|
coreglob="$(grep -E -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
|
||||||
|
|
||||||
if [[ $coreglob = "*" ]]; then
|
if [[ $coreglob = "*" ]]; then
|
||||||
|
@ -3999,3 +3999,47 @@ function replay_directory_diff # dir_a dir_b
|
|||||||
{
|
{
|
||||||
LIBTEST_DIFF_ZIL_REPLAY=1 directory_diff "$@"
|
LIBTEST_DIFF_ZIL_REPLAY=1 directory_diff "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Put coredumps into $1/core.{basename}
|
||||||
|
#
|
||||||
|
# Output must be saved and passed to pop_coredump_pattern on cleanup
|
||||||
|
#
|
||||||
|
function push_coredump_pattern # dir
|
||||||
|
{
|
||||||
|
ulimit -c unlimited
|
||||||
|
case $(uname) in
|
||||||
|
Linux)
|
||||||
|
cat /proc/sys/kernel/core_pattern /proc/sys/kernel/core_uses_pid
|
||||||
|
echo "$1/core.%e" >/proc/sys/kernel/core_pattern &&
|
||||||
|
echo 0 >/proc/sys/kernel/core_uses_pid
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
|
sysctl -n kern.corefile
|
||||||
|
sysctl kern.corefile="$1/core.%N" >/dev/null
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Nothing to output – set only for this shell
|
||||||
|
coreadm -p "$1/core.%f"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Put coredumps back into the default location
|
||||||
|
#
|
||||||
|
function pop_coredump_pattern
|
||||||
|
{
|
||||||
|
[ -s "$1" ] || return 0
|
||||||
|
case $(uname) in
|
||||||
|
Linux)
|
||||||
|
typeset pat pid
|
||||||
|
{ read -r pat; read -r pid; } < "$1"
|
||||||
|
echo "$pat" >/proc/sys/kernel/core_pattern &&
|
||||||
|
echo "$pid" >/proc/sys/kernel/core_uses_pid
|
||||||
|
;;
|
||||||
|
FreeBSD)
|
||||||
|
sysctl kern.corefile="$(<"$1")" >/dev/null
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
@ -48,33 +48,23 @@ function cleanup
|
|||||||
{
|
{
|
||||||
unset ZFS_ABORT
|
unset ZFS_ABORT
|
||||||
|
|
||||||
if is_freebsd && [[ -n $savedcorefile ]]; then
|
log_must pop_coredump_pattern "$coresavepath"
|
||||||
sysctl kern.corefile=$savedcorefile
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d $corepath ]]; then
|
|
||||||
rm -rf $corepath
|
|
||||||
fi
|
|
||||||
for ds in $fs1 $fs $ctr; do
|
for ds in $fs1 $fs $ctr; do
|
||||||
datasetexists $ds && destroy_dataset $ds -rRf
|
datasetexists $ds && destroy_dataset $ds -rRf
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a " \
|
log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a core file."
|
||||||
"core file."
|
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
|
||||||
# Preparation work for testing
|
|
||||||
savedcorefile=""
|
|
||||||
corepath=$TESTDIR/core
|
|
||||||
corefile=$corepath/core.zfs
|
|
||||||
if [[ -d $corepath ]]; then
|
|
||||||
rm -rf $corepath
|
|
||||||
fi
|
|
||||||
log_must mkdir $corepath
|
|
||||||
|
|
||||||
ctr=$TESTPOOL/$TESTCTR
|
ctr=$TESTPOOL/$TESTCTR
|
||||||
log_must zfs create $ctr
|
log_must zfs create -p $ctr
|
||||||
|
|
||||||
|
# Preparation work for testing
|
||||||
|
corepath=/$ctr
|
||||||
|
corefile=$corepath/core.zfs
|
||||||
|
coresavepath=$corepath/save
|
||||||
|
|
||||||
fs=$ctr/$TESTFS
|
fs=$ctr/$TESTFS
|
||||||
fs1=$ctr/$TESTFS1
|
fs1=$ctr/$TESTFS1
|
||||||
@ -93,24 +83,12 @@ typeset badparams=("" "create" "destroy" "snapshot" "rollback" "clone" \
|
|||||||
"promote" "rename" "list -*" "set" "get -*" "inherit" "mount -A" \
|
"promote" "rename" "list -*" "set" "get -*" "inherit" "mount -A" \
|
||||||
"unmount" "share" "unshare" "send" "receive")
|
"unmount" "share" "unshare" "send" "receive")
|
||||||
|
|
||||||
if is_linux; then
|
log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\""
|
||||||
ulimit -c unlimited
|
|
||||||
echo "$corefile" >/proc/sys/kernel/core_pattern
|
|
||||||
echo 0 >/proc/sys/kernel/core_uses_pid
|
|
||||||
elif is_freebsd; then
|
|
||||||
ulimit -c unlimited
|
|
||||||
savedcorefile=$(sysctl -n kern.corefile)
|
|
||||||
log_must sysctl kern.corefile=$corepath/core.%N
|
|
||||||
else
|
|
||||||
log_must coreadm -p ${corepath}/core.%f
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_must export ZFS_ABORT=yes
|
log_must export ZFS_ABORT=yes
|
||||||
|
|
||||||
for subcmd in "${cmds[@]}" "${badparams[@]}"; do
|
for subcmd in "${cmds[@]}" "${badparams[@]}"; do
|
||||||
log_mustnot eval "zfs $subcmd >/dev/null 2>&1"
|
log_mustnot eval "zfs $subcmd"
|
||||||
log_must rm $corefile
|
log_must rm "$corefile"
|
||||||
done
|
done
|
||||||
|
|
||||||
log_pass "With ZFS_ABORT set, zfs command can abort and generate core file " \
|
log_pass "With ZFS_ABORT set, zfs command can abort and generate core file as expected."
|
||||||
"as expected."
|
|
||||||
|
@ -47,33 +47,27 @@ function cleanup
|
|||||||
{
|
{
|
||||||
unset ZFS_ABORT
|
unset ZFS_ABORT
|
||||||
|
|
||||||
if is_freebsd && [ -n "$old_corefile" ]; then
|
log_must pop_coredump_pattern "$coresavepath"
|
||||||
sysctl kern.corefile=$old_corefile
|
log_must rm -rf $corepath $vdev1 $vdev2 $vdev3
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean up the pool created if we failed to abort.
|
# Clean up the pool created if we failed to abort.
|
||||||
poolexists $pool && destroy_pool $pool
|
poolexists $pool && destroy_pool $pool
|
||||||
|
|
||||||
rm -rf $corepath $vdev1 $vdev2 $vdev3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_assert "With ZFS_ABORT set, all zpool commands can abort and generate a core file."
|
log_assert "With ZFS_ABORT set, all zpool commands can abort and generate a core file."
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
|
||||||
corepath=$TESTDIR/core
|
corepath=$TESTDIR/core
|
||||||
corefile=$corepath/zpool.core
|
corefile=$corepath/core.zpool
|
||||||
if [[ -d $corepath ]]; then
|
coresavepath=$corepath/save
|
||||||
log_must rm -rf $corepath
|
log_must rm -rf $corepath
|
||||||
fi
|
|
||||||
log_must mkdir $corepath
|
log_must mkdir $corepath
|
||||||
|
|
||||||
pool=pool.$$
|
pool=pool.$$
|
||||||
vdev1=$TESTDIR/file1
|
vdev1=$TESTDIR/file1
|
||||||
vdev2=$TESTDIR/file2
|
vdev2=$TESTDIR/file2
|
||||||
vdev3=$TESTDIR/file3
|
vdev3=$TESTDIR/file3
|
||||||
for vdev in $vdev1 $vdev2 $vdev3; do
|
log_must mkfile $MINVDEVSIZE $vdev1 $vdev2 $vdev3
|
||||||
log_must mkfile $MINVDEVSIZE $vdev
|
|
||||||
done
|
|
||||||
|
|
||||||
set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \
|
set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \
|
||||||
"status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \
|
"status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \
|
||||||
@ -86,25 +80,12 @@ set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status"
|
|||||||
"online" "offline" "clear" "attach" "detach" "replace" "scrub" \
|
"online" "offline" "clear" "attach" "detach" "replace" "scrub" \
|
||||||
"import" "export" "upgrade" "history -?" "get" "set"
|
"import" "export" "upgrade" "history -?" "get" "set"
|
||||||
|
|
||||||
if is_linux; then
|
log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\""
|
||||||
echo $corefile >/proc/sys/kernel/core_pattern
|
log_must export ZFS_ABORT=yes
|
||||||
echo 0 >/proc/sys/kernel/core_uses_pid
|
|
||||||
elif is_freebsd; then
|
|
||||||
old_corefile=$(sysctl -n kern.corefile)
|
|
||||||
log_must sysctl kern.corefile=$corefile
|
|
||||||
fi
|
|
||||||
ulimit -c unlimited
|
|
||||||
|
|
||||||
export ZFS_ABORT=yes
|
|
||||||
|
|
||||||
for subcmd in "${cmds[@]}" "${badparams[@]}"; do
|
for subcmd in "${cmds[@]}" "${badparams[@]}"; do
|
||||||
zpool $subcmd >/dev/null 2>&1
|
log_mustnot eval "zpool $subcmd"
|
||||||
if [[ ! -e $corefile ]]; then
|
log_must rm "$corefile"
|
||||||
log_fail "zpool $subcmd cannot generate core file with ZFS_ABORT set."
|
|
||||||
fi
|
|
||||||
rm -f $corefile
|
|
||||||
done
|
done
|
||||||
|
|
||||||
unset ZFS_ABORT
|
|
||||||
|
|
||||||
log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected."
|
log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected."
|
||||||
|
@ -46,15 +46,12 @@ function cleanup
|
|||||||
{
|
{
|
||||||
unset ZFS_ABORT
|
unset ZFS_ABORT
|
||||||
|
|
||||||
if is_freebsd && [ -n "$old_corefile" ]; then
|
log_must pop_coredump_pattern "$coresavepath"
|
||||||
sysctl kern.corefile=$old_corefile
|
log_must rm -rf $corepath
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf $corepath
|
|
||||||
|
|
||||||
# Don't leave the pool frozen.
|
# Don't leave the pool frozen.
|
||||||
destroy_pool $TESTPOOL
|
log_must destroy_pool $TESTPOOL
|
||||||
default_mirror_setup $DISKS
|
log_must default_mirror_setup $DISKS
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_runnable "both"
|
verify_runnable "both"
|
||||||
@ -63,15 +60,14 @@ log_assert "Debugging features of zpool should succeed."
|
|||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
|
||||||
corepath=$TESTDIR/core
|
corepath=$TESTDIR/core
|
||||||
corefile=$corepath/zpool.core
|
corefile=$corepath/core.zpool
|
||||||
if [[ -d $corepath ]]; then
|
coresavepath=$corepath/save
|
||||||
log_must rm -rf $corepath
|
log_must rm -rf $corepath
|
||||||
fi
|
|
||||||
log_must mkdir $corepath
|
log_must mkdir $corepath
|
||||||
|
|
||||||
log_must eval "zpool -? >/dev/null 2>&1"
|
log_must eval "zpool -? >/dev/null 2>&1"
|
||||||
|
|
||||||
if is_global_zone ; then
|
if is_global_zone; then
|
||||||
log_must zpool freeze $TESTPOOL
|
log_must zpool freeze $TESTPOOL
|
||||||
else
|
else
|
||||||
log_mustnot zpool freeze $TESTPOOL
|
log_mustnot zpool freeze $TESTPOOL
|
||||||
@ -80,21 +76,10 @@ fi
|
|||||||
|
|
||||||
log_mustnot zpool freeze fakepool
|
log_mustnot zpool freeze fakepool
|
||||||
|
|
||||||
if is_linux; then
|
log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\""
|
||||||
echo $corefile >/proc/sys/kernel/core_pattern
|
log_must export ZFS_ABORT=yes
|
||||||
echo 0 >/proc/sys/kernel/core_uses_pid
|
|
||||||
elif is_freebsd; then
|
|
||||||
old_corefile=$(sysctl -n kern.corefile)
|
|
||||||
log_must sysctl kern.corefile=$corefile
|
|
||||||
fi
|
|
||||||
ulimit -c unlimited
|
|
||||||
|
|
||||||
export ZFS_ABORT=yes
|
log_mustnot eval "zpool >/dev/null 2>&1"
|
||||||
|
log_must [ -f "$corefile" ]
|
||||||
zpool >/dev/null 2>&1
|
|
||||||
|
|
||||||
unset ZFS_ABORT
|
|
||||||
|
|
||||||
[[ -f $corefile ]] || log_fail "zpool did not dump core by request."
|
|
||||||
|
|
||||||
log_pass "Debugging features of zpool succeed."
|
log_pass "Debugging features of zpool succeed."
|
||||||
|
Loading…
Reference in New Issue
Block a user