Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more tests to run installed #892

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/_test_encrypted_state
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--key "file=$keyfile,mode=aes-cbc,format=hex,remove" \
--log "file=$logfile"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -143,7 +143,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--key "file=$binkeyfile,mode=aes-cbc,format=binary,remove" \
--log "file=$logfile"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error (2): ${SWTPM_INTERFACE} TPM did not start."
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_getcap
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

Expand Down
4 changes: 2 additions & 2 deletions tests/_test_hashing
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_hashing2
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_init
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

Expand All @@ -40,7 +40,7 @@ run_swtpm "${SWTPM_INTERFACE}" \
--tpmstate "dir=$TPM_PATH" \
--pid "file=$PID_FILE"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_locality
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
10 changes: 5 additions & 5 deletions tests/_test_migration_key
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

# make a backup of the volatile state
TPM_PATH=$tpmstatedir
Expand All @@ -55,7 +55,7 @@ cp "${TESTDIR}"/data/tpmstate1/* "$TPM_PATH"
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--migration-key "pwdfile=$migpwdfile,remove=false,kdf=sha512"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -149,7 +149,7 @@ echo "Test 1: Ok"
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--migration-key "pwdfile=$migpwdfile,remove=false,kdf=sha512"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -194,7 +194,7 @@ echo "Test 2: Ok"
# This time we make this fail since we don't provide the migration key
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -231,7 +231,7 @@ echo "Test 3: Ok"
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--migration-key "pwdfile=$migpwdfile,remove=true,kdf=sha512"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_print_capabilities
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ TESTDIR=${abs_top_testdir:-$(dirname "$0")}

PATH=$ROOT/src/swtpm:$PATH

[ "${SWTPM_IFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_IFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

if ! msg="$(${SWTPM_EXE} "${SWTPM_IFACE}" --print-capabilities 2>&1)"; then
echo "Error: Could not pass --print-capabilities"
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_print_states
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ TESTDIR=${abs_top_testdir:-$(dirname "$0")}

PATH=$ROOT/src/swtpm:$PATH

[ "${SWTPM_IFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_IFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

trap "cleanup" SIGTERM EXIT

Expand Down
8 changes: 4 additions & 4 deletions tests/_test_resume_volatile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

TPM_PATH=$tpmstatedir
VOLATILE_STATE_FILE="$TPM_PATH/tpm-00.volatilestate"
Expand All @@ -41,7 +41,7 @@ cp "${TESTDIR}"/data/tpmstate1/* "${TPM_PATH}"

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -92,7 +92,7 @@ cp "${TESTDIR}"/data/tpmstate2/* "${TPM_PATH}"
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--key "pwdfile=${TESTDIR}/data/tpmstate2/pwdfile.txt,kdf=sha512"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -145,7 +145,7 @@ cp "${TESTDIR}"/data/tpmstate2b/* "${TPM_PATH}"
TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--key "pwdfile=${TESTDIR}/data/tpmstate2b/pwdfile.txt,mode=aes-256-cbc"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
8 changes: 4 additions & 4 deletions tests/_test_save_load_encrypted_state
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

Expand All @@ -45,7 +45,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--log "file=$logfile"
exec 101>&-

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -290,7 +290,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--log "file=$logfile"
exec 101>&-

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -364,7 +364,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--key "pwdfile=$keyfile,mode=aes-256-cbc" \
--log "file=$logfile"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_save_load_state
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
${BACKEND_PARAM:+${BACKEND_PARAM}} \
--log "file=$logfile"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_setbuffersize
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

Expand Down
4 changes: 2 additions & 2 deletions tests/_test_swtpm_bios
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

run_swtpm "${SWTPM_INTERFACE}" --tpmstate "dir=$TPM_PATH" --pid "file=$PID_FILE"

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_tpm2_avoid_da_lockout
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
source "${TESTDIR}/test_common"
[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--tpm2 \
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_tpm2_derived_keys
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

TPM_PATH=$tpmstatedir

Expand Down
6 changes: 3 additions & 3 deletions tests/_test_tpm2_encrypted_state
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

Expand All @@ -44,7 +44,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--log "file=$logfile" \
--tpm2

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down Expand Up @@ -145,7 +145,7 @@ TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" \
--log "file=$logfile" \
--tpm2

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error (2): ${SWTPM_INTERFACE} TPM did not start."
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_tpm2_file_permissions
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == cuse ] && source "${TESTDIR}/test_cuse"
SWTPM_SETUP_CONF=${TPM_PATH}/swtpm_setup.conf

cat <<_EOF_ > "${SWTPM_SETUP_CONF}"
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_tpm2_getcap
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" --tpm2

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
4 changes: 2 additions & 2 deletions tests/_test_tpm2_hashing
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ function cleanup()

trap "cleanup" EXIT

[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"
source "${TESTDIR}/common"
[ "${SWTPM_INTERFACE}" == "cuse" ] && source "${TESTDIR}/test_cuse"

rm -f "$STATE_FILE" "$VOLATILE_STATE_FILE" 2>/dev/null

TPM_PATH=$TPM_PATH run_swtpm "${SWTPM_INTERFACE}" --tpm2

display_processes_by_name "$SWTPM"
display_processes_by_name "swtpm"

if ! kill_quiet -0 "${SWTPM_PID}"; then
echo "Error: ${SWTPM_INTERFACE} TPM did not start."
Expand Down
Loading