ff testsuite #2 fixes and copyright updated
diff --git a/api-tests/val/common/val.h b/api-tests/val/common/val.h
index e14f69f..439e211 100644
--- a/api-tests/val/common/val.h
+++ b/api-tests/val/common/val.h
@@ -123,7 +123,7 @@
 
 #define TEST_ASSERT_EQUAL(arg1, arg2, checkpoint)                                   \
     do {                                                                            \
-        if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
+    	if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
         {                                                                           \
             return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);                             \
         }                                                                           \
@@ -138,7 +138,7 @@
 
 #define TEST_ASSERT_DUAL(arg1, status1, status2, checkpoint)                        \
     do {                                                                            \
-        if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
+    	if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
         {                                                                           \
             return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);                             \
         }                                                                           \
@@ -161,7 +161,7 @@
 
 #define TEST_ASSERT_NOT_EQUAL(arg1, arg2, checkpoint)                               \
     do {                                                                            \
-        if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
+    	if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
         {                                                                           \
             return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);                             \
         }                                                                           \
@@ -185,7 +185,7 @@
 
 #define TEST_ASSERT_RANGE(arg1, range1, range2, checkpoint)                         \
     do {                                                                            \
-        if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
+    	if ((arg1) == PAL_STATUS_UNSUPPORTED_FUNC)                                  \
         {                                                                           \
             return RESULT_SKIP(VAL_STATUS_UNSUPPORTED);                             \
         }                                                                           \
diff --git a/api-tests/val/nspe/val_framework.c b/api-tests/val/nspe/val_framework.c
index 54e5dbd..47254dd 100644
--- a/api-tests/val/nspe/val_framework.c
+++ b/api-tests/val/nspe/val_framework.c
@@ -271,45 +271,57 @@
             test_info.block_num = test_info.block_num + 2;
             val_print(PRINT_DEBUG, "[Check 2] PASSED\n", 0);
        }
+    }
+    else
+    {
+	  /*
+	   * Reboot have been expected by test in previous s run,
+	   * consider previous run pass and jump to next appropriate test function
+	   * of the same test if available.
+	   */
+       int32_t test_data = 0;
+ 	   status = val_get_test_data(NV_TEST_DATA1, &test_data);
+ 	   if (VAL_ERROR(status))
+ 	   {
+ 		   return VAL_STATUS_ERROR;
+ 	   }
+	   test_info.block_num = test_data + 1;
+	   val_print(PRINT_DEBUG, "[Check %d] PASSED\n", test_data);
+    }
 
-       status = val_set_boot_flag(BOOT_NOT_EXPECTED);
-       if (VAL_ERROR(status))
-       {
-           goto exit;
-       }
+    status = val_set_boot_flag(BOOT_NOT_EXPECTED);
+    if (VAL_ERROR(status))
+    {
+	   goto exit;
+    }
+
 
        /* switch to secure client */
 #if STATELESS_ROT == 1
-       status = val_execute_secure_test_func(&handle, test_info, CLIENT_TEST_DISPATCHER_HANDLE);
-       handle = (int32_t)CLIENT_TEST_DISPATCHER_HANDLE;
+   status = val_execute_secure_test_func(&handle, test_info, CLIENT_TEST_DISPATCHER_HANDLE);
+   handle = (int32_t)CLIENT_TEST_DISPATCHER_HANDLE;
 #else
-       status = val_execute_secure_test_func(&handle, test_info, CLIENT_TEST_DISPATCHER_SID);
+   status = val_execute_secure_test_func(&handle, test_info, CLIENT_TEST_DISPATCHER_SID);
 #endif
-       if (VAL_ERROR(status))
-       {
-           goto exit;
-       }
-
-       /* Retrive secure client test status */
-       status = val_get_secure_test_result(&handle);
-       if (IS_TEST_SKIP(status))
-       {
-            val_set_status(status);
-            return status;
-       }
-       if (VAL_ERROR(status))
-       {
-           goto exit;
-       }
-       return status;
-   }
-   else
+   if (VAL_ERROR(status))
    {
-       /* If we are here means, we are in third run of this test */
-       val_print(PRINT_DEBUG, "[Check 1] PASSED\n", 0);
-       return VAL_STATUS_SUCCESS;
+	   goto exit;
    }
 
+   /* Retrive secure client test status */
+   status = val_get_secure_test_result(&handle);
+   if (IS_TEST_SKIP(status))
+   {
+		val_set_status(status);
+		return status;
+   }
+   if (VAL_ERROR(status))
+   {
+	   goto exit;
+   }
+   return status;
+
+
 exit:
    val_set_status(RESULT_FAIL(status));
    return status;
@@ -707,3 +719,44 @@
    *state = boot.state;
    return status;
 }
+
+/**
+    @brief    - This function sets the test specific data
+                NVMEM location
+    @param    - nvm index
+    @param    - nvm testdata
+    @return   - val_status_t
+**/
+val_status_t val_set_test_data(int32_t nvm_index, int32_t test_data)
+{
+   val_status_t     status;
+
+   status = val_nvmem_write(VAL_NVMEM_OFFSET(nvm_index), &test_data, sizeof(int32_t));
+   if (VAL_ERROR(status))
+   {
+       val_print(PRINT_ERROR, "\tval_nvmem_write failed for test data. Error=0x%x\n", status);
+       return status;
+   }
+   return status;
+}
+
+/**
+    @brief    - This function gets the test specific data
+                NVMEM location
+    @param    - nvm index
+    @param    - nvm testdata
+    @return   - val_status_t
+**/
+val_status_t val_get_test_data(int32_t nvm_index, int32_t *test_data)
+{
+   val_status_t     status;
+
+   status = val_nvmem_read(VAL_NVMEM_OFFSET(nvm_index), test_data, sizeof(int32_t));
+   if (VAL_ERROR(status))
+   {
+       val_print(PRINT_ERROR, "\tval_nvmem_read failed for test data. Error=0x%x\n", status);
+       return status;
+   }
+   return status;
+}
+
diff --git a/api-tests/val/nspe/val_framework.h b/api-tests/val/nspe/val_framework.h
index 01b537b..a1420d8 100644
--- a/api-tests/val/nspe/val_framework.h
+++ b/api-tests/val/nspe/val_framework.h
@@ -49,4 +49,6 @@
 void         val_ipc_close(psa_handle_t handle);
 val_status_t val_set_boot_flag(boot_state_t state);
 val_status_t val_get_boot_flag(boot_state_t *state);
+val_status_t val_set_test_data(int32_t nvm_index, int32_t test_data);
+val_status_t val_get_test_data(int32_t nvm_index, int32_t *test_data);
 #endif
diff --git a/api-tests/val/nspe/val_interfaces.c b/api-tests/val/nspe/val_interfaces.c
index ca7ba08..cf84158 100644
--- a/api-tests/val/nspe/val_interfaces.c
+++ b/api-tests/val/nspe/val_interfaces.c
@@ -1,5 +1,5 @@
 /** @file
- * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited or its affiliates. All rights reserved.
  * SPDX-License-Identifier : Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,6 +57,8 @@
     .wd_reprogram_timer        = val_wd_reprogram_timer,
     .set_boot_flag             = val_set_boot_flag,
     .get_boot_flag             = val_get_boot_flag,
+	.set_test_data             = val_set_test_data,
+	.get_test_data             = val_get_test_data,
     .crypto_function           = val_crypto_function,
     .storage_function          = val_storage_function,
     .attestation_function      = val_attestation_function,
diff --git a/api-tests/val/nspe/val_interfaces.h b/api-tests/val/nspe/val_interfaces.h
index 503769f..01f07aa 100644
--- a/api-tests/val/nspe/val_interfaces.h
+++ b/api-tests/val/nspe/val_interfaces.h
@@ -1,5 +1,5 @@
 /** @file
- * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited or its affiliates. All rights reserved.
  * SPDX-License-Identifier : Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,6 +57,8 @@
     val_status_t     (*wd_reprogram_timer)        (wd_timeout_type_t timeout_type);
     val_status_t     (*set_boot_flag)             (boot_state_t state);
     val_status_t     (*get_boot_flag)             (boot_state_t *state);
+    val_status_t     (*get_test_data)             (int32_t nvm_index, int32_t *test_data);
+    val_status_t     (*set_test_data)             (int32_t nvm_index, int32_t test_data);
     int32_t          (*crypto_function)           (int type, ...);
     int32_t          (*storage_function)          (int type, ...);
     int32_t          (*attestation_function)      (int type, ...);
diff --git a/api-tests/val/spe/val_partition_common.h b/api-tests/val/spe/val_partition_common.h
index f52c340..7217b25 100644
--- a/api-tests/val/spe/val_partition_common.h
+++ b/api-tests/val/spe/val_partition_common.h
@@ -1,5 +1,5 @@
 /** @file
- * Copyright (c) 2018-2021, Arm Limited or its affiliates. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited or its affiliates. All rights reserved.
  * SPDX-License-Identifier : Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,6 +54,7 @@
 __UNUSED STATIC_DECLARE val_status_t val_err_check_set(uint32_t checkpoint, val_status_t status);
 __UNUSED STATIC_DECLARE val_status_t val_nvmem_write(uint32_t offset, void *buffer, int size);
 __UNUSED STATIC_DECLARE val_status_t val_set_boot_flag(boot_state_t state);
+__UNUSED STATIC_DECLARE val_status_t val_set_test_data(int32_t nvm_index, int32_t test_data);
 
 __UNUSED static val_api_t val_api = {
     .print                     = val_print,
@@ -64,6 +65,7 @@
     .ipc_call                  = val_ipc_call,
     .ipc_close                 = val_ipc_close,
     .set_boot_flag             = val_set_boot_flag,
+	.set_test_data             = val_set_test_data,
     .target_get_config         = val_target_get_config,
     .process_connect_request   = val_process_connect_request,
     .process_call_request      = val_process_call_request,
@@ -569,4 +571,26 @@
    }
    return status;
 }
+
+/**
+    @brief    - This function sets the test specific data
+                NVMEM location
+    @param    - nvm index
+    @param    - nvm testdata
+    @return   - val_status_t
+**/
+STATIC_DECLARE val_status_t val_set_test_data(int32_t nvm_index, int32_t test_data)
+{
+   val_status_t     status;
+
+   status = val_nvmem_write(VAL_NVMEM_OFFSET(nvm_index), &test_data, sizeof(int32_t));
+   if (VAL_ERROR(status))
+   {
+       val_print(PRINT_ERROR, "\tval_nvmem_write failed for test data. Error=0x%x\n", status);
+       return status;
+   }
+   return status;
+}
+
+
 #endif
diff --git a/api-tests/val/spe/val_service_defs.h b/api-tests/val/spe/val_service_defs.h
index 4b10804..1b69563 100644
--- a/api-tests/val/spe/val_service_defs.h
+++ b/api-tests/val/spe/val_service_defs.h
@@ -1,5 +1,5 @@
 /** @file
- * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited or its affiliates. All rights reserved.
  * SPDX-License-Identifier : Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,6 +85,7 @@
                                               size_t out_len);
   void         (*ipc_close)                  (psa_handle_t handle);
   val_status_t (*set_boot_flag)              (boot_state_t state);
+  val_status_t (*set_test_data)             (int32_t nvm_index, int32_t test_data);
   val_status_t (*target_get_config)          (cfg_id_t cfg_id, uint8_t **data, uint32_t *size);
   val_status_t (*process_connect_request)    (psa_signal_t sig, psa_msg_t *msg);
   val_status_t (*process_call_request)       (psa_signal_t sig, psa_msg_t *msg);