mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-26 20:12:44 +00:00
savecore: Add a livedump regression test
MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47715
This commit is contained in:
parent
37cef00192
commit
73465bb47b
@ -505,6 +505,8 @@
|
||||
..
|
||||
route
|
||||
..
|
||||
savecore
|
||||
..
|
||||
sysctl
|
||||
..
|
||||
..
|
||||
|
@ -18,4 +18,7 @@ CFLAGS+= -DWITH_CASPER
|
||||
LIBADD+= casper cap_fileargs cap_syslog
|
||||
.endif
|
||||
|
||||
HAS_TESTS=
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
3
sbin/savecore/tests/Makefile
Normal file
3
sbin/savecore/tests/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
ATF_TESTS_SH= livedump_test
|
||||
|
||||
.include <bsd.test.mk>
|
54
sbin/savecore/tests/livedump_test.sh
Normal file
54
sbin/savecore/tests/livedump_test.sh
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
|
||||
#
|
||||
|
||||
atf_test_case livedump_kldstat
|
||||
livedump_kldstat_head()
|
||||
{
|
||||
atf_set "descr" "Test livedump integrity"
|
||||
atf_set "require.progs" kgdb
|
||||
atf_set "require.user" root
|
||||
}
|
||||
livedump_kldstat_body()
|
||||
{
|
||||
atf_check savecore -L .
|
||||
|
||||
kernel=$(sysctl -n kern.bootfile)
|
||||
|
||||
if ! [ -f /usr/lib/debug/${kernel}.debug ]; then
|
||||
atf_skip "No debug symbols for the running kernel"
|
||||
fi
|
||||
|
||||
# Implement kldstat using gdb script.
|
||||
cat >./kldstat.gdb <<'__EOF__'
|
||||
printf "Id Refs Address Size Name\n"
|
||||
set $_lf = linker_files.tqh_first
|
||||
while ($_lf)
|
||||
printf "%2d %4d %p %8x %s\n", $_lf->id, $_lf->refs, $_lf->address, $_lf->size, $_lf->filename
|
||||
set $_lf = $_lf->link.tqe_next
|
||||
end
|
||||
__EOF__
|
||||
|
||||
# Ignore stderr since kgdb prints some warnings about inaccessible
|
||||
# source files.
|
||||
#
|
||||
# Use a script to source the main gdb script, otherwise kgdb prints
|
||||
# a bunch of line noise that is annoying to filter out.
|
||||
echo "source ./kldstat.gdb" > ./script.gdb
|
||||
atf_check -o save:out -e ignore \
|
||||
kgdb -q ${kernel} ./livecore.0 < ./script.gdb
|
||||
|
||||
# Get rid of gunk printed by kgdb.
|
||||
sed -i '' -n -e 's/^(kgdb) //' -e '/^Id Refs /,$p' out
|
||||
|
||||
# The output of kgdb should match the output of kldstat.
|
||||
atf_check -o save:kldstat kldstat
|
||||
atf_check diff kldstat out
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case livedump_kldstat
|
||||
}
|
Loading…
Reference in New Issue
Block a user