mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-10 15:45:15 -04:00
app-crypt/tpm2-openssl: Enable tests
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user