From 38ec19b7b1b48422a53142236c8f98b77711b87b Mon Sep 17 00:00:00 2001 From: Xiao Date: Wed, 6 Nov 2024 10:11:09 +0800 Subject: [PATCH] Fix the failure of test_spdm_responder when it is run multiple times. Signed-off-by: Xiao --- .../set_key_pair_info_ack.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/unit_test/test_spdm_responder/set_key_pair_info_ack.c b/unit_test/test_spdm_responder/set_key_pair_info_ack.c index ff40f196fcf..ff8d6a49c8d 100644 --- a/unit_test/test_spdm_responder/set_key_pair_info_ack.c +++ b/unit_test/test_spdm_responder/set_key_pair_info_ack.c @@ -476,6 +476,31 @@ void libspdm_test_responder_set_key_pair_info_ack_case3(void **state) assert_int_equal(spdm_response->header.param1, SPDM_ERROR_CODE_INVALID_REQUEST); assert_int_equal(spdm_response->header.param2, 0); + + /*Before reset, change: remove an association with slot*/ + set_key_pair_info_request_size = + sizeof(spdm_set_key_pair_info_request_t) + + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint8_t); + + libspdm_zero_mem(set_key_pair_info_request, set_key_pair_info_request_size); + set_key_pair_info_request->header.spdm_version = SPDM_MESSAGE_VERSION_13; + set_key_pair_info_request->header.request_response_code = SPDM_SET_KEY_PAIR_INFO; + set_key_pair_info_request->header.param1 = SPDM_SET_KEY_PAIR_INFO_CHANGE_OPERATION; + set_key_pair_info_request->header.param2 = 0; + set_key_pair_info_request->key_pair_id = 0x1; + + response_size = sizeof(response); + status = libspdm_get_response_set_key_pair_info_ack( + spdm_context, set_key_pair_info_request_size, + set_key_pair_info_request, &response_size, response); + assert_int_equal(status, LIBSPDM_STATUS_SUCCESS); + assert_int_equal(response_size, sizeof(spdm_error_response_t)); + spdm_response = (void *)response; + assert_int_equal(spdm_response->header.request_response_code, + SPDM_ERROR); + assert_int_equal(spdm_response->header.param1, + SPDM_ERROR_CODE_RESET_REQUIRED); + assert_int_equal(spdm_response->header.param2, 0); } int libspdm_responder_set_key_pair_info_ack_test_main(void)