Skip to content

Commit a76d735

Browse files
committed
Only change mock_import_data if import should succeed
1 parent b8ff1e9 commit a76d735

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ static psa_status_t mock_import( psa_key_slot_number_t slot_number,
125125
(void) p_data;
126126

127127
mock_import_data.called++;
128-
mock_import_data.slot_number = slot_number;
129-
mock_import_data.lifetime = lifetime;
130-
mock_import_data.type = type;
131-
mock_import_data.algorithm = algorithm;
132-
mock_import_data.usage = usage;
133-
mock_import_data.data_length = data_length;
128+
129+
if( mock_import_data.return_value == PSA_SUCCESS )
130+
{
131+
mock_import_data.slot_number = slot_number;
132+
mock_import_data.lifetime = lifetime;
133+
mock_import_data.type = type;
134+
mock_import_data.algorithm = algorithm;
135+
mock_import_data.usage = usage;
136+
mock_import_data.data_length = data_length;
137+
}
134138

135139
return( mock_import_data.return_value );
136140
}
@@ -270,8 +274,6 @@ void mock_import( int mock_alloc_return_value,
270274
&handle ) == expected_result );
271275

272276
TEST_ASSERT( mock_allocate_data.called == 1 );
273-
TEST_ASSERT( mock_import_data.called ==
274-
(expected_result == PSA_SUCCESS? 1 : 0) );
275277
TEST_ASSERT( mock_import_data.type ==
276278
(expected_result == PSA_SUCCESS? PSA_KEY_TYPE_RAW_DATA : 0));
277279

0 commit comments

Comments
 (0)