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

Fix unit tests #2819

Closed
wants to merge 4 commits into from
Closed
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
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/challenge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3950,13 +3950,6 @@ void libspdm_test_requester_challenge_case28(void **state)
free(data);
}

libspdm_test_context_t m_libspdm_requester_challenge_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_challenge_test_send_message,
libspdm_requester_challenge_test_receive_message,
};

int libspdm_requester_challenge_test_main(void)
{
const struct CMUnitTest spdm_requester_challenge_tests[] = {
Expand Down Expand Up @@ -4012,7 +4005,14 @@ int libspdm_requester_challenge_test_main(void)
cmocka_unit_test(libspdm_test_requester_challenge_case28),
};

libspdm_setup_test_context(&m_libspdm_requester_challenge_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_challenge_test_send_message,
libspdm_requester_challenge_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_challenge_tests,
libspdm_unit_test_group_setup,
Expand Down
17 changes: 8 additions & 9 deletions unit_test/test_spdm_requester/chunk_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,6 @@ void libspdm_test_requester_chunk_get_case4(void** state)
}
#endif

libspdm_test_context_t m_libspdm_requester_chunk_get_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_chunk_get_test_send_message,
libspdm_requester_chunk_get_test_receive_message,
};

int libspdm_requester_chunk_get_test_main(void)
{
/* Test the CHUNK_GET handlers in various requester handlers */
Expand All @@ -861,8 +854,14 @@ int libspdm_requester_chunk_get_test_main(void)
#endif
};

libspdm_setup_test_context(
&m_libspdm_requester_chunk_get_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_chunk_get_test_send_message,
libspdm_requester_chunk_get_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_chunk_get_tests,
libspdm_unit_test_group_setup,
Expand Down
17 changes: 8 additions & 9 deletions unit_test/test_spdm_requester/chunk_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,6 @@ void libspdm_test_requester_chunk_send_case12(void** state)
assert_int_equal(status, LIBSPDM_STATUS_ERROR_PEER);
}

libspdm_test_context_t m_libspdm_requester_chunk_send_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_chunk_send_test_send_message,
libspdm_requester_chunk_send_test_receive_message,
};

int libspdm_requester_chunk_send_test_main(void)
{
/* Test the CHUNK_SEND handlers in various requester handlers */
Expand Down Expand Up @@ -509,8 +502,14 @@ int libspdm_requester_chunk_send_test_main(void)
cmocka_unit_test(libspdm_test_requester_chunk_send_case12),
};

libspdm_setup_test_context(
&m_libspdm_requester_chunk_send_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_chunk_send_test_send_message,
libspdm_requester_chunk_send_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_chunk_send_tests,
libspdm_unit_test_group_setup,
Expand Down
12 changes: 6 additions & 6 deletions unit_test/test_spdm_requester/encap_certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,6 @@ void libspdm_test_requester_encap_certificate_case7(void **state)
free(data);
}

libspdm_test_context_t m_libspdm_requester_encap_certificate_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

int libspdm_requester_encap_certificate_test_main(void)
{
const struct CMUnitTest spdm_requester_encap_certificate_tests[] = {
Expand All @@ -550,7 +545,12 @@ int libspdm_requester_encap_certificate_test_main(void)
cmocka_unit_test(libspdm_test_requester_encap_certificate_case7),
};

libspdm_setup_test_context(&m_libspdm_requester_encap_certificate_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_encap_certificate_tests,
libspdm_unit_test_group_setup,
Expand Down
12 changes: 6 additions & 6 deletions unit_test/test_spdm_requester/encap_challenge_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,6 @@ void test_libspdm_requester_encap_challenge_auth_case8(void **state)
free(data);
}

libspdm_test_context_t m_spdm_requester_challenge_auth_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

int libspdm_requester_encap_challenge_auth_test_main(void)
{
const struct CMUnitTest spdm_requester_challenge_auth_tests[] = {
Expand All @@ -587,7 +582,12 @@ int libspdm_requester_encap_challenge_auth_test_main(void)
cmocka_unit_test(test_libspdm_requester_encap_challenge_auth_case8),
};

libspdm_setup_test_context(&m_spdm_requester_challenge_auth_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_challenge_auth_tests,
libspdm_unit_test_group_setup,
Expand Down
12 changes: 6 additions & 6 deletions unit_test/test_spdm_requester/encap_digests.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,6 @@ void test_spdm_requester_encap_get_digests_case6(void **state)
}
}

libspdm_test_context_t m_spdm_requester_digests_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

int libspdm_requester_encap_digests_test_main(void)
{
const struct CMUnitTest spdm_requester_digests_tests[] = {
Expand All @@ -428,7 +423,12 @@ int libspdm_requester_encap_digests_test_main(void)
cmocka_unit_test(test_spdm_requester_encap_get_digests_case6),
};

libspdm_setup_test_context(&m_spdm_requester_digests_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_digests_tests,
libspdm_unit_test_group_setup,
Expand Down
14 changes: 6 additions & 8 deletions unit_test/test_spdm_requester/encap_key_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,13 +1078,6 @@ void test_libspdm_requester_encap_key_update_case14(void **state)
0);
}



libspdm_test_context_t m_libspdm_requester_encap_key_update_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

int libspdm_requester_encap_key_update_test_main(void)
{
const struct CMUnitTest spdm_requester_key_update_tests[] = {
Expand Down Expand Up @@ -1118,7 +1111,12 @@ int libspdm_requester_encap_key_update_test_main(void)
cmocka_unit_test(test_libspdm_requester_encap_key_update_case14),
};

libspdm_setup_test_context(&m_libspdm_requester_encap_key_update_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
false,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_key_update_tests,
libspdm_unit_test_group_setup,
Expand Down
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/encap_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,13 +1071,6 @@ void libspdm_test_requester_encap_request_case10(void **State)
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
}

libspdm_test_context_t m_libspdm_requester_encap_request_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_encap_request_test_send_message,
libspdm_requester_encap_request_test_receive_message,
};

int libspdm_requester_encap_request_test_main(void)
{
const struct CMUnitTest spdm_requester_encap_request_tests[] = {
Expand Down Expand Up @@ -1106,7 +1099,14 @@ int libspdm_requester_encap_request_test_main(void)
cmocka_unit_test(libspdm_test_requester_encap_request_case10),
};

libspdm_setup_test_context(&m_libspdm_requester_encap_request_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_encap_request_test_send_message,
libspdm_requester_encap_request_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_encap_request_tests,
libspdm_unit_test_group_setup,
Expand Down
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/end_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,13 +1731,6 @@ void libspdm_test_requester_end_session_case12(void **state)
free(data);
}

libspdm_test_context_t m_libspdm_requester_end_session_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_end_session_test_send_message,
libspdm_requester_end_session_test_receive_message,
};

int libspdm_requester_end_session_test_main(void)
{
const struct CMUnitTest spdm_requester_end_session_tests[] = {
Expand Down Expand Up @@ -1767,7 +1760,14 @@ int libspdm_requester_end_session_test_main(void)
cmocka_unit_test(libspdm_test_requester_end_session_case12),
};

libspdm_setup_test_context(&m_libspdm_requester_end_session_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_end_session_test_send_message,
libspdm_requester_end_session_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_end_session_tests,
libspdm_unit_test_group_setup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1998,13 +1998,6 @@ static void libspdm_test_requester_get_capabilities_err_case40(void **state)
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
}

static libspdm_test_context_t m_libspdm_requester_get_capabilities_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_capabilities_test_send_message,
libspdm_requester_get_capabilities_test_receive_message,
};

int libspdm_requester_get_capabilities_error_test_main(void)
{
const struct CMUnitTest m_spdm_requester_get_capabilities_tests[] = {
Expand Down Expand Up @@ -2050,7 +2043,14 @@ int libspdm_requester_get_capabilities_error_test_main(void)
cmocka_unit_test(libspdm_test_requester_get_capabilities_err_case40),
};

libspdm_setup_test_context(&m_libspdm_requester_get_capabilities_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_capabilities_test_send_message,
libspdm_requester_get_capabilities_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(m_spdm_requester_get_capabilities_tests,
libspdm_unit_test_group_setup,
Expand Down
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/error_test/get_digests_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -1586,13 +1586,6 @@ static void libspdm_test_requester_get_digests_err_case25(void **state)
{
}

static libspdm_test_context_t m_libspdm_requester_get_digests_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_digests_test_send_message,
libspdm_requester_get_digests_test_receive_message,
};

int libspdm_requester_get_digests_error_test_main(void)
{
const struct CMUnitTest spdm_requester_get_digests_tests[] = {
Expand Down Expand Up @@ -1623,7 +1616,14 @@ int libspdm_requester_get_digests_error_test_main(void)
cmocka_unit_test(libspdm_test_requester_get_digests_err_case25),
};

libspdm_setup_test_context(&m_libspdm_requester_get_digests_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_digests_test_send_message,
libspdm_requester_get_digests_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_get_digests_tests,
libspdm_unit_test_group_setup,
Expand Down
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/error_test/get_event_types_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,20 @@ static void libspdm_test_requester_get_event_types_err_case1(void **state)
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
}

static libspdm_test_context_t m_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
send_message,
receive_message,
};

int libspdm_requester_get_event_types_error_test_main(void)
{
const struct CMUnitTest spdm_requester_get_event_types_tests[] = {
cmocka_unit_test(libspdm_test_requester_get_event_types_err_case1)
};

libspdm_setup_test_context(&m_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
send_message,
receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_get_event_types_tests,
libspdm_unit_test_group_setup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4697,13 +4697,6 @@ static void libspdm_test_requester_get_measurements_err_case37(void **state)
{
}

static libspdm_test_context_t m_libspdm_requester_get_measurements_test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_measurements_test_send_message,
libspdm_requester_get_measurements_test_receive_message,
};

int libspdm_requester_get_measurements_error_test_main(void)
{
const struct CMUnitTest spdm_requester_get_measurements_tests[] = {
Expand Down Expand Up @@ -4746,7 +4739,14 @@ int libspdm_requester_get_measurements_error_test_main(void)
cmocka_unit_test(libspdm_test_requester_get_measurements_err_case37),
};

libspdm_setup_test_context(&m_libspdm_requester_get_measurements_test_context);
libspdm_test_context_t test_context = {
LIBSPDM_TEST_CONTEXT_VERSION,
true,
libspdm_requester_get_measurements_test_send_message,
libspdm_requester_get_measurements_test_receive_message,
};

libspdm_setup_test_context(&test_context);

return cmocka_run_group_tests(spdm_requester_get_measurements_tests,
libspdm_unit_test_group_setup,
Expand Down
Loading
Loading