git: 19a847e5f282 - main - kinst: Add a rudimentary regression test case

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 11 Oct 2022 22:35:41 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=19a847e5f2820202243b04f73017a9e7def63d11

commit 19a847e5f2820202243b04f73017a9e7def63d11
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-09-29 13:44:39 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-10-11 22:19:55 +0000

    kinst: Add a rudimentary regression test case
    
    The test instruments a number of large, frequently called kernel
    functions while generating load in the background.
    
    MFC after:      3 months
---
 .../cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh  | 46 ++++++++++++++++++++++
 cddl/usr.sbin/dtrace/tests/amd64/Makefile          |  3 +-
 cddl/usr.sbin/dtrace/tests/amd64/kinst/Makefile    | 19 +++++++++
 etc/mtree/BSD.tests.dist                           |  2 +
 4 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh
new file mode 100644
index 000000000000..23019fb41f41
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/amd64/kinst/tst.basic.ksh
@@ -0,0 +1,46 @@
+#!/usr/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2022 Mark Johnston <markj@FreeBSD.org>
+#
+
+script()
+{
+	$dtrace -q -s /dev/stdin <<__EOF__
+kinst::vm_fault: {}
+kinst::amd64_syscall: {}
+kinst::exit1: {}
+
+tick-10s {exit(0);}
+__EOF__
+}
+
+spin()
+{
+	while true; do
+		ls -la / >/dev/null 2>&1
+	done
+}
+
+if [ $# != 1 ]; then
+	echo expected one argument: '<'dtrace-path'>'
+	exit 2
+fi
+
+dtrace=$1
+
+spin &
+child=$!
+
+script
+exit $?
diff --git a/cddl/usr.sbin/dtrace/tests/amd64/Makefile b/cddl/usr.sbin/dtrace/tests/amd64/Makefile
index 39ccd333bedf..db421ea0880f 100644
--- a/cddl/usr.sbin/dtrace/tests/amd64/Makefile
+++ b/cddl/usr.sbin/dtrace/tests/amd64/Makefile
@@ -1,7 +1,8 @@
 # $FreeBSD$
 
 TESTSDIR=	${TESTSBASE}/cddl/usr.sbin/dtrace/amd64
-TESTS_SUBDIRS+= arrays
+TESTS_SUBDIRS+= arrays \
+		kinst
 
 .PATH:		${.CURDIR:H:H:H:H:H}/tests
 KYUAFILE=	YES
diff --git a/cddl/usr.sbin/dtrace/tests/amd64/kinst/Makefile b/cddl/usr.sbin/dtrace/tests/amd64/kinst/Makefile
new file mode 100644
index 000000000000..52568df07e07
--- /dev/null
+++ b/cddl/usr.sbin/dtrace/tests/amd64/kinst/Makefile
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+#
+# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh.
+#
+
+PACKAGE=	tests
+
+${PACKAGE}FILES= \
+     tst.basic.ksh  \
+
+TESTEXES= \
+
+
+CFILES= \
+
+
+
+.include "../../dtrace.test.mk"
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 394b2ec90dcd..c83f720e1de3 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -253,6 +253,8 @@
                 amd64
                     arrays
                     ..
+                    kinst
+                    ..
                 ..
             ..
             zfsd