Skip to content

Commit

Permalink
Fix the incorrect use of logical negation in the unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Xiao <[email protected]>
  • Loading branch information
Xiao authored and jyao1 committed Jul 17, 2024
1 parent fbc1960 commit 504fd45
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions unit_test/test_spdm_requester/error_test/key_exchange_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -5951,9 +5951,9 @@ static void libspdm_test_requester_key_exchange_err_case26(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down Expand Up @@ -6041,9 +6041,9 @@ static void libspdm_test_requester_key_exchange_err_case27(void **state)
measurement_hash);
/*Clear Mut_auth flags*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down Expand Up @@ -6131,9 +6131,9 @@ static void libspdm_test_requester_key_exchange_err_case28(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down Expand Up @@ -6233,9 +6233,9 @@ static void libspdm_test_requester_key_exchange_err_case31(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down
36 changes: 18 additions & 18 deletions unit_test/test_spdm_requester/key_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -6780,9 +6780,9 @@ static void libspdm_test_requester_key_exchange_case19(void **state)
measurement_hash);
/* Clear Handshake in the clear flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -6955,9 +6955,9 @@ static void libspdm_test_requester_key_exchange_case21(void **state)
measurement_hash);
/* clear Heartbeat flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -7052,9 +7052,9 @@ static void libspdm_test_requester_key_exchange_case22(void **state)

/*clear Heartbeat flags*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;

assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
Expand Down Expand Up @@ -7149,9 +7149,9 @@ static void libspdm_test_requester_key_exchange_case23(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -7242,9 +7242,9 @@ static void libspdm_test_requester_key_exchange_case24(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -7340,9 +7340,9 @@ static void libspdm_test_requester_key_exchange_case25(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -7438,9 +7438,9 @@ static void libspdm_test_requester_key_exchange_case26(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down Expand Up @@ -7528,9 +7528,9 @@ static void libspdm_test_requester_key_exchange_case27(void **state)
measurement_hash);
/*Clear Mut_auth flags*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down Expand Up @@ -7618,9 +7618,9 @@ static void libspdm_test_requester_key_exchange_case28(void **state)
measurement_hash);
/* Clear Mut_auth flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP;
assert_int_equal(status, LIBSPDM_STATUS_INVALID_MSG_FIELD);
free(data);
}
Expand Down
4 changes: 2 additions & 2 deletions unit_test/test_spdm_requester/key_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -4215,9 +4215,9 @@ void libspdm_test_requester_key_update_case12(void **state)

/*no capabilities*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;

session_info = &spdm_context->session_info[0];

Expand Down
8 changes: 4 additions & 4 deletions unit_test/test_spdm_requester/psk_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -4564,9 +4564,9 @@ void libspdm_test_requester_psk_exchange_case21(void **state)
&heartbeat_period, measurement_hash);
/* clear Heartbeat flags */
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
assert_int_equal(
Expand Down Expand Up @@ -4657,9 +4657,9 @@ void libspdm_test_requester_psk_exchange_case22(void **state)

/*clear Heartbeat flags*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP;

assert_int_equal(status, LIBSPDM_STATUS_SUCCESS);
assert_int_equal(session_id, 0xFFFFFFFF);
Expand Down
2 changes: 1 addition & 1 deletion unit_test/test_spdm_responder/key_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ void libspdm_test_responder_key_exchange_case11(void **state)

/* Clear capabilities flag */
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;

/*set capabilities flags */
spdm_context->connection_info.capability.flags |=
Expand Down
4 changes: 2 additions & 2 deletions unit_test/test_spdm_responder/key_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ void libspdm_test_responder_key_update_case8(void **state)

/*no capabilities*/
spdm_context->connection_info.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;
~SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;

session_info = &spdm_context->session_info[0];
secured_message_context = session_info->secured_message_context;
Expand Down
2 changes: 1 addition & 1 deletion unit_test/test_spdm_responder/psk_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ void libspdm_test_responder_psk_exchange_case13(void **state)
LIBSPDM_CONNECTION_STATE_NEGOTIATED;

spdm_context->local_context.capability.flags &=
!SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;
~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP;

spdm_context->connection_info.capability.flags |=
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP;
Expand Down

0 comments on commit 504fd45

Please sign in to comment.