Add logging RPC caller

To help debug PSA API tests, a simple logging RPC caller has been
added that can be stacked on top of another rpc_caller to log
call requests and responses.  The logging_caller has been
integrated into the psa-api-test deployment.  Logging may
be enabled using '-l' command line switch.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: Ib71d9fb2d6efbd2b5f513dd62b47109aab7ef55d
diff --git a/deployments/psa-api-test/arch_test_runner.c b/deployments/psa-api-test/arch_test_runner.c
index 90ca304..43ca703 100644
--- a/deployments/psa-api-test/arch_test_runner.c
+++ b/deployments/psa-api-test/arch_test_runner.c
@@ -5,20 +5,43 @@
  */
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <stdio.h>
+#include <string.h>
 #include <service_locator.h>
+#include <rpc/common/logging/logging_caller.h>
 #include "service_under_test.h"
 
 int32_t val_entry(void);
 
+static bool option_selected(const char *option_switch, int argc, char *argv[])
+{
+    bool selected = false;
+
+    for (int i = 1; (i < argc) && !selected; ++i) {
+
+        selected = (strcmp(argv[i], option_switch) == 0);
+    }
+
+    return selected;
+}
+
 int main(int argc, char *argv[])
 {
     int rval = -1;
+    struct logging_caller *selected_call_logger = NULL;
+    struct logging_caller call_logger;
 
+    logging_caller_init(&call_logger, stdout);
     service_locator_init();
 
-    rval = locate_service_under_test();
+    /* Check command line options */
+    if (option_selected("-l", argc, argv)) selected_call_logger = &call_logger;
 
+    /* Locate service under test */
+    rval = locate_service_under_test(selected_call_logger);
+
+    /* Run tests */
     if (!rval) {
 
         rval = val_entry();
@@ -30,5 +53,7 @@
         printf("Failed to locate service under test.  Error code: %d\n", rval);
     }
 
+    logging_caller_deinit(&call_logger);
+
     return rval;
 }