Test: Enable positive core tests in ipc model

Change-Id: Ib58e27bff608658fe382a6812f2b67b2b3c405b9
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 8e00003..7ed545a 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -147,18 +147,16 @@
 	set(SERVICE_TEST_NS ON)
 	if (CORE_IPC)
 		set(CORE_TEST_IPC ON)
-	else ()
-		set(CORE_TEST_POSITIVE ON)
 	endif()
+	set(CORE_TEST_POSITIVE ON)
 endif()
 
 if (CORE_TEST)
 	if (CORE_IPC)
 		set(CORE_TEST_IPC ON)
-	else()
-		set(CORE_TEST_POSITIVE ON)
-		set(CORE_TEST_INTERACTIVE OFF)
 	endif()
+	set(CORE_TEST_POSITIVE ON)
+	set(CORE_TEST_INTERACTIVE OFF)
 endif()
 
 if (CORE_TEST_INTERACTIVE)
diff --git a/configs/ConfigRegression.cmake b/configs/ConfigRegression.cmake
index c18ba29..cca5c4b 100644
--- a/configs/ConfigRegression.cmake
+++ b/configs/ConfigRegression.cmake
@@ -33,7 +33,7 @@
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION True)
-set (CORE_TEST False)
+set (CORE_TEST True)
 set (CORE_IPC False)
 set (PSA_API_TEST False)
 
diff --git a/configs/ConfigRegressionIPC.cmake b/configs/ConfigRegressionIPC.cmake
index 60b389b..bb797dc 100644
--- a/configs/ConfigRegressionIPC.cmake
+++ b/configs/ConfigRegressionIPC.cmake
@@ -33,7 +33,7 @@
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION True)
-set (CORE_TEST False)
+set (CORE_TEST True)
 set (CORE_IPC True)
 set (PSA_API_TEST False)
 
diff --git a/configs/ConfigRegressionIPCTfmLevel2.cmake b/configs/ConfigRegressionIPCTfmLevel2.cmake
index 17d6d90..d94e9d6 100644
--- a/configs/ConfigRegressionIPCTfmLevel2.cmake
+++ b/configs/ConfigRegressionIPCTfmLevel2.cmake
@@ -33,7 +33,7 @@
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION True)
-set (CORE_TEST False)
+set (CORE_TEST True)
 set (CORE_IPC True)
 set (PSA_API_TEST False)
 
diff --git a/secure_fw/core/ipc/include/tfm_spm.h b/secure_fw/core/ipc/include/tfm_spm.h
index d8bde34..f11f749 100644
--- a/secure_fw/core/ipc/include/tfm_spm.h
+++ b/secure_fw/core/ipc/include/tfm_spm.h
@@ -12,7 +12,7 @@
 #include "tfm_message_queue.h"
 #include "tfm_secure_api.h"
 
-#define TFM_SPM_MAX_ROT_SERV_NUM        28
+#define TFM_SPM_MAX_ROT_SERV_NUM        48
 #define TFM_VERSION_POLICY_RELAXED      0
 #define TFM_VERSION_POLICY_STRICT       1
 
diff --git a/test/framework/non_secure_suites.c b/test/framework/non_secure_suites.c
index fac7299..2dee95e 100644
--- a/test/framework/non_secure_suites.c
+++ b/test/framework/non_secure_suites.c
@@ -71,7 +71,7 @@
 #endif /* TFM_LVL == 3 */
 
 #ifdef CORE_TEST_POSITIVE
-#if !((TFM_LVL == 2) && defined(TFM_PSA_API))
+#if !defined(TFM_PSA_API) || (TFM_LVL == 1)
     /* Non-secure core test cases */
     {&register_testsuite_ns_core_positive, 0, 0, 0},
 #endif
diff --git a/test/suites/core/non_secure/core_ns_positive_testsuite.c b/test/suites/core/non_secure/core_ns_positive_testsuite.c
index 08f11a4..caf16d6 100644
--- a/test/suites/core/non_secure/core_ns_positive_testsuite.c
+++ b/test/suites/core/non_secure/core_ns_positive_testsuite.c
@@ -29,6 +29,7 @@
 static void tfm_core_test_mpu_access(struct test_result_t *ret);
 static void tfm_core_test_share_change(struct test_result_t *ret);
 static void tfm_core_test_get_caller_client_id(struct test_result_t *ret);
+static void tfm_core_test_spm_request(struct test_result_t *ret);
 #endif /* TFM_PSA_API */
 static void tfm_core_test_ns_thread(struct test_result_t *ret);
 static void tfm_core_test_check_init(struct test_result_t *ret);
@@ -37,7 +38,6 @@
 static void tfm_core_test_ss_to_ss(struct test_result_t *ret);
 static void tfm_core_test_ss_to_ss_buffer(struct test_result_t *ret);
 static void tfm_core_test_peripheral_access(struct test_result_t *ret);
-static void tfm_core_test_spm_request(struct test_result_t *ret);
 static void tfm_core_test_iovec_sanitization(struct test_result_t *ret);
 static void tfm_core_test_outvec_write(struct test_result_t *ret);
 static void tfm_core_test_secure_irq(struct test_result_t *ret);
@@ -80,10 +80,10 @@
 CORE_TEST_DESCRIPTION(CORE_TEST_ID_GET_CALLER_CLIENT_ID,
     tfm_core_test_get_caller_client_id,
     "Test get caller client ID function"),
-#endif /* TFM_PSA_API */
 CORE_TEST_DESCRIPTION(CORE_TEST_ID_SPM_REQUEST,
     tfm_core_test_spm_request,
     "Test SPM request function"),
+#endif /* TFM_PSA_API */
 CORE_TEST_DESCRIPTION(CORE_TEST_ID_IOVEC_SANITIZATION,
     tfm_core_test_iovec_sanitization,
     "Test service parameter sanitization"),
@@ -807,7 +807,6 @@
 
     ret->val = TEST_PASSED;
 }
-#endif /* TFM_PSA_API */
 
 static void tfm_core_test_spm_request(struct test_result_t *ret)
 {
@@ -831,3 +830,5 @@
 
     ret->val = TEST_PASSED;
 }
+
+#endif /* TFM_PSA_API */
diff --git a/test/test_services/tfm_core_test/core_test_defs.h b/test/test_services/tfm_core_test/core_test_defs.h
index c7a3ae1..48c9c08 100644
--- a/test/test_services/tfm_core_test/core_test_defs.h
+++ b/test/test_services/tfm_core_test/core_test_defs.h
@@ -100,6 +100,7 @@
 #define CORE_TEST_ERROR_GET_CODE(x) (x & 0xFFFF)
 
 enum core_test_errno_t {
+    CORE_TEST_ERRNO_TEST_NOT_SUPPORTED         = -13,
     CORE_TEST_ERRNO_SP_NOT_INITED              = -12,
     CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR  = -11,
     CORE_TEST_ERRNO_SP_RECURSION_NOT_REJECTED  = -10,
diff --git a/test/test_services/tfm_core_test/tfm_ss_core_test.c b/test/test_services/tfm_core_test/tfm_ss_core_test.c
index f6f3aa6..6488d79 100644
--- a/test/test_services/tfm_core_test/tfm_ss_core_test.c
+++ b/test/test_services/tfm_core_test/tfm_ss_core_test.c
@@ -24,6 +24,7 @@
 #define INVALID_NS_CLIENT_ID  0x49abcdef
 #define EXPECTED_NS_CLIENT_ID (-1)
 
+#ifndef TFM_PSA_API
 /* Don't initialise caller_partition_id_zi and expect it to be linked in the
  * zero-initialised data area
  */
@@ -36,7 +37,8 @@
 
 static int32_t* invalid_addresses [] = {(int32_t*)0x0, (int32_t*)0xFFF12000};
 
-#ifdef TFM_PSA_API
+#else /* !defined(TFM_PSA_API) */
+
 static psa_status_t psa_test_common(uint32_t sid, uint32_t minor_version,
                                     const psa_invec *in_vecs, size_t in_len,
                                     psa_outvec *out_vecs, size_t out_len)
@@ -57,7 +59,7 @@
     psa_close(handle);
     return status;
 }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
 psa_status_t spm_core_test_sfn_init_success(
                                      struct psa_invec *in_vec, size_t in_len,
@@ -74,6 +76,7 @@
     }
 }
 
+#ifndef TFM_PSA_API
 psa_status_t spm_core_test_sfn_direct_recursion(
                                      struct psa_invec *in_vec, size_t in_len,
                                      struct psa_outvec *out_vec, size_t out_len)
@@ -113,7 +116,6 @@
 /* Service RW data array for testing memory accesses */
 static int32_t mem[4] = {1, 2, 3, 4};
 
-
 static psa_status_t test_mpu_access(
     uint32_t *data_r_ptr, uint32_t *code_ptr, uint32_t *data_w_ptr)
 {
@@ -197,6 +199,7 @@
 
     return CORE_TEST_ERRNO_SUCCESS;
 }
+#endif /* !defined(TFM_PSA_API) */
 
 static psa_status_t test_share_redirection(void)
 {
@@ -206,7 +209,7 @@
     if (tfm_core_set_buffer_area(TFM_BUFFER_SHARE_SCRATCH) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     /* Read from scratch */
     tmp = tfm_scratch_area[0];
@@ -242,11 +245,17 @@
 {
     int32_t i;
     /* Service internal buffer */
-    uint32_t ss_buffer[SS_BUFFER_LEN];
+    uint32_t ss_buffer[SS_BUFFER_LEN] = {0};
     /* Slave service has to use scratch area */
+#ifdef TFM_PSA_API
+    uint32_t slave_buffer [len];
+    int32_t result;
+    int32_t *result_ptr = &result;
+#else
     uint32_t *slave_buffer = (uint32_t *)tfm_scratch_area;
-    /* Store result at end of scratch area to test entire range for RW access */
     int32_t *result_ptr = (int32_t *)&tfm_scratch_area[tfm_scratch_area_size-4];
+#endif /* TFM_PSA_API */
+    /* Store result at end of scratch area to test entire range for RW access */
     int32_t res;
     psa_invec in_vec[] = { {slave_buffer, len*sizeof(uint32_t)} };
     psa_outvec outvec[] = { {slave_buffer, len*sizeof(uint32_t)},
@@ -264,7 +273,7 @@
         TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS)) {
         return CORE_TEST_ERRNO_INVALID_BUFFER;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     for (i = 0; i < len; i++) {
         ss_buffer[i] = in_ptr[i];
@@ -274,7 +283,7 @@
     if (tfm_core_set_buffer_area(TFM_BUFFER_SHARE_SCRATCH) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     for (i = 0; i < len; i++) {
         slave_buffer[i] = ss_buffer[i];
@@ -286,9 +295,9 @@
     res = psa_test_common(SPM_CORE_TEST_2_INVERT_SID,
                           SPM_CORE_TEST_2_INVERT_MIN_VER,
                           in_vec, 1, outvec, 2);
-#else
+#else /* defined(TFM_PSA_API) */
     res = tfm_spm_core_test_2_sfn_invert_veneer(in_vec, 1, outvec, 2);
-#endif
+#endif /* defined(TFM_PSA_API) */
 
     if (res != CORE_TEST_ERRNO_SUCCESS) {
         return CORE_TEST_ERRNO_SLAVE_SP_CALL_FAILURE;
@@ -305,7 +314,7 @@
     if (tfm_core_set_buffer_area(TFM_BUFFER_SHARE_DEFAULT) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     for (i = 0; i < len; i++) {
         out_ptr[i] = ss_buffer[i];
@@ -318,7 +327,12 @@
 {
     int32_t err;
     int i;
-    uint8_t *scratch_ptr = (uint8_t *)tfm_scratch_area;
+#ifdef TFM_PSA_API
+    uint8_t data_buf [36]; /* (6 + 12) * 2 = 36 plus some alignment */
+    uint8_t *data_buf_ptr = data_buf;
+#else
+    uint8_t *data_buf_ptr = (uint8_t *)tfm_scratch_area;
+#endif
     psa_invec in_vec [2];
     psa_outvec out_vec [2];
     uint8_t *in_buf_0;
@@ -330,44 +344,44 @@
     if (tfm_core_set_buffer_area(TFM_BUFFER_SHARE_SCRATCH) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
-    in_buf_0 = scratch_ptr;
-    for (i = 0; i < 5; ++i, ++scratch_ptr)
+    in_buf_0 = data_buf_ptr;
+    for (i = 0; i < 5; ++i, ++data_buf_ptr)
     {
-        *scratch_ptr = i;
+        *data_buf_ptr = i;
     }
     in_vec[0].base = in_buf_0;
-    in_vec[0].len = scratch_ptr - in_buf_0;
+    in_vec[0].len = data_buf_ptr - in_buf_0;
 
-    in_buf_1 = scratch_ptr;
-    *(scratch_ptr++) = 1;
-    *(scratch_ptr++) = 1;
-    for (i = 2; i < 11; ++i, ++scratch_ptr)
+    in_buf_1 = data_buf_ptr;
+    *(data_buf_ptr++) = 1;
+    *(data_buf_ptr++) = 1;
+    for (i = 2; i < 11; ++i, ++data_buf_ptr)
     {
-        *scratch_ptr = *(scratch_ptr-1) + *(scratch_ptr-2);
+        *data_buf_ptr = *(data_buf_ptr-1) + *(data_buf_ptr-2);
     }
     in_vec[1].base = in_buf_1;
-    in_vec[1].len = scratch_ptr - in_buf_1;
+    in_vec[1].len = data_buf_ptr - in_buf_1;
 
-    out_buf_0 = scratch_ptr;
-    scratch_ptr += in_vec[0].len;
+    out_buf_0 = data_buf_ptr;
+    data_buf_ptr += in_vec[0].len;
     out_vec[0].base = out_buf_0;
-    out_vec[0].len = scratch_ptr - out_buf_0;
+    out_vec[0].len = data_buf_ptr - out_buf_0;
 
-    out_buf_1 = scratch_ptr;
-    scratch_ptr += in_vec[1].len;
+    out_buf_1 = data_buf_ptr;
+    data_buf_ptr += in_vec[1].len;
     out_vec[1].base = out_buf_0;
-    out_vec[1].len = scratch_ptr - out_buf_0;
+    out_vec[1].len = data_buf_ptr - out_buf_0;
 
 #ifdef TFM_PSA_API
     err = psa_test_common(SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_SID,
                           SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_MIN_VER,
                           in_vec, 2, out_vec, 2);
-#else
+#else /* defined(TFM_PSA_API) */
     err = tfm_spm_core_test_2_get_every_second_byte_veneer(in_vec, 2,
                                                            out_vec, 2);
-#endif
+#endif /* defined(TFM_PSA_API) */
 
     if (err != CORE_TEST_ERRNO_SUCCESS) {
         return CORE_TEST_ERRNO_TEST_FAULT;
@@ -392,7 +406,7 @@
     if (tfm_core_set_buffer_area(TFM_BUFFER_SHARE_DEFAULT) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     return CORE_TEST_ERRNO_SUCCESS;
 }
@@ -405,9 +419,9 @@
     ret = psa_test_common(SPM_CORE_TEST_2_SLAVE_SERVICE_SID,
                           SPM_CORE_TEST_2_SLAVE_SERVICE_MIN_VER,
                           NULL, 0, NULL, 0);
-#else /* TFM_PAS_API*/
+#else /* defined(TFM_PSA_API) */
     ret = tfm_spm_core_test_2_slave_service_veneer(NULL, 0, NULL, 0);
-#endif /* TFM_PAS_API*/
+#endif /* defined(TFM_PSA_API) */
     if (ret == CORE_TEST_ERRNO_SUCCESS_2) {
         return CORE_TEST_ERRNO_SUCCESS;
     } else {
@@ -415,6 +429,7 @@
     }
 }
 
+#ifndef TFM_PSA_API
 static psa_status_t test_get_caller_client_id(void)
 {
     /* Call to a special service that checks the caller service ID */
@@ -469,6 +484,7 @@
 
     return CORE_TEST_ERRNO_SUCCESS;
 }
+#endif /* !defined(TFM_PSA_API) */
 
 #ifdef CORE_TEST_INTERACTIVE
 static void wait_button_event(void)
@@ -490,19 +506,20 @@
     LOG_MSG("Leaving the service");
     return CORE_TEST_ERRNO_SUCCESS;
 }
-#endif
+#endif /* defined(CORE_TEST_INTERACTIVE) */
 
 static psa_status_t test_block(void)
 {
 #ifdef CORE_TEST_INTERACTIVE
     /* Only block if interactive test is turned on */
     return test_wait_button();
-#else
+#else /* defined(CORE_TEST_INTERACTIVE) */
     /* This test should not be run if interactive tests are disabled */
     return CORE_TEST_ERRNO_TEST_FAULT;
-#endif /* CORE_TEST_INTERACTIVE */
+#endif /* defined(CORE_TEST_INTERACTIVE) */
 }
 
+#ifndef TFM_PSA_API
 psa_status_t spm_core_test_sfn(struct psa_invec *in_vec, size_t in_len,
                           struct psa_outvec *out_vec, size_t out_len)
 {
@@ -576,7 +593,7 @@
     }
 }
 
-#ifdef TFM_PSA_API
+#else /* !defined(TFM_PSA_API) */
 
 #define SS_TO_SS_BUFFER_SIZE (16*4)
 
@@ -594,64 +611,12 @@
 
 static psa_status_t tfm_core_test_sfn_wrap_mpu_access(psa_msg_t *msg)
 {
-    size_t num;
-    uint32_t *data_r_ptr;
-    uint32_t *code_ptr;
-    uint32_t *data_w_ptr;
-
-    if ((msg->in_size[0] < sizeof(int32_t)) ||
-        (msg->in_size[1] < sizeof(int32_t)) ||
-        (msg->in_size[2] < sizeof(int32_t))) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 0, &data_r_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 1, &code_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 2, &data_w_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    return test_mpu_access(data_r_ptr, code_ptr, data_w_ptr);
+    return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
 }
 
 static psa_status_t tfm_core_test_sfn_wrap_memory_permissions(psa_msg_t *msg)
 {
-    size_t num;
-    uint32_t *data_r_ptr;
-    uint32_t *code_ptr;
-    uint32_t *data_w_ptr;
-
-    if ((msg->in_size[0] < sizeof(int32_t)) ||
-        (msg->in_size[1] < sizeof(int32_t)) ||
-        (msg->in_size[2] < sizeof(int32_t))) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 0, &data_r_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 1, &code_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    num = psa_read(msg->handle, 2, &data_w_ptr, sizeof(int32_t));
-    if (num != sizeof(int32_t)) {
-        return CORE_TEST_ERRNO_INVALID_PARAMETER;
-    }
-
-    return test_memory_permissions(data_r_ptr, code_ptr, data_w_ptr);
+    return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
 }
 
 static psa_status_t tfm_core_test_sfn_wrap_share_redirection(psa_msg_t *msg)
@@ -714,12 +679,12 @@
 
 static psa_status_t tfm_core_test_sfn_wrap_get_caller_client_id(psa_msg_t *msg)
 {
-    return test_get_caller_client_id();
+    return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
 }
 
 static psa_status_t tfm_core_test_sfn_wrap_spm_request(psa_msg_t *msg)
 {
-    return test_spm_request();
+    return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
 }
 
 static psa_status_t tfm_core_test_sfn_wrap_block(psa_msg_t *msg)
@@ -757,13 +722,13 @@
         break;
     }
 }
-#endif
+#endif /* !defined(TFM_PSA_API) */
 
 psa_status_t core_test_init(void)
 {
 #ifdef TFM_PSA_API
     psa_signal_t signals = 0;
-#endif
+#endif /* defined(TFM_PSA_API) */
 
     partition_init_done = 1;
 
@@ -813,7 +778,7 @@
             ; /* do nothing */
         }
     }
-#endif
+#endif /* defined(TFM_PSA_API) */
 
     return CORE_TEST_ERRNO_SUCCESS;
 }
diff --git a/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c b/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
index 4f93fc8..1d3e2bf 100644
--- a/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
+++ b/test/test_services/tfm_core_test_2/tfm_ss_core_test_2.c
@@ -17,6 +17,7 @@
 #define INVALID_NS_CLIENT_ID  0x49abcdef
 #define INVERT_BUFFER_SIZE    (16*4)
 
+#ifndef TFM_PSA_API
 /* Don't initialise caller_partition_id_zi and expect it to be linked in the
  * zero-initialised data area
  */
@@ -28,6 +29,7 @@
 static int32_t caller_client_id_rw = INVALID_NS_CLIENT_ID;
 
 static int32_t* invalid_addresses [] = {(int32_t*)0x0, (int32_t*)0xFFF12000};
+#endif /* !defined(TFM_PSA_API) */
 
 /* structures for secure IRQ testing */
 static enum irq_test_scenario_t current_scenario = IRQ_TEST_SCENARIO_NONE;
@@ -48,6 +50,7 @@
     return CORE_TEST_ERRNO_SUCCESS_2;
 }
 
+#ifndef TFM_PSA_API
 psa_status_t spm_core_test_2_check_caller_client_id(struct psa_invec *in_vec,
                                                     size_t in_len,
                                                     struct psa_outvec *out_vec,
@@ -87,6 +90,7 @@
 
     return CORE_TEST_ERRNO_SUCCESS;
 }
+#endif /* !defined(TFM_PSA_API) */
 
 psa_status_t spm_core_test_2_get_every_second_byte_internal(
                                                            const uint8_t *inbuf,
@@ -143,7 +147,7 @@
         TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS) {
         return CORE_TEST_ERRNO_INVALID_BUFFER;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
     *res_ptr = -1;
 
     if (len > SFN_INVERT_MAX_LEN) {
@@ -158,7 +162,7 @@
         TFM_MEMORY_ACCESS_RW) != TFM_SUCCESS)) {
         return CORE_TEST_ERRNO_INVALID_BUFFER;
     }
-#endif /* TFM_PSA_API */
+#endif /* !defined(TFM_PSA_API) */
 
     for (i = 0; i < len; i++) {
         invert_buffer[i] = in_ptr[i];
@@ -321,7 +325,7 @@
 
 psa_status_t spm_core_test_2_wrap_check_caller_client_id(psa_msg_t *msg)
 {
-    return spm_core_test_2_check_caller_client_id(NULL, 0, NULL, 0);
+    return CORE_TEST_ERRNO_TEST_NOT_SUPPORTED;
 }
 
 psa_status_t spm_core_test_2_wrap_get_every_second_byte(psa_msg_t *msg)
@@ -382,7 +386,7 @@
     }
 
     ret = spm_core_test_2_sfn_invert_internal(inbuf, outbuf,
-                                              &res_ptr, msg->in_size[0]);
+                                              &res_ptr, msg->in_size[0] / 4);
     if (ret < 0) {
         return ret;
     }
@@ -436,7 +440,7 @@
     return spm_core_test_2_execute_test_scenario_internal(irq_test_scenario);
 }
 
-#endif
+#endif /* defined(TFM_PSA_API) */
 
 /* FIXME: Add a testcase to test that a failed init makes the secure partition
  * closed, and none of its functions can be called.
@@ -475,6 +479,6 @@
             ; /* do nothing */
         }
     }
-#endif
+#endif /* defined(TFM_PSA_API) */
     return CORE_TEST_ERRNO_SUCCESS;
 }