Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144611038
D47715.1775765345.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D47715.1775765345.diff
View Options
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -505,6 +505,8 @@
..
route
..
+ savecore
+ ..
sysctl
..
..
diff --git a/sbin/savecore/Makefile b/sbin/savecore/Makefile
--- a/sbin/savecore/Makefile
+++ b/sbin/savecore/Makefile
@@ -18,4 +18,7 @@
LIBADD+= casper cap_fileargs cap_syslog
.endif
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
diff --git a/sbin/savecore/tests/Makefile b/sbin/savecore/tests/Makefile
new file mode 100644
--- /dev/null
+++ b/sbin/savecore/tests/Makefile
@@ -0,0 +1,3 @@
+ATF_TESTS_SH= livedump_test
+
+.include <bsd.test.mk>
diff --git a/sbin/savecore/tests/livedump_test.sh b/sbin/savecore/tests/livedump_test.sh
new file mode 100644
--- /dev/null
+++ b/sbin/savecore/tests/livedump_test.sh
@@ -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
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 9, 8:09 PM (4 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28309667
Default Alt Text
D47715.1775765345.diff (2 KB)
Attached To
Mode
D47715: savecore: Add a livedump regression test
Attached
Detach File
Event Timeline
Log In to Comment