tf_fuzz: fix ps teardown boilerplate and disable teardown for write once assets
Fix failing demos 14,16,35 by fixing the teardown boilerplate and no
longer generating asset teardown code for Protected Storage assets with
the WRITE_ONCE flag.
Protected Storage assets with the WRITE_ONCE flag set cannot be removed
after creation. However, all Protected Storage assets, including those
with WRITE_ONCE, currently have teardown code that removes the asset
and ensures that this happened sucessfully. This causes test failures
for WRITE_ONCE assets.
As WRITE_ONCE assets now persist between tests, there is a possibility
that asset UIDs in different tests could collide. Because of this,
WRITE_ONCE can no longer be given to a PS asset during random flag
selection, and must be explicitly specified in the test template.
Change-Id: I4fa79f33851b6e580109acd4e40238c04e7ea773
Signed-off-by: Nik Dewally <Nik.Dewally@arm.com>
diff --git a/tf_fuzz/tfz-cpp/tf_fuzz.cpp b/tf_fuzz/tfz-cpp/tf_fuzz.cpp
index 3d52685..17c1881 100644
--- a/tf_fuzz/tfz-cpp/tf_fuzz.cpp
+++ b/tf_fuzz/tfz-cpp/tf_fuzz.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -157,6 +157,16 @@
string call;
// Traverse through the SST-assets list, writing out remove commands:
for (auto &asset : active_sst_asset) {
+ // write once assets cannot be removed
+
+ // NOTE: As write once assets persist across tests, there is as
+ // chance of UID collisions between tests. There is no technical solution
+ // for this - test authors just have to be careful in their use of
+ // WRITE_ONCE.
+ if (asset->set_data.flags_string.find("PSA_STORAGE_FLAG_WRITE_ONCE") !=
+ std::string::npos) {
+ continue;
+ }
call = bplate->bplate_string[teardown_sst];
find_replace_1st ("$uid", to_string(asset->asset_info.id_n), call);
call.append (bplate->bplate_string[teardown_sst_check]);