Skip to content

Commit

Permalink
Merge pull request #56 from chetansinghrathore/ew_beta0
Browse files Browse the repository at this point in the history
Reverting constant read buffer & MAX_UINT32 len check
  • Loading branch information
prasanth-pulla authored Feb 14, 2019
2 parents 6c42448 + 5c3c013 commit c5ddf85
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

#define TEST_BUFF_SIZE 1024
#define NUM_ITERATIONS 5
#define NUM_ITERATIONS 2
#define TEST_BASE_UID_VALUE UID_BASE_VALUE + 5

client_test_t test_s003_sst_list[] = {
Expand All @@ -35,6 +35,9 @@ client_test_t test_s003_sst_list[] = {
};

static uint8_t write_buff[TEST_BUFF_SIZE];
static char test_desc[2][80] = {
"Overload storage space\n",
"Overload storage again to verify all previous UID removed\n"};

int32_t psa_sst_insufficient_space(security_t caller)
{
Expand All @@ -46,7 +49,8 @@ int32_t psa_sst_insufficient_space(security_t caller)
/* Saturate the storage for NUM_ITERATION times, and remove them after */
for (i = 0 ; i < NUM_ITERATIONS; i++)
{
val->print(PRINT_TEST, "[Check %d] Overload storage space\n", i + 1 );
val->print(PRINT_TEST, "[Check %d] ", i + 1);
val->print(PRINT_TEST, &test_desc[i][0], 0);
for (uid = TEST_BASE_UID_VALUE; status == PSA_SST_SUCCESS; uid++)
{
val->print(PRINT_INFO, "Setting 0x%x bytes for ", TEST_BUFF_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ static const test_data s008_data[] = {
{
VAL_ITS_GET, PSA_ITS_SUCCESS /* Call get API with offset = MAX_UINT32 */
},
{
VAL_ITS_GET, PSA_ITS_SUCCESS /* Call get API with length = MAX_UINT32 */
},
{
VAL_ITS_REMOVE, PSA_ITS_SUCCESS /* Remove the storage entity */
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ static const test_data s008_data[] = {
{
VAL_PS_GET, PSA_PS_SUCCESS /* Call get API with offset = MAX_UINT32 */
},
{
VAL_PS_GET, PSA_PS_SUCCESS /* Call get API with length = MAX_UINT32 */
},
{
VAL_PS_REMOVE, PSA_PS_SUCCESS /* Remove the storage entity */
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@ int32_t psa_sst_invalid_offset_failure(security_t caller)
status = SST_FUNCTION(s008_data[12].api, uid, TEST_MAX_UINT32, TEST_BUFF_SIZE/2, read_buff);
TEST_ASSERT_NOT_EQUAL(status, s008_data[12].status, TEST_CHECKPOINT_NUM(12));

/* Try to access data with valid non-zero offset and length equal to MAX_UINT21 */
status = SST_FUNCTION(s008_data[13].api, uid, 4, TEST_MAX_UINT32, read_buff);
TEST_ASSERT_NOT_EQUAL(status, s008_data[13].status, TEST_CHECKPOINT_NUM(13));

/* Remove the UID */
status = SST_FUNCTION(s008_data[14].api, uid);
TEST_ASSERT_EQUAL(status, s008_data[14].status, TEST_CHECKPOINT_NUM(14));
status = SST_FUNCTION(s008_data[13].api, uid);
TEST_ASSERT_EQUAL(status, s008_data[13].status, TEST_CHECKPOINT_NUM(13));

return VAL_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ static const test_data s009_data[] = {
{
VAL_ITS_SET, PSA_ITS_SUCCESS /* Increase the asset size */
},
{
VAL_ITS_GET, PSA_ITS_ERROR_INVALID_ARGUMENTS /* Call get API with constant read buffer */
},
{
VAL_ITS_REMOVE, PSA_ITS_SUCCESS /* Remove the storage entity */
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ static const test_data s009_data[] = {
{
VAL_PS_SET, PSA_PS_SUCCESS /* Increase the asset size */
},
{
VAL_PS_GET, PSA_PS_ERROR_INVALID_ARGUMENT /* Call get API with constant read buffer */
},
{
VAL_PS_REMOVE, PSA_PS_SUCCESS /* Remove the storage entity */
},
Expand Down
16 changes: 5 additions & 11 deletions api-tests/dev_apis/internal_trusted_storage/test_s009/test_s009.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ client_test_t test_s009_sst_list[] = {
static psa_sst_uid_t uid = UID_BASE_VALUE + 5;
static uint8_t write_buff[TEST_BUFF_SIZE] = {0x99, 0x01, 0x02, 0x03, 0x04, 0x23, 0xF6, 0x07, 0x08, \
0x0D, 0x70, 0xA1, 0xFF, 0xFF, 0x14, 0x73, 0x46, 0x97, 0xE8, 0xDD};
static const uint8_t read_buff[TEST_BUFF_SIZE];

int32_t psa_sst_invalid_arguments_check(security_t caller)
{
uint32_t status;

/* Set data for UID with length 0 and NULL pointer */
val->print(PRINT_TEST, "[Check 1] Call set API with NULL write buffer\n", 0);
val->print(PRINT_TEST, "[Check 1] Call set API with NULL pointer and data length 0\n", 0);
status = SST_FUNCTION(s009_data[1].api, uid, 0, NULL, 0);
TEST_ASSERT_EQUAL(status, s009_data[1].status, TEST_CHECKPOINT_NUM(1));

Expand All @@ -56,7 +55,7 @@ int32_t psa_sst_invalid_arguments_check(security_t caller)
TEST_ASSERT_EQUAL(status, s009_data[3].status, TEST_CHECKPOINT_NUM(3));

/* Set data for UID with length 0 and NULL pointer */
val->print(PRINT_TEST, "[Check 3] Try to set NULL buffer for UID with data length\n", 0);
val->print(PRINT_TEST, "[Check 3] Try to set NULL buffer for existing UID\n", 0);
status = SST_FUNCTION(s009_data[4].api, uid, 0, NULL, 0);
TEST_ASSERT_EQUAL(status, s009_data[4].status, TEST_CHECKPOINT_NUM(4));

Expand All @@ -66,7 +65,7 @@ int32_t psa_sst_invalid_arguments_check(security_t caller)
TEST_ASSERT_EQUAL(info.size, 0, TEST_CHECKPOINT_NUM(6));

/* Call get API with NULL read buffer and valid UID */
val->print(PRINT_TEST, "[Check 4] Call get API with NULL read buffer\n", 0);
val->print(PRINT_TEST, "[Check 4] Call get API with NULL read buffer and data length 0\n", 0);
status = SST_FUNCTION(s009_data[7].api, uid, 0, 0, NULL);
TEST_ASSERT_EQUAL(status, s009_data[7].status, TEST_CHECKPOINT_NUM(7));

Expand All @@ -75,14 +74,9 @@ int32_t psa_sst_invalid_arguments_check(security_t caller)
status = SST_FUNCTION(s009_data[8].api, uid, TEST_BUFF_SIZE, write_buff, 0);
TEST_ASSERT_EQUAL(status, s009_data[8].status, TEST_CHECKPOINT_NUM(8));

/* Call the get function with const read bufferr */
val->print(PRINT_TEST, "[Check 6] Call get API with const read buffer\n", 0);
status = SST_FUNCTION(s009_data[9].api, uid, 0, TEST_BUFF_SIZE, read_buff);
TEST_ASSERT_EQUAL(status, s009_data[9].status, TEST_CHECKPOINT_NUM(9));

/* Remove the UID */
status = SST_FUNCTION(s009_data[10].api, uid);
TEST_ASSERT_EQUAL(status, s009_data[10].status, TEST_CHECKPOINT_NUM(10));
status = SST_FUNCTION(s009_data[9].api, uid);
TEST_ASSERT_EQUAL(status, s009_data[9].status, TEST_CHECKPOINT_NUM(9));

return VAL_STATUS_SUCCESS;
}
2 changes: 1 addition & 1 deletion api-tests/docs/psa_its_testlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Following are the requirements of the Storage Test Suite. <br />
|-----------|--------------------------------------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| test_s001 | PSA_ITS_ERROR_UID_NOT_FOUND | psa_its_get<br />psa_its_get_info <br />psa_its_remove<br /> | 1. Call get API with UID for which no UID/Data pair is created<br />2. Call get_info API for which no UID/Data pair is created<br />3. Call remove API for which no UID/Data pair is created<br />4. Set valid UID/Data pair with uid1<br />5. Set one more set of UID/Data pair, with different uid, than previous<br />6. Remove the uid of step 4.<br />7. Call get API for removed UID/data pair<br />8. Call get_info API for removed UID/Data pair<br />9. Call remove API for removed UID/Data pair<br />10. Set valid UID/Data pair<br />11. Call get API for different uid , then created<br />12. Call get_info API for different uid, then created<br />13. Call remove API for different uid, then created<br />14. Remove the created UID/Data pair.<br />15. Remove the stray uid.<br /> | UID value used are 5,6,7 |
| test_s002 | PSA_ITS_ERROR_WRITE_ONCE | psa_its_set<br />psa_its_remove<br /> | 1. Set valid UID/data value pair , with create flag value none.2. Call get and get_info API to validate the data, attributes associated with data<br />3. Call set API again with same uid and create flag PSA_PS_WRITE_ONCE_FLAG<br />4. Call get and get_info API to validate the data, attributes associated with data is not changed after second set operation<br />5. try to remove the UID/data pair.<br />6. Create new UID/data value pair, with create flag PSA_PS_WRITE_ONCE_FLAG<br />7. Try to remove the created UID.<br />8. Call get and get_info API to validate the data, attributes associated with data<br />9. Again call SET with same UID , create flag PSA_PS_WRITE_ONCE_FLAG but different data length<br />10. Try to remove the UID, PSA_ITS_ERROR_WRITE_ONCE error should be returned<br />11. Call get and get_info API to validate the data, attributes associated with data<br /> | UID value used are 1 and 2 |
| test_s003 | PSA_ITS_ERROR_INSUFFICIENT_SPACE | psa_its_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps 5 times, to check same number of uid <br /> | UID value starts from 5 and keep on incrementing till all space is exhausted |
| test_s003 | PSA_ITS_ERROR_INSUFFICIENT_SPACE | psa_its_set<br /> | 1. Create UID/data pairs, with data_len 256 bytes. Do this with incrementing uid values till we have INSUFFICENT_SPACE.<br />2. Remove all the UID/data pairs created.<br />3. Repeat the steps once more, to check all previous uid are removed successfully<br /> | UID value starts from 5 and keep on incrementing till all space is exhausted |
| test_s004 | PSA_ITS_SUCCESS | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | 1. Set a valid uid/data pair<br />2. Validate the data using get api<br />3. Change the data length to half of previous.<br />4. Call GET api with original data length , error should be returned and also the return buffer should be empty<br />5. Call GET api with correct data_len and validate the data received.<br />6. Check old data cannot be accessed.<br />7. Call REMOVE api to delete the UID/data pair<br /> | UID value used is 5 |
| test_s005 | PSA_ITS_SUCCESS | psa_its_set<br />psa_its_get<br />psa_its_get_info<br />psa_its_remove<br /> | 1. Set valid UID/data pair with varying uid and data_len <br />2. Call GET api and validate the set data<br />3. Call GET info api and validate the data attributes<br />4. Call REMOVE api to delete the UID/data pair<br /> | UID value used are 4 |
| test_s006 | PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED | psa_its_set<br /> | 1. Call the SET_INFO with minimum flag value to max flag value <br />2. Call GET_INFO api and validate the flag value<br />3. Remove the uid/data pair<br /> | UID value used is 5 |
Expand Down
Loading

0 comments on commit c5ddf85

Please sign in to comment.