From nobody Mon Nov 25 21:13:01 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 4Xxz255lXmz5fD1D; Mon, 25 Nov 2024 21:13:01 +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 4Xxz25410Dz3ypV; Mon, 25 Nov 2024 21:13:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732569181; 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=4mbUl/WzNM7xjChJt/4qkXt5Nk1lKo5graM9uH873eQ=; b=I/uUaItw/FHhLwcM8k34duie9OKGqaj0GIBoXrS/1IkTkMWzRmztbDeuAJ0T14Kgl1/ZNe XOyRuvNttIWUzX99mHbQIXQkT3OKC4EYOyFTqNrW+SnNGk9f2qBqYIhW9iP04STmURKOFN yP/Qq8h7E25VW+v0wF3R7koHNR+IA/mEgN7mla1nR4R1pVx035WCu/QfUVvPia4ApDY9iU s1EUMBfrGQ4//AvH0gMUnF9rJt/Ci/CwNj162F9caGlsmXJOOjwwPEwQqntU8eInb8ssaU 49acLlcywU3omJy9M1Flj6JpRrCUT3ENhgxeVtRKGP7GOThZQBdaneajSd0YQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732569181; 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=4mbUl/WzNM7xjChJt/4qkXt5Nk1lKo5graM9uH873eQ=; b=RfqsCLurkx2KkzeZ73kmrzHErM91QrDvYFVODEo51e00lwpQKD8rxJ428T/akLhpoSwtph ir9HsvrqscT4CVAC8bbHlPkk/ZR03AZI7OlazNLwASZbpmbc7ETkafgla4Z1Mb9ao5Kn0J 1xVHouuOoJBcG0ViU0ktMcdzBoXdlo6Ss9az5xo71g4iVAJwSyHHA0GvgJB+fWtX9qkB8d Uh0WhW+j6B3bnPb5HCEBQOWZU8EciRb525HD4bLT8O/CchtIQhx3ALZVm+ek7+di6a5HmO xmKQoLb5oYMz8NlOz0uL/ZUzRBqCv2r6z9VGK1fnV7J0SW9eBFBW90QUT60mcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732569181; a=rsa-sha256; cv=none; b=Esaevw4QOjye2YXQMF/WFtCQ6Vx+1Jf4/DisucxjjQ2FgKoQUntPkmOvjYDc321pUoVKBb UusMnhGqIpQUheXCpgjx6SHsSVAkmeD4WKDjz3bVhXLmv6na7jpSyDcn6erkpd6NRc1KHC rYT1lblEl+6ZFkPeCpPZ5ht6lQNp/LHgGruSSzqz69cBibhl3hPNkvVL4kUm+OBsYQP0Pv anckM4IfmYno9sUg2L01FFuiYAiWh6BfZxWbAyhMMKod0KaIippGBYOSEAqT/Du0VnQlAr d2D1zjt3ElE74dgDKTjQjlblxDHzwnuo+GOtvhPjJJJAh1TFNLD1mRcZN2IN8w== 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 4Xxz253cqSzwrn; Mon, 25 Nov 2024 21:13:01 +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 4APLD1MV028065; Mon, 25 Nov 2024 21:13:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4APLD1LN028062; Mon, 25 Nov 2024 21:13:01 GMT (envelope-from git) Date: Mon, 25 Nov 2024 21:13:01 GMT Message-Id: <202411252113.4APLD1LN028062@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 73465bb47bb3 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 73465bb47bb37e6efdc61827e260a070dda0a0dc Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=73465bb47bb37e6efdc61827e260a070dda0a0dc commit 73465bb47bb37e6efdc61827e260a070dda0a0dc Author: Mark Johnston AuthorDate: 2024-11-25 21:12:12 +0000 Commit: Mark Johnston CommitDate: 2024-11-25 21:12:51 +0000 savecore: Add a livedump regression test MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47715 --- 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 beae521789c0..e9ba0f689678 100644 --- 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 index 8d22ab21b6da..7e194a62deb1 100644 --- a/sbin/savecore/Makefile +++ b/sbin/savecore/Makefile @@ -18,4 +18,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 +}