From nobody Fri Dec 13 01:43:59 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y8XDv43s8z5h1WN; Fri, 13 Dec 2024 01:43:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y8XDv136Zz4jN5; Fri, 13 Dec 2024 01:43:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734054239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UFHTQn/gMCh4+CpM9ZYb5sQbGvEUO7UDzc/uK+zdfk0=; b=da5BR7nixAHIOsdyXgp8dXF5XjLUMc9IZFfdcqpSQHfwUyIWPDr3cOp1H6yID7xbblXpVR mnsEwwDIxlbZL5kBSGEHhre7T6Pe4iIP2jV1WPAuzPGfJo+GMUV8+XS8LyD7wCWXQ7qKQ5 ApbtjNM0jACS1vccLHpluBmzpAwg0opXA/oXnymCztLAHZ/LQJIZk5+W/vFiuotz8W0hwD jtDni0m32zRIX6GsvGD3hdaCS8wMvDAZkOz6NqZ0hY5z6vTG+ldY0GuxSDRP4/c4Jf1HA9 KTFc1+ms5ouzYx7bHMyO4NEZ0b5+80KD0ZCNHCZUnuDoeIELqj0ZJypj401Hpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734054239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UFHTQn/gMCh4+CpM9ZYb5sQbGvEUO7UDzc/uK+zdfk0=; b=YrxRe4/1qyMxZ1ca2+2tGBPbgCr+DjL70EKem51OZvKpsrsjuSapFLfLMAls3l84Nc56wD yDunwzrims/IyaJ9C9QyHgI0yQa2l0f+2XbpOhIKASuG0GsGuHqjm8HI54Lf7Nfn5k9Vjx xiq/c1DuM8FsAt0iwy5uN/pfarQrwm5U9JGHw/jRAN6FvwRg9mkQ5za90XFJKJkB07hzgS Yf1/+Hl6HoLpuW8A1F4nkBV4OHUyr6bP6rUAAbtwZ82/QrL9uiQkatoafC8671jKw6k/wD e4NJmh5mtUpNsGv6ymcFGGq/vuNWsFFvVhGWdEJQysn5MEdSFGkEx4dIto7BNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734054239; a=rsa-sha256; cv=none; b=nTEFYBr2M/Ny3EG3ypFohqM1XppIsoB3QJopu2bo2OPajOTaYz8pU7I1zr8DJuoS5CBkKR DTorgdxyMQxAb8lZnQiX4u8M+7f5gVf6hdGCy6UC2f0TaH6edga1eVn3dZ+Xolhr+O4S7p HW1xF975vJ8Y0dRlRkKQp+mdCxKBG0q/JqC+/cINS1lpJImuA67vIBrQbPISIjbUPQHpE/ dTapC+fQazPlLPlYEkjSHPaaj5P8PfOAQaqGe4d8rVm0YQ6MA3C2t/KmbMHNQESHlMt702 j4BIXiWUZ3FFkmhMWqgDtR6z9qNOqSZcj67aP9+e+1D81Ooyd0eyBbX0AAvlIg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y8XDv0ZZpzHR2; Fri, 13 Dec 2024 01:43:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BD1hxe6033788; Fri, 13 Dec 2024 01:43:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BD1hxKG033785; Fri, 13 Dec 2024 01:43:59 GMT (envelope-from git) Date: Fri, 13 Dec 2024 01:43:59 GMT Message-Id: <202412130143.4BD1hxKG033785@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: fea53bf43f85 - stable/14 - savecore: Add a livedump regression test List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fea53bf43f85a6b42245fe5f1330eea27cf6f0db Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fea53bf43f85a6b42245fe5f1330eea27cf6f0db commit fea53bf43f85a6b42245fe5f1330eea27cf6f0db Author: Mark Johnston AuthorDate: 2024-11-25 21:12:12 +0000 Commit: Mark Johnston CommitDate: 2024-12-13 01:34:14 +0000 savecore: Add a livedump regression test MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47715 (cherry picked from commit 73465bb47bb37e6efdc61827e260a070dda0a0dc) --- etc/mtree/BSD.tests.dist | 2 ++ sbin/savecore/Makefile | 3 ++ sbin/savecore/tests/Makefile | 3 ++ sbin/savecore/tests/livedump_test.sh | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index b152fb6e5271..7fa7ed24f897 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -477,6 +477,8 @@ .. route .. + savecore + .. sysctl .. .. diff --git a/sbin/savecore/Makefile b/sbin/savecore/Makefile index fe10df459309..338d168bba0a 100644 --- a/sbin/savecore/Makefile +++ b/sbin/savecore/Makefile @@ -19,4 +19,7 @@ CFLAGS+= -DWITH_CASPER LIBADD+= casper cap_fileargs cap_syslog .endif +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include diff --git a/sbin/savecore/tests/Makefile b/sbin/savecore/tests/Makefile new file mode 100644 index 000000000000..b58e79f518ef --- /dev/null +++ b/sbin/savecore/tests/Makefile @@ -0,0 +1,3 @@ +ATF_TESTS_SH= livedump_test + +.include diff --git a/sbin/savecore/tests/livedump_test.sh b/sbin/savecore/tests/livedump_test.sh new file mode 100644 index 000000000000..42c726bfad4e --- /dev/null +++ b/sbin/savecore/tests/livedump_test.sh @@ -0,0 +1,54 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 Mark Johnston +# + +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 +}