ITS: Increase test coverage
* Add a test case to check that setting data that exceeds maximum
allowed size returns a failure.
* Modify existing test case to get after two consecutive sets
to check that the the most recent flag set is returned.
Signed-off-by: Awadhy Mohammed <awadhy.mohammed@arm.com>
Change-Id: I1c0e30d4aaac640d042f289bc2b12a2e64504758
diff --git a/test/secure_fw/suites/its/its_tests_common.c b/test/secure_fw/suites/its/its_tests_common.c
index 5ca2fdb..f0ddefd 100644
--- a/test/secure_fw/suites/its/its_tests_common.c
+++ b/test/secure_fw/suites/its/its_tests_common.c
@@ -97,6 +97,7 @@
const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const size_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
+ struct psa_storage_info_t info = {0};
/* Set with no flags */
status = psa_its_set(WRITE_ONCE_UID, data_len, write_data, flags);
@@ -112,6 +113,19 @@
TEST_FAIL("Set should not fail with valid flags (existing UID)");
return;
}
+
+ status = psa_its_get_info(WRITE_ONCE_UID, &info);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("Failed to get info.");
+ return;
+ }
+
+ /* Ensure that the latest set flag is returned */
+ if (info.flags != PSA_STORAGE_FLAG_WRITE_ONCE) {
+ TEST_FAIL("Failed to return most recent flag set.");
+ return;
+ }
+
} else if (status == PSA_ERROR_NOT_PERMITTED) {
/* The UID has already been created with the PSA_STORAGE_FLAG_WRITE_ONCE
* flag in a previous test run, so skip creating it again and emit a
@@ -1004,3 +1018,17 @@
ret->val = TEST_PASSED;
}
+
+void tfm_its_test_common_020(struct test_result_t *ret)
+{
+ psa_status_t status;
+ const uint8_t write_data[ITS_MAX_ASSET_SIZE + 1] = {0};
+
+ status = psa_its_set(TEST_UID_1, ITS_MAX_ASSET_SIZE + 1, write_data, PSA_STORAGE_FLAG_NONE);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
+ TEST_FAIL("Setting UID with size exceeding maximum did not return error");
+ return;
+ }
+
+ ret->val = TEST_PASSED;
+}
diff --git a/test/secure_fw/suites/its/its_tests_common.h b/test/secure_fw/suites/its/its_tests_common.h
index b6b1a24..36006c2 100644
--- a/test/secure_fw/suites/its/its_tests_common.h
+++ b/test/secure_fw/suites/its/its_tests_common.h
@@ -70,6 +70,7 @@
* \brief Tests set function with:
* - Zero create flags
* - Valid create flags (with previously created UID)
+ * - Valid flag is latest set (checked by getting info)
* - Invalid create flags
*
* \param[out] ret Test result
@@ -230,6 +231,14 @@
*/
void tfm_its_test_common_019(struct test_result_t *ret);
+/**
+* \brief Tests set function with:
+* - Invalid set length exceeds ITS_MAX_ASSET_SIZE
+*
+* \param[out] ret Test result
+*/
+void tfm_its_test_common_020(struct test_result_t *ret);
+
#ifdef __cplusplus
}
#endif
diff --git a/test/secure_fw/suites/its/non_secure/psa_its_ns_interface_testsuite.c b/test/secure_fw/suites/its/non_secure/psa_its_ns_interface_testsuite.c
index 60c87af..01718bd 100644
--- a/test/secure_fw/suites/its/non_secure/psa_its_ns_interface_testsuite.c
+++ b/test/secure_fw/suites/its/non_secure/psa_its_ns_interface_testsuite.c
@@ -13,7 +13,7 @@
{&tfm_its_test_common_001, "TFM_NS_ITS_TEST_1001",
"Set interface"},
{&tfm_its_test_common_002, "TFM_NS_ITS_TEST_1002",
- "Set interface with create flags"},
+ "Set interface with create flags and get latest set flag"},
{&tfm_its_test_common_003, "TFM_NS_ITS_TEST_1003",
"Set interface with NULL data pointer"},
{&tfm_its_test_common_004, "TFM_NS_ITS_TEST_1004",
@@ -48,6 +48,8 @@
"Multiple sets to same UID from same thread"},
{&tfm_its_test_common_019, "TFM_NS_ITS_TEST_1019",
"Set, get and remove interface with different asset sizes"},
+ {&tfm_its_test_common_020, "TFM_NS_ITS_TEST_1020",
+ "Set with asset size that exceeds the maximum"},
};
void register_testsuite_ns_psa_its_interface(struct test_suite_t *p_test_suite)
diff --git a/test/secure_fw/suites/its/secure/psa_its_s_interface_testsuite.c b/test/secure_fw/suites/its/secure/psa_its_s_interface_testsuite.c
index 4d08c47..e54d1ef 100644
--- a/test/secure_fw/suites/its/secure/psa_its_s_interface_testsuite.c
+++ b/test/secure_fw/suites/its/secure/psa_its_s_interface_testsuite.c
@@ -21,7 +21,7 @@
{&tfm_its_test_common_001, "TFM_S_ITS_TEST_1001",
"Set interface"},
{&tfm_its_test_common_002, "TFM_S_ITS_TEST_1002",
- "Set interface with create flags"},
+ "Set interface with create flags and get latest set flag"},
{&tfm_its_test_common_003, "TFM_S_ITS_TEST_1003",
"Set interface with NULL data pointer"},
{&tfm_its_test_common_004, "TFM_S_ITS_TEST_1004",
@@ -56,6 +56,8 @@
"Multiple sets to same UID from same thread"},
{&tfm_its_test_common_019, "TFM_S_ITS_TEST_1019",
"Set, get and remove interface with different asset sizes"},
+ {&tfm_its_test_common_020, "TFM_S_ITS_TEST_1020",
+ "Set with asset size that exceeds the maximum"},
{&tfm_its_test_1020, "TFM_S_ITS_TEST_1023",
"Attempt to get a UID set by a different partition"},
};