Skip to content

Commit

Permalink
tests: teach them to run installed
Browse files Browse the repository at this point in the history
Rely on "common" variables.

Signed-off-by: Marc-André Lureau <[email protected]>
  • Loading branch information
elmarco authored and stefanberger committed Jul 15, 2024
1 parent 90bd137 commit 24b8e20
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 22 deletions.
1 change: 0 additions & 1 deletion tests/_test_swtpm_bios
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
ROOT=${abs_top_builddir:-$(pwd)/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}

SWTPM_BIOS=$ROOT/src/swtpm_bios/swtpm_bios
VTPM_NAME="vtpm-test-swtpm-bios"
SWTPM_DEV_NAME="/dev/${VTPM_NAME}"
TPM_PATH="$(mktemp -d)" || exit 1
Expand Down
2 changes: 2 additions & 0 deletions tests/common
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ if [ -z "${INSTALLED}" ]; then
SWTPM_BIOS=${SWTPM_BIOS:-${ROOT}/src/swtpm_bios/swtpm_bios}
SWTPM_SETUP=${SWTPM_SETUP:-${ROOT}/src/swtpm_setup/swtpm_setup}
SWTPM_CERT=${SWTPM_CERT:-${ROOT}/src/swtpm_cert/swtpm_cert}
SWTPM_LOCALCA=${SWTPM_LOCALCA:-${ROOT}/src/swtpm_localca/swtpm_localca}
SWTPM_SETUP_CONF="${ROOT}/samples/swtpm_setup.conf"
else
SWTPM_EXE=${SWTPM_EXE:-$(type -P swtpm)}
SWTPM_IOCTL=${SWTPM_IOCTL:-$(type -P swtpm_ioctl)}
SWTPM_BIOS=${SWTPM_BIOS:-$(type -P swtpm_bios)}
SWTPM_SETUP=${SWTPM_SETUP:-$(type -P swtpm_setup)}
SWTPM_CERT=${SWTPM_CERT:-$(type -P swtpm_cert)}
SWTPM_LOCALCA=${SWTPM_LOCALCA:-$(type -P swtpm_localca)}
SWTPM_SETUP_CONF="$(dirname "$0")/swtpm_setup.conf"
fi

Expand Down
4 changes: 1 addition & 3 deletions tests/test_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ FILESIZES=(
source "${TESTDIR}/common"
skip_test_no_tpm12 "${SWTPM_EXE}"

SWTPM=swtpm
SWTPM_EXE=${SWTPM_EXE:-$ROOT/src/swtpm/$SWTPM}
TPMDIR="$(mktemp -d)" || exit 1
# filesystem privileges require to run swtpm_setup as root during test
TPMAUTHORING="$ROOT/src/swtpm_setup/swtpm_setup --config ${SWTPM_SETUP_CONF}"
TPMAUTHORING="$SWTPM_SETUP --config ${SWTPM_SETUP_CONF}"
PATH=${ROOT}/src/swtpm_bios:${TESTDIR}:$PATH

trap "cleanup" SIGTERM EXIT
Expand Down
2 changes: 1 addition & 1 deletion tests/test_swtpm_cert
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ROOT=${abs_top_builddir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:=$(dirname "$0")}

SWTPM_CERT=${SWTPM_CERT:-${ROOT}/src/swtpm_cert/swtpm_cert}
source "${TESTDIR}/common"

trap "cleanup" SIGTERM EXIT

Expand Down
2 changes: 0 additions & 2 deletions tests/test_swtpm_setup_create_cert
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ TESTDIR=${abs_top_testdir:-$(dirname "$0")}
source "${TESTDIR}/common"
skip_test_no_tpm12 "${SWTPM_EXE}"

SWTPM_LOCALCA=${ROOT}/src/swtpm_localca/swtpm_localca

workdir="$(mktemp -d)" || exit 1

SIGNINGKEY=${workdir}/signingkey.pem
Expand Down
6 changes: 1 addition & 5 deletions tests/test_tpm2_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ skip_test_no_tpm20 "${SWTPM_EXE}"

PATH=$ROOT/src/swtpm:$PATH

source "${abs_top_builddir:-$(dirname "$0")/..}/tests/test_config"

PARAMETERS=(
""
"--createek"
Expand Down Expand Up @@ -62,10 +60,8 @@ exec 101<"${TESTDIR}/data/pwdfile.txt"

# produced file size is always the same with TPM2

SWTPM=swtpm
SWTPM_EXE=$ROOT/src/swtpm/$SWTPM
TPMDIR="$(mktemp -d)" || exit 1
TPMAUTHORING="$ROOT/src/swtpm_setup/swtpm_setup --tpm2 --config ${SWTPM_SETUP_CONF}"
TPMAUTHORING="$SWTPM_SETUP --tpm2 --config ${SWTPM_SETUP_CONF}"
PATH=${ROOT}/src/swtpm_bios:$PATH


Expand Down
2 changes: 1 addition & 1 deletion tests/test_tpm2_swtpm_cert
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ROOT=${abs_top_builddir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}

SWTPM_CERT=${SWTPM_CERT:-${ROOT}/src/swtpm_cert/swtpm_cert}
source "${TESTDIR}/common"

cert="$(mktemp)" || exit 1

Expand Down
2 changes: 1 addition & 1 deletion tests/test_tpm2_swtpm_cert_ecc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ROOT=${abs_top_builddir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}

SWTPM_CERT=${SWTPM_CERT:-${ROOT}/src/swtpm_cert/swtpm_cert}
source "${TESTDIR}/common"

cert="$(mktemp)" || exit 1

Expand Down
3 changes: 1 addition & 2 deletions tests/test_tpm2_swtpm_localca
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# For the license, see the LICENSE file in the root directory.
#set -x

ROOT=${abs_top_builddir:-$(dirname "$0")/..}
TOPBUILD=${abs_top_builddir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}

SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca

workdir="$(mktemp -d "/tmp/path with spaces.XXXXXX")" || exit 1

ek="80" # 2048 bit key must have highest bit set
Expand Down
6 changes: 2 additions & 4 deletions tests/test_tpm2_swtpm_localca_pkcs11.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
# For the license, see the LICENSE file in the root directory.
#set -x

TOPBUILD=${abs_top_builddir:-$(dirname "$0")/..}
ROOT=${abs_top_builddir:-$(dirname "$0")/..}
TESTDIR=${abs_top_testdir:-$(dirname "$0")}

SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca

workdir="$(mktemp -d)" || exit 1

# Have softhsm_setup use 'workdir'.
Expand All @@ -26,7 +24,7 @@ done
ISSUERCERT="${workdir}/issuercert.pem"
CERTSERIAL="${workdir}/certserial"

PATH="${TOPBUILD}/src/swtpm_cert:$PATH"
PATH="${ROOT}/src/swtpm_cert:$PATH"

source "${TESTDIR}/common"

Expand Down
2 changes: 0 additions & 2 deletions tests/test_tpm2_swtpm_setup_create_cert
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ TESTDIR=${abs_top_testdir:-$(dirname "$0")}
source "${TESTDIR}/common"
skip_test_no_tpm20 "${SWTPM_EXE}"

SWTPM_LOCALCA=${TOPBUILD}/src/swtpm_localca/swtpm_localca

workdir="$(mktemp -d "/tmp/path with spaces.XXXXXX")" || exit 1

SIGNINGKEY=${workdir}/signingkey.pem
Expand Down

0 comments on commit 24b8e20

Please sign in to comment.