tf_fuzz: do not check sst read value when data_size=0
Do not run check code for sst read when the requested data size is 0.
Fixes demo/10.test. This demo failed as it does a 0 byte read followed
by a memcmp check. Memcmp with a buffer length of 0 returns 0; however,
the test wanted to check that the strings were different (!=0).
The length to read is set to 0 only when the fuzzer expects the asset to
not exist or be unreadable, so this essentially acts as a way for the
simulation step to decide to disable the check.
Change-Id: Iba21e7377fc3b84b2c0a67f527101ec789835d5e
Signed-off-by: Nik Dewally <Nik.Dewally@arm.com>
diff --git a/tf_fuzz/tfz-cpp/calls/sst_call.cpp b/tf_fuzz/tfz-cpp/calls/sst_call.cpp
index ac71a8d..5007314 100644
--- a/tf_fuzz/tfz-cpp/calls/sst_call.cpp
+++ b/tf_fuzz/tfz-cpp/calls/sst_call.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
*
@@ -332,7 +332,7 @@
void sst_get_call::fill_in_command (void)
{
- string exp_var_name, act_var_name, act_data_length, hash_var_name,
+ string exp_var_name, act_var_name, length_var_name,act_data_length, hash_var_name,
id_string, var_name_suffix;
/* TODO: Flesh-out/fix this (it was a good try/start, but not quite right):
@@ -399,11 +399,12 @@
find_replace_all ("$act_data", act_var_name, call_code);
find_replace_all ("$act_length", act_data_length, call_code);
// Perform most of the same substitutions in the check_code:
-// TODO: Make data checks contingent upon the PSA call itself passing?
+ // TODO: Make data checks contingent upon the PSA call itself passing?
find_replace_1st ("$offset", "0", check_code);
find_replace_1st ("$exp_data", exp_var_name, check_code);
find_replace_all ("$act_data", act_var_name, check_code);
- find_replace_all ("$length", act_data_length, check_code);
+ find_replace_all ("$length", to_string(set_data.get().length()), check_code);
+ find_replace_all ("$act_length", act_data_length, check_code);
if (print_data) {
check_code.append (test_state->bplate->bplate_string[test_log]);
find_replace_1st ("$message", act_var_name, check_code);
@@ -492,4 +493,3 @@
/**********************************************************************************
End of methods of class sst_remove_call.
**********************************************************************************/
-