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

Ensure that cached.csr always exists at the beginning #2636

Merged
merged 1 commit into from
Mar 30, 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
12 changes: 12 additions & 0 deletions unit_test/test_spdm_requester/get_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ bool libspdm_read_requester_gen_csr(void **csr_data, size_t *csr_len)
return res;
}

/*ensure that cached.csr exists in test_csr at the beginning*/
void libspdm_clear_cached_csr()
{
char *new_name = "test_csr/cached.csr";
char *file_name = "test_csr/cached.staging";

rename(file_name, new_name);
}

libspdm_return_t libspdm_requester_get_csr_test_send_message(
void *spdm_context, size_t request_size, const void *request,
uint64_t timeout)
Expand Down Expand Up @@ -556,6 +565,9 @@ int libspdm_requester_get_csr_test_main(void)
libspdm_setup_test_context(
&m_libspdm_requester_get_csr_test_context);

/*ensure that cached.csr exists in test_csr at the beginning*/
libspdm_clear_cached_csr();

return cmocka_run_group_tests(spdm_requester_get_csr_tests,
libspdm_unit_test_group_setup,
libspdm_unit_test_group_teardown);
Expand Down
12 changes: 12 additions & 0 deletions unit_test/test_spdm_responder/csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ bool libspdm_set_csr_after_reset()
return true;
}

/*ensure that cached.csr exists in test_csr at the beginning*/
void libspdm_clear_cached_csr()
{
char *new_name = "test_csr/cached.csr";
char *file_name = "test_csr/cached.staging";

rename(file_name, new_name);
}

/*clean the cached last SPDM csr request*/
void libspdm_test_clear_cached_last_request()
{
Expand Down Expand Up @@ -1929,6 +1938,9 @@ int libspdm_responder_csr_test_main(void)

libspdm_setup_test_context(&m_libspdm_responder_csr_test_context);

/*ensure that cached.csr exists in test_csr at the beginning*/
libspdm_clear_cached_csr();

return cmocka_run_group_tests(spdm_responder_csr_tests,
libspdm_unit_test_group_setup,
libspdm_unit_test_group_teardown);
Expand Down
Loading