summaryrefslogtreecommitdiffstats
path: root/src/test/test-tpm2.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-13 16:41:16 +0100
committerLennart Poettering <lennart@poettering.net>2023-11-13 16:50:55 +0100
commit47a7a4d404366cf6efc89f7ea1bfe30b8a8d0299 (patch)
treec5f17155b93d32f70285af30152d9b7c34040bb7 /src/test/test-tpm2.c
parentutil-lib: share plymouth client code (diff)
downloadsystemd-47a7a4d404366cf6efc89f7ea1bfe30b8a8d0299.tar.xz
systemd-47a7a4d404366cf6efc89f7ea1bfe30b8a8d0299.zip
tests: add macro for generating function enter log message
The test-tpm2 test multiplexes a bunch of tests from a single entrypoint test that creates the TPM2 connection. This means we only get the nice log output which test we are looking for once for the entrypoint. Let's add a macro that allows it to nicely generate it for the inner tests too and use it.
Diffstat (limited to 'src/test/test-tpm2.c')
-rw-r--r--src/test/test-tpm2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test-tpm2.c b/src/test/test-tpm2.c
index 0469625ab1..c3506936e4 100644
--- a/src/test/test-tpm2.c
+++ b/src/test/test-tpm2.c
@@ -995,6 +995,8 @@ TEST(tpm2_get_srk_template) {
}
static void check_best_srk_template(Tpm2Context *c) {
+ TEST_LOG_FUNC();
+
TPMT_PUBLIC template;
assert_se(tpm2_get_best_srk_template(c, &template) >= 0);
@@ -1009,6 +1011,8 @@ static void check_best_srk_template(Tpm2Context *c) {
static void check_test_parms(Tpm2Context *c) {
assert(c);
+ TEST_LOG_FUNC();
+
TPMU_PUBLIC_PARMS parms = {
.symDetail.sym = {
.algorithm = TPM2_ALG_AES,
@@ -1031,6 +1035,8 @@ static void check_test_parms(Tpm2Context *c) {
static void check_supports_alg(Tpm2Context *c) {
assert(c);
+ TEST_LOG_FUNC();
+
/* Test invalid algs */
assert_se(!tpm2_supports_alg(c, TPM2_ALG_ERROR));
assert_se(!tpm2_supports_alg(c, TPM2_ALG_LAST + 1));
@@ -1044,6 +1050,8 @@ static void check_supports_alg(Tpm2Context *c) {
static void check_supports_command(Tpm2Context *c) {
assert(c);
+ TEST_LOG_FUNC();
+
/* Test invalid commands. TPM specification Part 2 ("Structures") section "TPM_CC (Command Codes)"
* states bits 31:30 and 28:16 are reserved and must be 0. */
assert_se(!tpm2_supports_command(c, UINT32_C(0x80000000)));
@@ -1062,6 +1070,8 @@ static void check_supports_command(Tpm2Context *c) {
}
static void check_get_or_create_srk(Tpm2Context *c) {
+ TEST_LOG_FUNC();
+
_cleanup_free_ TPM2B_PUBLIC *public = NULL;
_cleanup_free_ TPM2B_NAME *name = NULL, *qname = NULL;
_cleanup_(tpm2_handle_freep) Tpm2Handle *handle = NULL;
@@ -1132,6 +1142,8 @@ static int check_calculate_seal(Tpm2Context *c) {
assert(c);
int r;
+ TEST_LOG_FUNC();
+
_cleanup_free_ TPM2B_PUBLIC *srk_public = NULL;
assert_se(tpm2_get_srk(c, NULL, &srk_public, NULL, NULL, NULL) >= 0);
calculate_seal_and_unseal(c, TPM2_SRK_HANDLE, srk_public);
@@ -1204,6 +1216,8 @@ static void check_seal_unseal(Tpm2Context *c) {
assert(c);
+ TEST_LOG_FUNC();
+
check_seal_unseal_for_handle(c, 0);
check_seal_unseal_for_handle(c, TPM2_SRK_HANDLE);