Skip to content

Commit

Permalink
regression_1041: give 5 seconds for /dev/tpm0 to appear
Browse files Browse the repository at this point in the history
It does take some time for the kernel to probe the fTPM device, and
therefore if regression_1041 is run immediately after boot it may fail.
Add a 5 second timeout to make the test reliable.

Signed-off-by: Jerome Forissier <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
  • Loading branch information
jforissier committed Jan 15, 2025
1 parent 44ec72b commit a1739a1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion host/xtest/regression_1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -3371,6 +3371,8 @@ static void xtest_tee_test_1041(ADBG_Case_t *c)
TEEC_Session sess = { };
uint32_t ret_orig = 0;
struct stat sb = { };
bool found = false;
int i = 0;

res = xtest_teec_open_session(&sess, &(const TEEC_UUID)TA_FTPM_UUID,
NULL, &ret_orig);
Expand All @@ -3381,7 +3383,19 @@ static void xtest_tee_test_1041(ADBG_Case_t *c)
if (res != TEEC_ERROR_BUSY && ADBG_EXPECT_TEEC_SUCCESS(c, res))
TEEC_CloseSession(&sess);

if (!ADBG_EXPECT_COMPARE_SIGNED(c, stat(fname, &sb), ==, 0)) {
/*
* Check for the presence of the TPM device. Give the kernel some time
* (5 seconds) otherwise the test may fail if run immediately after
* boot.
*/
for (i = 0; i < 5; i++) {
if (stat(fname, &sb) == 0) {
found = true;
break;
}
sleep(1);
}
if (!ADBG_EXPECT_TRUE(c, found)) {
Do_ADBG_Log("stat(\"%s\"): %s", fname, strerror(errno));
if (res != TEEC_ERROR_BUSY)
Do_ADBG_Log("Perhaps fTPM hasn't finished probing");
Expand Down

0 comments on commit a1739a1

Please sign in to comment.