aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-07-19 16:23:02 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-07-19 16:23:02 +0000
commit83f5e032b435cb35a6f53dff84a568e7b7ef9d9a (patch)
tree05eb0d53f190e01f06680e74c1b759797d8d4f42
parentfa562aca7a51bbf5aeb388112789e7641bdb2131 (diff)
downloadsrc-83f5e032b435cb35a6f53dff84a568e7b7ef9d9a.tar.gz
src-83f5e032b435cb35a6f53dff84a568e7b7ef9d9a.zip
Clean up :coredump_phnum
- Use "atf_check -x 'cmd1 | cmd2'" instead of "cmd1 | atf_check cmd2". The two forms are idiomatically similar, but subtly different in the sense of what program invokes the other, and there could be unwanted side effects of the latter idiom dealing with forking, pipes, etc. - Remove chmod and instead source coredump_phnum_restore_state.sh directly. This avoids the need to check the result of the chmod call. - Fix indentation in an if-block (4 column space indentation -> hard tab).
Notes
Notes: svn path=/head/; revision=321211
-rwxr-xr-xtests/sys/kern/coredump_phnum_test.sh26
1 files changed, 11 insertions, 15 deletions
diff --git a/tests/sys/kern/coredump_phnum_test.sh b/tests/sys/kern/coredump_phnum_test.sh
index c801030d88b3..9ed3c7a34e65 100755
--- a/tests/sys/kern/coredump_phnum_test.sh
+++ b/tests/sys/kern/coredump_phnum_test.sh
@@ -46,7 +46,6 @@ coredump_phnum_body()
sysctl kern.coredump=$(sysctl -n kern.coredump)
sysctl kern.corefile='$(sysctl -n kern.corefile)'
EOF
- chmod +x coredump_phnum_restore_state.sh
ulimit -c unlimited
sysctl kern.coredump=1
@@ -56,30 +55,27 @@ EOF
# Check that core looks good
if [ ! -f coredump_phnum_helper.core ]; then
- atf_fail "Helper program did not dump core"
+ atf_fail "Helper program did not dump core"
fi
# These magic numbers don't have any real significance. They are just
# the result of running the helper program and dumping core. The only
# important bit is that they're larger than 65535 (UINT16_MAX).
- readelf -h coredump_phnum_helper.core | \
- atf_check -o "match:65535 \(66[0-9]{3}\)" \
- grep "Number of program headers:"
- readelf -l coredump_phnum_helper.core | \
- atf_check -o "match:There are 66[0-9]{3} program headers" \
- grep -1 "program headers"
- readelf -S coredump_phnum_helper.core | \
- atf_check -o "match: 0000000000000001 .* 66[0-9]{3} " \
- grep -A1 "^ \[ 0\] "
+ atf_check -o "match:65535 \(66[0-9]{3}\)" \
+ -x 'readelf -h coredump_phnum_helper.core | grep "Number of program headers:"'
+ atf_check -o "match:There are 66[0-9]{3} program headers" \
+ -x 'readelf -l coredump_phnum_helper.core | grep -1 "program headers"'
+ atf_check -o "match: 0000000000000001 .* 66[0-9]{3} " \
+ -x 'readelf -S coredump_phnum_helper.core | grep -A1 "^ \[ 0\] "'
- procstat -v coredump_phnum_helper.core | \
- atf_check -o "match:66[0-9]{3}" wc -l
+ atf_check -o "match:66[0-9]{3}" \
+ -x 'procstat -v coredump_phnum_helper.core | wc -l'
}
coredump_phnum_cleanup()
{
rm -f coredump_phnum_helper.core
- if [ -x coredump_phnum_restore_state.sh ]; then
- ./coredump_phnum_restore_state.sh
+ if [ -f coredump_phnum_restore_state.sh ]; then
+ . ./coredump_phnum_restore_state.sh
fi
rm -f coredump_phnum_restore_state.sh
}