public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ronny Gutbrod" <gentoo@tastytea.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/guru:master commit in: app-crypt/tpm2-openssl/
Date: Wed, 28 Sep 2022 16:05:01 +0000 (UTC)	[thread overview]
Message-ID: <1664316552.f967da3dc0d646f757b7a7807ee89f7e0181dbc7.tastytea@gentoo> (raw)

commit:     f967da3dc0d646f757b7a7807ee89f7e0181dbc7
Author:     Christopher Byrne <salah.coronya <AT> gmail <DOT> com>
AuthorDate: Tue Sep 27 22:05:33 2022 +0000
Commit:     Ronny Gutbrod <gentoo <AT> tastytea <DOT> de>
CommitDate: Tue Sep 27 22:09:12 2022 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=f967da3d

app-crypt/tpm2-openssl: Enable tests

Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com>

 app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild | 76 ++++++++++++++++++++++--
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild b/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
index bce9e94a4..2cb119589 100644
--- a/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
+++ b/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
@@ -13,18 +13,82 @@ LICENSE="BSD"
 
 SLOT="0/${PV}"
 KEYWORDS="~amd64"
-
-# Needs IBM's software TPM simulator, which isn't in Portage
-RESTRICT="test"
+IUSE="test"
 
 RDEPEND=">=app-crypt/tpm2-tss-3.2.0:=
 	=dev-libs/openssl-3.0*:0="
 
-DEPEND="${RDEPEND}"
+DEPEND="${RDEPEND}
+	test? ( app-crypt/swtpm
+		app-crypt/tpm2-abrmd
+		app-crypt/tpm2-tools )"
 
 BDEPEND="sys-devel/autoconf-archive
 	 virtual/pkgconfig"
 
+RESTRICT="!test? ( test )"
+
+dbus_run() {
+	(
+		# start isolated dbus session bus
+		dbus_data=$(dbus-launch --sh-syntax) || exit
+		eval "${dbus_data}"
+
+		$@
+		ret=${?}
+
+		kill "${DBUS_SESSION_BUS_PID}"
+		exit "${ret}"
+	) || die
+}
+
+tpm2_run_with_emulator() {
+	export XDG_CONFIG_HOME=${T}/.config/swtpm
+	"${BROOT}"/usr/share/swtpm/swtpm-create-user-config-files || die
+
+	mkdir -p ${XDG_CONFIG_HOME}/mytpm1 || die
+	swtpm_setup_args=(
+		--tpm2
+		--tpmstate ${XDG_CONFIG_HOME}/mytpm1
+		--createek
+		--allow-signing
+		--decryption
+		--create-ek-cert
+		--create-platform-cert
+		--lock-nvram
+		--overwrite
+		--display
+	)
+	swtpm_setup "${swtpm_setup_args[@]}" || die
+
+	swtpm_socket_args=(
+		--tpm2
+		--tpmstate dir=${XDG_CONFIG_HOME}/mytpm1
+		--flags startup-clear
+		--ctrl type=unixio,path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket.ctrl
+		--server type=unixio,path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket
+		--pid file=${XDG_CONFIG_HOME}/mytpm1/swtpm.pid
+		--daemon
+	)
+	swtpm socket "${swtpm_socket_args[@]}" || die
+
+	tpm2_abrmd_args=(
+		--logger=stdout
+		--tcti=swtpm:path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket
+		--session
+		--flush-all
+	)
+	tpm2-abrmd "${tpm2_abrmd_args[@]}" &
+
+	export TPM2OPENSSL_TCTI="tabrmd:bus_type=session"
+	export TPM2TOOLS_TCTI="tabrmd:bus_type=session"
+
+	$@ || die
+
+	# When swtpm dies, tmp2-abrmd will exit
+	kill $(< ${XDG_CONFIG_HOME}/mytpm1/swtpm.pid) || die
+}
+
 src_prepare() {
 	# See bug #833887 (and similar); eautoreconf means version information
 	# could be incorrectly embedded
@@ -42,3 +106,7 @@ src_install() {
 
 	# No libtool files are install, so nothing to check for bug #833887
 }
+
+src_test() {
+	dbus_run tpm2_run_with_emulator make check
+}


             reply	other threads:[~2022-09-28 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 16:05 Ronny Gutbrod [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-11 19:30 [gentoo-commits] repo/proj/guru:master commit in: app-crypt/tpm2-openssl/ Andrew Ammerlaan
2022-10-11 19:30 Andrew Ammerlaan
2022-09-28 16:05 Ronny Gutbrod
2022-09-08 10:06 [gentoo-commits] repo/proj/guru:dev " Andrew Ammerlaan
2022-09-08 10:06 ` [gentoo-commits] repo/proj/guru:master " Andrew Ammerlaan
2022-06-06 16:28 Florian Schmaus
2022-04-17 18:13 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1664316552.f967da3dc0d646f757b7a7807ee89f7e0181dbc7.tastytea@gentoo \
    --to=gentoo@tastytea.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox