Build: Add flag to protect NV counters when testing

Adds an SST_TEST_NV_COUNTERS build flag that enables a virtual
implementation of the SST NV counters interface and disables the
hardware NV counter implementation. This flag is automatically enabled
when running the regression tests to protect the hardware counters from
burn-out.

Change-Id: I7bd66ee45ea865dbf5af236123c4f7ef4391f249
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/test/framework/CMakeLists.inc b/test/framework/CMakeLists.inc
index e5b7d51..50fafb3 100644
--- a/test/framework/CMakeLists.inc
+++ b/test/framework/CMakeLists.inc
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -40,12 +40,6 @@
 list(APPEND ALL_SRC_C_S ${TEST_FRAMEWORK_C_SRC_S})
 list(APPEND ALL_SRC_C_NS ${TEST_FRAMEWORK_C_SRC_NS})
 
-#Add compile definitions
-if (SST_ROLLBACK_PROTECTION AND SST_ENCRYPTION AND TFM_LVL EQUAL 1)
-        set_property(SOURCE ${TEST_FRAMEWORK_C_SRC_S} APPEND PROPERTY COMPILE_DEFINITIONS SST_ROLLBACK_PROTECTION)
-endif()
-
 #Setting include directories
 embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
 embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
-
diff --git a/test/framework/secure_suites.c b/test/framework/secure_suites.c
index 4caf4ae..0b4c918 100644
--- a/test/framework/secure_suites.c
+++ b/test/framework/secure_suites.c
@@ -31,7 +31,7 @@
     {&register_testsuite_s_psa_ps_interface, 0, 0, 0},
     {&register_testsuite_s_psa_ps_reliability, 0, 0, 0},
 
-#if defined(SST_ROLLBACK_PROTECTION) && defined(SST_ENCRYPTION)
+#ifdef SST_TEST_NV_COUNTERS
     {&register_testsuite_s_rollback_protection, 0, 0, 0},
 #endif
 
diff --git a/test/suites/sst/CMakeLists.inc b/test/suites/sst/CMakeLists.inc
index 51e1bcf..407f16b 100644
--- a/test/suites/sst/CMakeLists.inc
+++ b/test/suites/sst/CMakeLists.inc
@@ -33,9 +33,10 @@
 	list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/psa_ps_s_interface_testsuite.c"
 				"${SECURE_STORAGE_TEST_DIR}/secure/psa_ps_s_reliability_testsuite.c")
 
-	if (SST_ROLLBACK_PROTECTION AND SST_ENCRYPTION AND TFM_LVL EQUAL 1)
+	if (SST_ENCRYPTION AND SST_ROLLBACK_PROTECTION AND SST_TEST_NV_COUNTERS)
 		list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/sst_rollback_protection_testsuite.c"
 					"${SECURE_STORAGE_TEST_DIR}/secure/nv_counters/test_sst_nv_counters.c")
+		set_property(SOURCE ${ALL_SRC_C_S} APPEND PROPERTY COMPILE_DEFINITIONS SST_TEST_NV_COUNTERS)
 	endif()
 
 	if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
diff --git a/test/suites/sst/secure/sst_tests.h b/test/suites/sst/secure/sst_tests.h
index cf0e98e..60cda80 100644
--- a/test/suites/sst/secure/sst_tests.h
+++ b/test/suites/sst/secure/sst_tests.h
@@ -28,8 +28,7 @@
  */
 void register_testsuite_s_psa_ps_reliability(struct test_suite_t *p_test_suite);
 
-#if defined(SST_ROLLBACK_PROTECTION) && defined(SST_ENCRYPTION) \
-    && (TFM_LVL == 1)
+#ifdef SST_TEST_NV_COUNTERS
 /**
  * \brief Register testsuite for the sst rollback protection tests.
  *