Build: Enable PS NV counter test by default

This patch enables the PS NV counter tests by default.
But there is no effect of it when regression tests are disabled.

Documentation of it is updated as well.

Change-Id: Ibbce9da66f0242135ba71f8b8e9f0225823ca66f
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/config/config_default.cmake b/config/config_default.cmake
index dc7ab25..8793177 100644
--- a/config/config_default.cmake
+++ b/config/config_default.cmake
@@ -122,7 +122,7 @@
 set(TFM_IRQ_TEST                        OFF         CACHE BOOL      "Enable IRQ tests")
 set(TFM_PERIPH_ACCESS_TEST              OFF         CACHE BOOL      "Enable peripheral access tests")
 
-set(PS_TEST_NV_COUNTERS                 OFF         CACHE BOOL      "Use the test NV counters to test Protected Storage rollback scenarios")
+set(PS_TEST_NV_COUNTERS                 ON          CACHE BOOL      "Use the test NV counters to test Protected Storage rollback scenarios")
 
 set(TFM_CRYPTO_TEST_ALG_CBC             ON          CACHE BOOL      "Test CBC cryptography mode")
 set(TFM_CRYPTO_TEST_ALG_CCM             ON          CACHE BOOL      "Test CCM cryptography mode")
diff --git a/docs/reference/services/tfm_ps_integration_guide.rst b/docs/reference/services/tfm_ps_integration_guide.rst
index 0a414f4..0138bc0 100644
--- a/docs/reference/services/tfm_ps_integration_guide.rst
+++ b/docs/reference/services/tfm_ps_integration_guide.rst
@@ -350,12 +350,12 @@
   RAM (fast access) and flash (persistent storage). The memory used by the
   object table is allocated statically as PS does not use dynamic memory
   allocation.
-- ``PS_TEST_NV_COUNTERS``- this flag enables the virtual
-  implementation of the PS NV counters interface in
-  ``test/suites/ps/secure/nv_counters``, which emulates NV counters in
+- ``PS_TEST_NV_COUNTERS``- this flag enables the virtual implementation of the
+  PS NV counters interface in ``test/suites/ps/secure/nv_counters`` of the
+  ``tf-m-tests`` repo, which emulates NV counters in
   RAM, and disables the hardware implementation of NV counters provided by
-  the secure service. This flag is enabled by default when building the
-  regression tests and disabled by default otherwise.  This flag can be
+  the secure service. This flag is enabled by default, but has no effect when
+  the regression tests are disabled. This flag can be
   overridden to ``OFF`` when building the regression tests. In this case,
   the PS rollback protection test suite will not be built, as it relies
   on extra functionality provided by the virtual NV counters to simulate
diff --git a/secure_fw/partitions/protected_storage/CMakeLists.txt b/secure_fw/partitions/protected_storage/CMakeLists.txt
index 8a27f4b..120b927 100644
--- a/secure_fw/partitions/protected_storage/CMakeLists.txt
+++ b/secure_fw/partitions/protected_storage/CMakeLists.txt
@@ -30,7 +30,9 @@
         ps_utils.c
         $<$<BOOL:${PS_ENCRYPTION}>:crypto/ps_crypto_interface.c>
         $<$<BOOL:${PS_ENCRYPTION}>:ps_encrypted_object.c>
-        $<$<NOT:$<BOOL:${PS_TEST_NV_COUNTERS}>>:nv_counters/ps_nv_counters.c>
+        # The test_ps_nv_counters.c will be used instead, when either NS and S
+        # test is ON and PS_TEST_NV_COUNTERS ON
+        $<$<NOT:$<AND:$<OR:$<BOOL:${TEST_NS}>,$<BOOL:${TEST_S}>>,$<BOOL:${PS_TEST_NV_COUNTERS}>>>:nv_counters/ps_nv_counters.c>
 )
 
 target_link_libraries(tfm_partition_ps