tf_fuzz: refactor expected value storage and simulation flow

Refactor the storage of expected values (expected_info), and add a
simulate function to psa_call, allowing expected value modelling and
call simulation code to be eventually combined into a single method.

* expected_info currently uses a set of mutually-exclusive boolean flags
  to model the different possible return codes. As the flags are checked
  in different orders across the code-base, failing to unset the right
  flags could cause different areas of the code to use different
  expected values.

  In this commit, an enum is used instead. This allows expected result
  checking to be performed by a single switch statement. This also makes
  checking to see if the value needs to be simulated much clearer --
  currently, this is denoted by both pf_nothing and pf_pass being false.

* Remove expected_info fields with no use.

* There is no one place where call simulation and expected error code
  modelling occurs. Expected return code modelling currently occur in
  fill_in_command and calc_result_code, and call simulation in
  copy_call_to_asset.

  The new psa_call::simulate() method is intended as the singular home
  for all call simulation code. Combining the simulation of a call's
  actions and its expected result should make modelling easier. This
  also makes expected value modelling happen in the simulation step
  only instead of in both the simulation and code-generation steps
  (fill_in_command and calc_result_code are code generation methods).

  Due to upcoming changes to the crypto simulation, moving call
  simulation code to simulate() has been left for future commits.

Change-Id: I1173164f07a3615c157845ed3abfebefde675c89
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 1dc95ae..4be4a1d 100644
--- a/tf_fuzz/tfz-cpp/tf_fuzz.cpp
+++ b/tf_fuzz/tfz-cpp/tf_fuzz.cpp
@@ -236,38 +236,42 @@
 
 /* simulate_calls() goes through the vector of generated calls calculating expected
    results for each. */
-void tf_fuzz_info::simulate_calls (void)
-{
+void tf_fuzz_info::simulate_calls (void){
     bool asset_state_changed = false;
 
-    IV(cout << "Call sequence:" << endl;)
-    /* For now, much of the simulation "thinking" infrastructure is here for future
-       elaboration.  The algorithm is to through each call one by one, copying
-       information to the asset in question.  Then each currently-active asset is
-       allowed to react to that information until they all agree that they're
-       "quiescent."  Finally, result information is copied from the asset back to
-       the call. */
+    IV(cout << "Call sequence:" << endl;);
+
+    /* The thinking logic will probably need elaborating in the future.
+     *
+     * The current algorithm goes through the calls, simuating their expected
+     * return codes. After call simulation, assets are updated, which are then
+     * allowed to react to the new information. Asset simulation loops until they
+     * all agree that they're "quiescent". Finally, result information is copied
+     * from the asset back to the call.
+     */
     for (auto this_call : calls) {
         IV(cout << "    " << this_call->call_description << " for asset "
                 << this_call->asset_info.get_name() << endl;)
+
+        this_call->simulate();
         this_call->copy_call_to_asset();
            /* Note:  this_call->the_asset will now point to the asset
                      associated with this_call, if any such asset exists. */
-        if (this_call->asset_info.the_asset != nullptr) {
-            /* If the asset exists, allow changes to it to affect other active
-               assets. */
-            asset_state_changed = false;
-            do {
-               for (auto this_asset : active_sst_asset) {
-                   asset_state_changed |= this_asset->simulate();
-               }
-               for (auto this_asset : active_policy_asset) {
-                   asset_state_changed |= this_asset->simulate();
-               }
-               for (auto this_asset : active_key_asset) {
-                   asset_state_changed |= this_asset->simulate();
-               }
-            } while (asset_state_changed);
+    if (this_call->asset_info.the_asset != nullptr) {
+      /* If the asset exists, allow changes to it to affect other active
+         assets. */
+      asset_state_changed = false;
+      do {
+        for (auto this_asset : active_sst_asset) {
+          asset_state_changed |= this_asset->simulate();
+        }
+        for (auto this_asset : active_policy_asset) {
+          asset_state_changed |= this_asset->simulate();
+        }
+        for (auto this_asset : active_key_asset) {
+          asset_state_changed |= this_asset->simulate();
+        }
+      } while (asset_state_changed);
         }
         this_call->copy_asset_to_call();
     }