Fix coredump_phnum_test when kern.compress_user_cores != 0
If `kern.compress_user_cores` is non-zero, decompress the core file. Use `sysctl -f` to restore previous values. Don't bother restoring `ulimit -c`, since that's a per-process value. Check more commands with `atf_check`. Reviewed by: olivier ngie MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21820
This commit is contained in:
parent
11fd6a60e7
commit
2b2ad2d6c6
@ -40,21 +40,31 @@ coredump_phnum_head()
|
||||
coredump_phnum_body()
|
||||
{
|
||||
# Set up core dumping
|
||||
cat > coredump_phnum_restore_state.sh <<-EOF
|
||||
#!/bin/sh
|
||||
ulimit -c '$(ulimit -c)'
|
||||
sysctl kern.coredump=$(sysctl -n kern.coredump)
|
||||
sysctl kern.corefile='$(sysctl -n kern.corefile)'
|
||||
sysctl kern.compress_user_cores='$(sysctl -n kern.compress_user_cores)'
|
||||
EOF
|
||||
atf_check -o save:coredump_phnum_restore_state sysctl -e \
|
||||
kern.coredump kern.corefile
|
||||
|
||||
ulimit -c unlimited
|
||||
sysctl kern.coredump=1
|
||||
sysctl kern.compress_user_cores=0
|
||||
sysctl kern.corefile="$(pwd)/coredump_phnum_helper.core"
|
||||
atf_check -o ignore sysctl kern.coredump=1
|
||||
atf_check -o ignore sysctl kern.corefile=coredump_phnum_helper.core
|
||||
atf_check -o save:cuc sysctl -n kern.compress_user_cores
|
||||
read cuc < cuc
|
||||
|
||||
atf_check -s signal:sigabrt "$(atf_get_srcdir)/coredump_phnum_helper"
|
||||
|
||||
case "$cuc" in
|
||||
0)
|
||||
;;
|
||||
1)
|
||||
atf_check gunzip coredump_phnum_helper.core.gz
|
||||
;;
|
||||
2)
|
||||
atf_check zstd -qd coredump_phnum_helper.core.zst
|
||||
;;
|
||||
*)
|
||||
atf_skip "unsupported kern.compress_user_cores=$cuc"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check that core looks good
|
||||
if [ ! -f coredump_phnum_helper.core ]; then
|
||||
atf_fail "Helper program did not dump core"
|
||||
@ -76,10 +86,11 @@ EOF
|
||||
coredump_phnum_cleanup()
|
||||
{
|
||||
rm -f coredump_phnum_helper.core
|
||||
if [ -f coredump_phnum_restore_state.sh ]; then
|
||||
. ./coredump_phnum_restore_state.sh
|
||||
if [ -f coredump_phnum_restore_state ]; then
|
||||
sysctl -f coredump_phnum_restore_state
|
||||
rm -f coredump_phnum_restore_state
|
||||
fi
|
||||
rm -f coredump_phnum_restore_state.sh
|
||||
rm -f cuc
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
|
Loading…
Reference in New Issue
Block a user